platformx-device-api/src/main/java/com/by4cloud/platformx/device/entity/DeviceLeasingLedger.java
@@ -96,4 +96,11 @@ @Column(columnDefinition="datetime comment '出租日期'") private Date deliveryDate; /** * 合同id */ @Schema(description = "合同id") @Column(columnDefinition="bigint comment '合同id'") private Long contractId; } platformx-device-api/src/main/java/com/by4cloud/platformx/device/entity/vo/InventoryDetailVo.java
@@ -14,7 +14,7 @@ private String contractName; @Schema(description = "租赁方") private String partyb; private String rentName; @Schema(description = "设备编号") private String deviceNumber; platformx-device-api/src/main/java/com/by4cloud/platformx/device/entity/vo/InventoryFlowWaterPageVo.java
@@ -10,7 +10,7 @@ private Long id; private String devicName; private String deviceName; private String className; platformx-device-biz/src/main/java/com/by4cloud/platformx/device/mapper/DeviceLeasingLedgerItemMapper.java
@@ -3,9 +3,11 @@ import com.by4cloud.platformx.common.data.datascope.PlatformxBaseMapper; import com.by4cloud.platformx.device.entity.DeviceLeasingLedgerItem; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @Mapper public interface DeviceLeasingLedgerItemMapper extends PlatformxBaseMapper<DeviceLeasingLedgerItem> { Integer selectDeviceNumByContractId(@Param("contractId") Long contractId,@Param("deviceId") Long deviceId); } platformx-device-biz/src/main/java/com/by4cloud/platformx/device/mapper/ReceivingNoteItemMapper.java
@@ -14,4 +14,6 @@ IPage<ReceivingNoteItemPageVo> pageNew(Page page, @Param("queryDTO") ReceivingNoteItemQueryDTO queryDTO); Integer selectDeviceNumByContractId(@Param("contractId") Long contractId,@Param("deviceId") Long deviceId); } platformx-device-biz/src/main/java/com/by4cloud/platformx/device/service/impl/DeviceLeasingLedgerServiceImpl.java
@@ -71,16 +71,10 @@ if (contractItem.getNum()<item.getNum()) { return R.failed("合同中"+item.getDeviceName()+"设备数量与台账明细中不一致,无法建立台账"); } Integer deviceNum = itemMapper.selectDeviceNumByContractId(contract.getId(),contractItem.getDeviceId()); //查询是否有历史出账 QueryWrapper<DeviceLeasingLedgerItem> queryWrapperLedgerItem = new QueryWrapper<>(); queryWrapperLedgerItem.eq("contract_id",contract.getId()); queryWrapperLedgerItem.eq("device_id",contractItem.getDeviceId()); List<DeviceLeasingLedgerItem> noteItemList = itemMapper.selectList(queryWrapperLedgerItem); if (noteItemList != null&¬eItemList.size()>0) { Integer deviceNum = noteItemList.stream().mapToInt(DeviceLeasingLedgerItem::getNum).sum(); if (contractItem.getNum()<(item.getNum()+deviceNum)) { return R.failed("合同中"+item.getDeviceName()+"设备数量出租台账已超出设备库存,无法建立台账"); } return R.failed("合同中"+item.getDeviceName()+"设备数量出租台账已超出设备实际库存,无法建立台账"); } } } @@ -95,27 +89,15 @@ for (String serialNo:item.getSerialNos() ) { Device device = deviceMapper.selectById(item.getDeviceId()); if (device!=null) { DeviceInventory inventory = new DeviceInventory(); inventory.setDeviceId(item.getDeviceId()); inventory.setDeviceNumber(item.getDeviceCode()); inventory.setName(device.getName()); inventory.setSerialNo(serialNo); //根据合同类型 购买 承租 合同类型为入库操作 if (contract!=null&&(contract.getType()==1||contract.getType()==2)){ inventory.setSource(1); //入库操作 库存状态为 可用 inventory.setInventoryStatus(1); } //根据合同类型 租赁 合同类型为出库操作 if (contract!=null&&contract.getType()==0){ inventory.setSource(0); //出库操作 库存状态为 租赁中 QueryWrapper<DeviceInventory> inventoryQueryWrapper = new QueryWrapper<>(); inventoryQueryWrapper.eq("device_id",item.getDeviceId()); inventoryQueryWrapper.eq("serial_no",serialNo); DeviceInventory inventory = inventoryMapper.selectOne(inventoryQueryWrapper); if (device!=null&&inventory!=null) { inventory.setInventoryStatus(2); } inventory.setLedgerItemId(item.getId()); //库存调整 inventoryMapper.insert(inventory); inventoryMapper.updateById(inventory); //设备库存流水同步新增 InventoryFlowWater flowWater = new InventoryFlowWater(); @@ -139,17 +121,9 @@ //合同明细中与台账对比 for (ContractItem contractItem:list ) { //查询实际台账情况 QueryWrapper<DeviceLeasingLedgerItem> queryWrapperLedgerItem = new QueryWrapper<>(); queryWrapperLedgerItem.eq("contract_id",contract.getId()); queryWrapperLedgerItem.eq("device_id",contractItem.getDeviceId()); List<DeviceLeasingLedgerItem> ledgerItemList = itemMapper.selectList(queryWrapperLedgerItem); if (ledgerItemList != null&&ledgerItemList.size()>0) { Integer deviceNum = ledgerItemList.stream().mapToInt(DeviceLeasingLedgerItem::getNum).sum(); Integer deviceNum = itemMapper.selectDeviceNumByContractId(contract.getId(),contractItem.getDeviceId()); //查询是否有历史出账 if (contractItem.getNum()!=deviceNum) { return R.ok(); } }else { return R.ok(); } } platformx-device-biz/src/main/java/com/by4cloud/platformx/device/service/impl/ReceivingNoteServiceImpl.java
@@ -69,19 +69,12 @@ for (ReceivingNoteItem item:entity.getNoteItemList() ) { if (contractItem.getDeviceId().equals(item.getDeviceId())){ if (contractItem.getNum()>=item.getNum()) { if (contractItem.getNum() < item.getNum()) { return R.failed("验收明细中"+item.getDeviceName()+"设备数量不能超过合同明细中签订的设备数量"); } //查询是否有历史验收 QueryWrapper<ReceivingNoteItem> queryWrapperNoteItem = new QueryWrapper<>(); queryWrapperNoteItem.eq("contract_id",contract.getId()); queryWrapperNoteItem.eq("device_id",contractItem.getDeviceId()); List<ReceivingNoteItem> noteItemList = itemMapper.selectList(queryWrapperNoteItem); if (noteItemList != null&¬eItemList.size()>0) { Integer deviceNum = noteItemList.stream().mapToInt(ReceivingNoteItem::getNum).sum(); if (contractItem.getNum()>=(item.getNum()+deviceNum)) { return R.failed("合同中"+item.getDeviceName()+"设备数量与实际验收明细中不一致"); } Integer deviceNum = itemMapper.selectDeviceNumByContractId(contractItem.getContractId(),item.getDeviceId()); if (contractItem.getNum()<(deviceNum+item.getNum())){ return R.failed("实际验收明细中"+item.getDeviceName()+"设备数量不能超过合同明细中签订的设备数量"); } } //设备序列号检查是否有相同的存在 @@ -156,17 +149,8 @@ //合同明细中与实际验收对比 for (ContractItem contractItem:list ) { //查询实际验收情况 QueryWrapper<ReceivingNoteItem> queryWrapperNoteItem = new QueryWrapper<>(); queryWrapperNoteItem.eq("contract_id",contract.getId()); queryWrapperNoteItem.eq("device_id",contractItem.getDeviceId()); List<ReceivingNoteItem> noteItemList = itemMapper.selectList(queryWrapperNoteItem); if (noteItemList != null&¬eItemList.size()>0) { Integer deviceNum = noteItemList.stream().mapToInt(ReceivingNoteItem::getNum).sum(); Integer deviceNum = itemMapper.selectDeviceNumByContractId(contractItem.getContractId(),contractItem.getDeviceId()); if (contractItem.getNum()!=deviceNum) { return R.ok(); } }else { return R.ok(); } } @@ -204,8 +188,8 @@ } public static void main(String[] args) { Long l1= 1905442028714270722l; long l2 = 1905442028714270722l; System.out.println(l1==l2); int l1= 2; int l2 = 3; System.out.println(l1>=l2); } } platformx-device-biz/src/main/resources/mapper/DeviceLeasingLedgerItemMapper.xml
@@ -19,4 +19,20 @@ <result property="updateTime" column="update_time"/> <result property="delFlag" column="del_flag"/> </resultMap> <select id="selectDeviceNumByContractId" resultType="java.lang.Integer"> select ifnull(sum(dlli.num),0) from device_leasing_ledger_item dlli where dlli.device_id = #{deviceId} and exists ( select * from device_leasing_ledger dll where dll.contract_id = #{contractId} and dll.id = dlli.ledger_id ) </select> </mapper> platformx-device-biz/src/main/resources/mapper/InventoryFlowWaterMapper.xml
@@ -21,7 +21,7 @@ <select id="pageNew" resultType="com.by4cloud.platformx.device.entity.vo.InventoryFlowWaterPageVo"> select ifw.id, d.name devicName, d.name deviceName, dc.name className, d.create_time , ifw.operate_type, platformx-device-biz/src/main/resources/mapper/ReceivingNoteItemMapper.xml
@@ -39,4 +39,20 @@ and rni.note_id = #{queryDTO.noteId} </if> </select> <select id="selectDeviceNumByContractId" resultType="java.lang.Integer"> select ifnull(sum(rni.num),0) from receiving_note_item rni where rni.device_id = #{deviceId} and exists ( select * from receiving_note rn where rn.contract_id = #{contractId} and rn.id = rni.note_id) </select> </mapper> platformx-device-biz/src/main/resources/mapper/deviceInventoryMapper.xml
@@ -21,7 +21,7 @@ <select id="getReleaseDetail" resultType="com.by4cloud.platformx.device.entity.vo.InventoryDetailVo"> select c.name contractName, c.partyb, sd.name rentName, di.device_number, di.serial_no, dll.delivery_date @@ -33,6 +33,8 @@ dll.id = dlli.ledger_id join contract c on c.`number` = dll.contract_code join platformxx_boot.sys_dept sd on sd.dept_id = dll.lessee_contract_id where di.id =#{id} </select>