From 4ad9053cc576b74f74985f22fa5af25cca282a28 Mon Sep 17 00:00:00 2001
From: shiyunteng <shiyunteng@example.com>
Date: 星期五, 28 三月 2025 14:32:56 +0800
Subject: [PATCH] 合同审批 验收和台账中下拉 招标 中标编号后台生成 流水列表接口
---
platformx-device-biz/src/main/java/com/by4cloud/platformx/device/service/impl/ReceivingNoteServiceImpl.java | 114 ++++++++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 97 insertions(+), 17 deletions(-)
diff --git a/platformx-device-biz/src/main/java/com/by4cloud/platformx/device/service/impl/ReceivingNoteServiceImpl.java b/platformx-device-biz/src/main/java/com/by4cloud/platformx/device/service/impl/ReceivingNoteServiceImpl.java
index e4d4310..53bfba2 100644
--- a/platformx-device-biz/src/main/java/com/by4cloud/platformx/device/service/impl/ReceivingNoteServiceImpl.java
+++ b/platformx-device-biz/src/main/java/com/by4cloud/platformx/device/service/impl/ReceivingNoteServiceImpl.java
@@ -4,19 +4,22 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.by4cloud.platformx.common.core.util.R;
+import com.by4cloud.platformx.device.constant.MaxSizeContant;
import com.by4cloud.platformx.device.dto.ReceivingNoteQueryDTO;
-import com.by4cloud.platformx.device.entity.DeviceInventory;
-import com.by4cloud.platformx.device.entity.ReceivingNote;
-import com.by4cloud.platformx.device.entity.ReceivingNoteItem;
-import com.by4cloud.platformx.device.mapper.DeviceInventoryMapper;
-import com.by4cloud.platformx.device.mapper.ReceivingNoteItemMapper;
-import com.by4cloud.platformx.device.mapper.ReceivingNoteMapper;
+import com.by4cloud.platformx.device.entity.*;
+import com.by4cloud.platformx.device.mapper.*;
+import com.by4cloud.platformx.device.service.JcMaxSizeService;
import com.by4cloud.platformx.device.service.ReceivingNoteService;
import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
+import java.util.stream.Collectors;
/**
* 楠屾敹琛�
@@ -26,10 +29,16 @@
*/
@Service
@AllArgsConstructor
+@Slf4j
public class ReceivingNoteServiceImpl extends ServiceImpl<ReceivingNoteMapper, ReceivingNote> implements ReceivingNoteService {
+ private final JcMaxSizeService maxSizeService;
private final ReceivingNoteItemMapper itemMapper;
private final DeviceInventoryMapper inventoryMapper;
+ private final InventoryFlowWaterMapper inventoryFlowWaterMapper;
+ private final DeviceMapper deviceMapper;
+ private final ContractMapper contractMapper;
+ private final ContractItemMapper contractItemMapper;
@Override
public IPage pageNew(Page page, ReceivingNoteQueryDTO queryDTO) {
@@ -37,30 +46,95 @@
}
@Override
- public boolean saveDeep(ReceivingNote entity) {
+ public R saveDeep(ReceivingNote entity) {
+ //鏄庣粏璁惧鏁伴噺涓庡悎鍚屼腑绛捐鏁版嵁姣斿
+ Contract contract = contractMapper.selectById(entity.getContractId());
+ 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()!=entity.getNoteItemList().size()){
+ return R.failed("鍚堝悓涓澶囩绫讳笌楠屾敹鏄庣粏涓笉涓�鑷�");
+ }
+
+ //姣旇緝鍗曚釜璁惧鍙拌处鏁伴噺鏄惁涓庡悎鍚屼腑涓�鑷�
+ for (ContractItem contractItem:list
+ ) {
+ for (ReceivingNoteItem item:entity.getNoteItemList()
+ ) {
+ if (contractItem.getDeviceId().equals(item.getDeviceId())){
+ if (contractItem.getNum()!=item.getNum()) {
+ return R.failed("鍚堝悓涓�"+item.getDeviceName()+"璁惧鏁伴噺涓庨獙鏀舵槑缁嗕腑涓嶄竴鑷�");
+ }
+ }
+ }
+ }
+
+ //鐢熸垚楠屾敹鍗曠紪鍙�
+ entity.setReleaseCode(maxSizeService.nextNo(MaxSizeContant.RELEASE_CODE));
+ //鍏ュ簱
baseMapper.insert(entity);
if (entity.getNoteItemList()!=null&&entity.getNoteItemList().size()>0){
for (ReceivingNoteItem item:entity.getNoteItemList()
) {
+ List<String> serialArr = new ArrayList<>();
+ if (item.getSerialNos()!=null&&!"".equals(item.getSerialNos())) {
+ item.setSerialNos(item.getSerialNos());
+ serialArr = Arrays.stream(item.getSerialNos().split(",")).collect(Collectors.toList());
+ }
item.setNoteId(entity.getId());
itemMapper.insert(item);
//璁惧搴撳瓨鍚屾鏂板
- if (item.getSerialNos()!=null&&item.getSerialNos().size()>0){
- for (String serialNo:item.getSerialNos()
+ if (serialArr.size()>0){
+ for (String serialNo:serialArr
) {
- DeviceInventory inventory = new DeviceInventory();
- inventory.setDeviceId(item.getDeviceId());
- inventory.setDeviceNumber(item.getDeviceCode());
- inventory.setName(item.getDeviceName());
- inventory.setSerialNo(serialNo);
- inventory.setSource(1);
- inventoryMapper.insert(inventory);
+ 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(1);
+ 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);
+ }
}
}
}
}
- return Boolean.TRUE;
+
+ //鏇存柊鍚堝悓鐘舵�佷负瀹屾垚
+ contract.setStatus(2);
+ contractMapper.updateById(contract);
+
+ return R.ok();
}
@Override
@@ -88,4 +162,10 @@
note.setNoteItemList(itemList);
return note;
}
+
+ public static void main(String[] args) {
+ Long l1= 1905442028714270722l;
+ long l2 = 1905442028714270722l;
+ System.out.println(l1==l2);
+ }
}
--
Gitblit v1.9.1