明细批量修改接口修改

This commit is contained in:
hy2250089 2020-04-09 17:11:30 +08:00
parent 16f70ba4a4
commit b8bddc66bf
5 changed files with 26 additions and 20 deletions

View File

@ -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;

View File

@ -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>

View File

@ -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>

View File

@ -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">

View File

@ -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,6 +114,7 @@ public class ProductProcessBatchDetServiceImpl extends AbstractService<ProductPr
if(null!=idsDB && idsDB.size()!=0) {
List<Integer> deleteIdsDB = new ArrayList<Integer>(idsDB);
deleteIdsDB.removeAll(idsFront);
if(deleteIdsDB.size()!=0) {
productProcessBatchDetService.deleteByIdsList(deleteIdsDB);
ProductBatchDetectParams batchDetectParams = new ProductBatchDetectParams();
batchDetectParams.setBatchDetIdList(deleteIdsDB);
@ -118,6 +122,7 @@ public class ProductProcessBatchDetServiceImpl extends AbstractService<ProductPr
productBatchDetectService.deleteByBatchDet(batchDetectParams);
}
}
}
if(updateList.size()!=0)//批量更新对应的明细
productProcessBatchDetService.updateList(updateList);