From dc0dc216eec524e67ce19f820d2501a3798fcfe0 Mon Sep 17 00:00:00 2001 From: kongdeqiang <123456> Date: 星期五, 28 三月 2025 16:49:45 +0800 Subject: [PATCH] fix: 年度投资计划 --- platformx-device-biz/src/main/java/com/by4cloud/platformx/device/service/impl/DeviceLeasingLedgerServiceImpl.java | 122 +++++++++++++++++++++++++++++++++++++++- 1 files changed, 118 insertions(+), 4 deletions(-) diff --git a/platformx-device-biz/src/main/java/com/by4cloud/platformx/device/service/impl/DeviceLeasingLedgerServiceImpl.java b/platformx-device-biz/src/main/java/com/by4cloud/platformx/device/service/impl/DeviceLeasingLedgerServiceImpl.java index 44c7d67..34f149f 100644 --- a/platformx-device-biz/src/main/java/com/by4cloud/platformx/device/service/impl/DeviceLeasingLedgerServiceImpl.java +++ b/platformx-device-biz/src/main/java/com/by4cloud/platformx/device/service/impl/DeviceLeasingLedgerServiceImpl.java @@ -2,12 +2,12 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.by4cloud.platformx.device.entity.Device; -import com.by4cloud.platformx.device.entity.DeviceLeasingLedger; -import com.by4cloud.platformx.device.mapper.DeviceLeasingLedgerMapper; -import com.by4cloud.platformx.device.mapper.DeviceMapper; +import com.by4cloud.platformx.common.core.util.R; +import com.by4cloud.platformx.device.entity.*; +import com.by4cloud.platformx.device.mapper.*; import com.by4cloud.platformx.device.service.DeviceLeasingLedgerService; import lombok.AllArgsConstructor; +import net.sf.jsqlparser.expression.operators.arithmetic.Concat; import org.springframework.stereotype.Service; import java.util.List; @@ -23,6 +23,11 @@ public class DeviceLeasingLedgerServiceImpl extends ServiceImpl<DeviceLeasingLedgerMapper, DeviceLeasingLedger> implements DeviceLeasingLedgerService { private final DeviceMapper deviceMapper; + private final DeviceLeasingLedgerItemMapper itemMapper; + private final ContractItemMapper contractItemMapper; + private final ContractMapper contractMapper; + private final DeviceInventoryMapper inventoryMapper; + private final InventoryFlowWaterMapper inventoryFlowWaterMapper; @Override public List<DeviceLeasingLedger> getSelectList() { @@ -36,4 +41,113 @@ List<Device> list = deviceMapper.getDeviceSelectListByLedgerId(ledgerId); return list; } + + @Override + public R saveDeep(DeviceLeasingLedger deviceLeasingLedger) { + //鏄庣粏璁惧鏁伴噺涓庡悎鍚屼腑绛捐鏁版嵁姣斿 + QueryWrapper<Contract> contractQueryWrapper = new QueryWrapper<>(); + contractQueryWrapper.eq("number",deviceLeasingLedger.getContractCode()); + Contract contract = contractMapper.selectOne(contractQueryWrapper); + if (contract == null) { + return R.failed("鍚堝悓涓嶅瓨鍦�"); + } + + //鏌ヨ鍚堝悓鏄庣粏涓澶囨儏鍐� + QueryWrapper<ContractItem> queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("contract_id",contract.getId()); + List<ContractItem> list = contractItemMapper.selectList(queryWrapper); + + //姣旇緝璁惧绉嶇被鏄惁涓�鑷� + if (list.size()!=deviceLeasingLedger.getLedgerItemList().size()){ + return R.failed("鍚堝悓涓澶囩绫讳笌鍙拌处鏄庣粏涓笉涓�鑷�"); + } + + //姣旇緝鍗曚釜璁惧鍙拌处鏁伴噺鏄惁涓庡悎鍚屼腑涓�鑷� + for (ContractItem contractItem:list + ) { + for (DeviceLeasingLedgerItem item:deviceLeasingLedger.getLedgerItemList() + ) { + if (contractItem.getDeviceId().equals(item.getDeviceId())){ + if (contractItem.getNum()!=item.getNum()) { + return R.failed("鍚堝悓涓�"+item.getDeviceName()+"璁惧鏁伴噺涓庡彴璐︽槑缁嗕腑涓嶄竴鑷�"); + } + } + } + } + + //鍏ュ簱 + baseMapper.insert(deviceLeasingLedger); + for (DeviceLeasingLedgerItem item:deviceLeasingLedger.getLedgerItemList() + ) { + item.setLedgerId(deviceLeasingLedger.getId()); + itemMapper.insert(item); + 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); + //鍑哄簱鎿嶄綔 搴撳瓨鐘舵�佷负 绉熻祦涓� + inventory.setInventoryStatus(2); + } + //搴撳瓨璋冩暣 + inventoryMapper.insert(inventory); + + //璁惧搴撳瓨娴佹按鍚屾鏂板 + InventoryFlowWater flowWater = new InventoryFlowWater(); + flowWater.setDeviceId(item.getDeviceId()); + flowWater.setSerialNo(serialNo); + flowWater.setInventoryId(inventory.getId()); + flowWater.setClassId(device.getClassId()); + //鏍规嵁鍚堝悓绫诲瀷 璐拱 鎵跨 娴佹按鎿嶄綔绫诲瀷涓哄叆搴撴搷浣� + if (contract!=null&&(contract.getType()==1||contract.getType()==2)){ + flowWater.setOperateType(2); + } + //鏍规嵁鍚堝悓绫诲瀷 绉熻祦 娴佹按鎿嶄綔绫诲瀷涓哄嚭搴撴搷浣� + if (contract!=null&&contract.getType()==0){ + flowWater.setOperateType(1); + } + //璁板綍搴撳瓨娴佹按 + inventoryFlowWaterMapper.insert(flowWater); + } + } + } + + //鏇存柊鍚堝悓鐘舵�佷负瀹屾垚 + contract.setStatus(2); + contractMapper.updateById(contract); + + return R.ok(); + } + + @Override + public List<DeviceInventory> getLedgerDeviceList(Long deviceId) { + QueryWrapper<DeviceInventory> queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("device_id",deviceId); + queryWrapper.eq("inventory_status",1); + List<DeviceInventory> list = inventoryMapper.selectList(queryWrapper); + return list; + } + + @Override + public DeviceLeasingLedger getByIdDeep(Long id) { + DeviceLeasingLedger deviceLeasingLedger = baseMapper.selectById(id); + QueryWrapper<DeviceLeasingLedgerItem> queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("ledger_id",id); + List<DeviceLeasingLedgerItem> itemList = itemMapper.selectList(queryWrapper); + deviceLeasingLedger.setLedgerItemList(itemList); + return deviceLeasingLedger; + } } \ No newline at end of file -- Gitblit v1.9.1