明细批量修改接口修改
This commit is contained in:
父節點
16f70ba4a4
當前提交
b8bddc66bf
@ -3,6 +3,7 @@ package com.deer.wms.produce.manage.dao;
|
||||
import com.deer.wms.produce.manage.model.ProductBatchDetect;
|
||||
import com.deer.wms.produce.manage.model.ProductBatchDetectParams;
|
||||
import com.deer.wms.project.seed.core.mapper.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -54,11 +54,11 @@
|
||||
|
||||
<delete id="deleteByBatchDet" parameterType="com.deer.wms.produce.manage.model.ProductBatchDetectParams">
|
||||
DELETE FROM mt_alone_product_batch_detect_det WHERE 1>2 OR ( batch_det_id IN
|
||||
<foreach collection="params.batchDetIdList" item="item" open="(" separator="," close=")">
|
||||
#{params.batchDetIdList[${item}]}
|
||||
<foreach collection="batchDetIdList" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
<if test="companyId != null">
|
||||
AND company_id = #{params.companyId}
|
||||
AND company_id = #{companyId}
|
||||
</if> )
|
||||
</delete>
|
||||
</mapper>
|
@ -38,11 +38,11 @@
|
||||
|
||||
<delete id="deleteByBatchDet" parameterType="com.deer.wms.produce.manage.model.ProductBatchDetectParams">
|
||||
DELETE FROM mt_alone_product_batch_detect WHERE 1>2 OR ( batch_det_id IN
|
||||
<foreach collection="params.batchDetIdList" item="item" open="(" separator="," close=")">
|
||||
#{params.batchDetIdList[${item}]}
|
||||
<foreach collection="batchDetIdList" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
<if test="companyId != null">
|
||||
AND company_id = #{params.companyId}
|
||||
AND company_id = #{companyId}
|
||||
</if> )
|
||||
</delete>
|
||||
|
||||
|
@ -99,7 +99,7 @@
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="findMaxVolumeNumByProductProcess" parameterType="com.deer.wms.produce.manage.model.ProductProcessParams">
|
||||
<select id="findMaxVolumeNumByProductProcess" parameterType="com.deer.wms.produce.manage.model.ProductProcessParams" resultType="java.lang.Integer">
|
||||
SELECT MAX(CAST(det.volume_num AS DECIMAL)) FROM mt_alone_product_process_batch_det det
|
||||
<where>
|
||||
<if test="productProcessId != null">
|
||||
|
@ -64,8 +64,9 @@ public class ProductProcessBatchDetServiceImpl extends AbstractService<ProductPr
|
||||
ProductProcess currentProductProcess = productProcessService.findById(batchDetListAndProductProcess.getProductProcessId());
|
||||
//获取当前加工单下库表中所有的明细
|
||||
List<ProductProcessBatchDetVo> batchDetVoListDB = productProcessBatchDetService.findListByProductProcess(productProcessParams);
|
||||
//设置加工单的总卷数与前端明细个数相同,并更新加工单信息
|
||||
currentProductProcess.setPiNum(null==batchDetListFront?0:batchDetListFront.size());
|
||||
|
||||
//设置当前加工单的总卷数与前端明细个数相同,并更新加工单信息
|
||||
currentProductProcess.setPiNum(null==batchDetListFront ? 0:batchDetListFront.size());
|
||||
productProcessService.update(currentProductProcess);
|
||||
|
||||
Date date = new Date();
|
||||
@ -76,14 +77,15 @@ public class ProductProcessBatchDetServiceImpl extends AbstractService<ProductPr
|
||||
|
||||
/**原则:从前端的明细list中判断,先拿出有id的明细更新,再插入没id的明细,最后删除前端已移除的明细(即库表中在前端找不到对应id的明细)**/
|
||||
if(null!=batchDetListFront && batchDetListFront.size()!=0){//如果前端有明细
|
||||
//将已有(非新增)明细放入一个list
|
||||
//存放库表已有(非新增)明细
|
||||
List<ProductProcessBatchDet> updateList = new ArrayList<ProductProcessBatchDet>();
|
||||
//将新增明细放入一个list
|
||||
//存放新增明细
|
||||
List<ProductProcessBatchDet> addList = new ArrayList<ProductProcessBatchDet>();
|
||||
for (ProductProcessBatchDet productProcessBatchDet : batchDetListFront){
|
||||
if(null!=productProcessBatchDet.getId()){//已有的明细(非新增明细),有id
|
||||
if(null!=productProcessBatchDet.getId()){//库表已有的明细(非新增明细),有id
|
||||
productProcessBatchDet.setUpdateTime(date);
|
||||
productProcessBatchDet.setShrinkage(productProcessBatchDet.getLen()/productProcessBatchDet.getDetectionLen()+"");
|
||||
//空值或零值情况判断
|
||||
productProcessBatchDet.setShrinkage((null==productProcessBatchDet.getDetectionLen() || productProcessBatchDet.getDetectionLen()==0)?"0":(((null==productProcessBatchDet.getLen() || productProcessBatchDet.getLen()==0)?0:productProcessBatchDet.getLen())/productProcessBatchDet.getDetectionLen()+""));
|
||||
updateList.add(productProcessBatchDet);
|
||||
}else{//新增明细,没有id
|
||||
productProcessBatchDet.setCreateTime(date);
|
||||
@ -95,14 +97,15 @@ public class ProductProcessBatchDetServiceImpl extends AbstractService<ProductPr
|
||||
productProcessBatchDet.setDeliveryCode(currentProductProcess.getDeliveryCode());
|
||||
productProcessBatchDet.setProductProcessId(currentProductProcess.getId());
|
||||
productProcessBatchDet.setVolumeNum((maxVolumeNumDB++)+"");
|
||||
productProcessBatchDet.setBatchCode(ProduceManagePublicMethod.creatBatchDetCode(date, currentProductProcess.getId(), currentProductProcess.getBatchCode(), productProcessBatchDet.getVolumeNum()));
|
||||
productProcessBatchDet.setShrinkage(productProcessBatchDet.getLen()/productProcessBatchDet.getDetectionLen()+"");
|
||||
productProcessBatchDet.setBatchDetCode(ProduceManagePublicMethod.creatBatchDetCode(date, currentProductProcess.getId(), currentProductProcess.getBatchCode(), productProcessBatchDet.getVolumeNum()));
|
||||
productProcessBatchDet.setShrinkage((null==productProcessBatchDet.getDetectionLen() || productProcessBatchDet.getDetectionLen()==0)?"0":(((null==productProcessBatchDet.getLen() || productProcessBatchDet.getLen()==0)?0:productProcessBatchDet.getLen())/productProcessBatchDet.getDetectionLen()+""));
|
||||
productProcessBatchDet.setCompanyId(currentUser.getCompanyId());
|
||||
addList.add(productProcessBatchDet);
|
||||
}
|
||||
}
|
||||
|
||||
//批量删除前端已移除的明细及其瑕疵
|
||||
|
||||
if(null!=batchDetVoListDB && batchDetVoListDB.size()!=0){
|
||||
//获取所有前端明细的id
|
||||
List<Integer> idsFront = batchDetListFront.stream().map(ProductProcessBatchDet::getId).collect(Collectors.toList());
|
||||
@ -111,11 +114,13 @@ public class ProductProcessBatchDetServiceImpl extends AbstractService<ProductPr
|
||||
if(null!=idsDB && idsDB.size()!=0) {
|
||||
List<Integer> deleteIdsDB = new ArrayList<Integer>(idsDB);
|
||||
deleteIdsDB.removeAll(idsFront);
|
||||
productProcessBatchDetService.deleteByIdsList(deleteIdsDB);
|
||||
ProductBatchDetectParams batchDetectParams = new ProductBatchDetectParams();
|
||||
batchDetectParams.setBatchDetIdList(deleteIdsDB);
|
||||
batchDetectParams.setCompanyId(currentProductProcess.getCompanyId());
|
||||
productBatchDetectService.deleteByBatchDet(batchDetectParams);
|
||||
if(deleteIdsDB.size()!=0) {
|
||||
productProcessBatchDetService.deleteByIdsList(deleteIdsDB);
|
||||
ProductBatchDetectParams batchDetectParams = new ProductBatchDetectParams();
|
||||
batchDetectParams.setBatchDetIdList(deleteIdsDB);
|
||||
batchDetectParams.setCompanyId(currentProductProcess.getCompanyId());
|
||||
productBatchDetectService.deleteByBatchDet(batchDetectParams);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user