明细批量修改接口修改

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.ProductBatchDetect;
import com.deer.wms.produce.manage.model.ProductBatchDetectParams; import com.deer.wms.produce.manage.model.ProductBatchDetectParams;
import com.deer.wms.project.seed.core.mapper.Mapper; import com.deer.wms.project.seed.core.mapper.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;

View File

@ -54,11 +54,11 @@
<delete id="deleteByBatchDet" parameterType="com.deer.wms.produce.manage.model.ProductBatchDetectParams"> <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 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=")"> <foreach collection="batchDetIdList" item="item" open="(" separator="," close=")">
#{params.batchDetIdList[${item}]} #{item}
</foreach> </foreach>
<if test="companyId != null"> <if test="companyId != null">
AND company_id = #{params.companyId} AND company_id = #{companyId}
</if> ) </if> )
</delete> </delete>
</mapper> </mapper>

View File

@ -38,11 +38,11 @@
<delete id="deleteByBatchDet" parameterType="com.deer.wms.produce.manage.model.ProductBatchDetectParams"> <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 DELETE FROM mt_alone_product_batch_detect WHERE 1>2 OR ( batch_det_id IN
<foreach collection="params.batchDetIdList" item="item" open="(" separator="," close=")"> <foreach collection="batchDetIdList" item="item" open="(" separator="," close=")">
#{params.batchDetIdList[${item}]} #{item}
</foreach> </foreach>
<if test="companyId != null"> <if test="companyId != null">
AND company_id = #{params.companyId} AND company_id = #{companyId}
</if> ) </if> )
</delete> </delete>

View File

@ -99,7 +99,7 @@
</where> </where>
</select> </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 SELECT MAX(CAST(det.volume_num AS DECIMAL)) FROM mt_alone_product_process_batch_det det
<where> <where>
<if test="productProcessId != null"> <if test="productProcessId != null">

View File

@ -64,8 +64,9 @@ public class ProductProcessBatchDetServiceImpl extends AbstractService<ProductPr
ProductProcess currentProductProcess = productProcessService.findById(batchDetListAndProductProcess.getProductProcessId()); ProductProcess currentProductProcess = productProcessService.findById(batchDetListAndProductProcess.getProductProcessId());
//获取当前加工单下库表中所有的明细 //获取当前加工单下库表中所有的明细
List<ProductProcessBatchDetVo> batchDetVoListDB = productProcessBatchDetService.findListByProductProcess(productProcessParams); List<ProductProcessBatchDetVo> batchDetVoListDB = productProcessBatchDetService.findListByProductProcess(productProcessParams);
//设置加工单的总卷数与前端明细个数相同,并更新加工单信息
currentProductProcess.setPiNum(null==batchDetListFront?0:batchDetListFront.size()); //设置当前加工单的总卷数与前端明细个数相同,并更新加工单信息
currentProductProcess.setPiNum(null==batchDetListFront ? 0:batchDetListFront.size());
productProcessService.update(currentProductProcess); productProcessService.update(currentProductProcess);
Date date = new Date(); Date date = new Date();
@ -76,14 +77,15 @@ public class ProductProcessBatchDetServiceImpl extends AbstractService<ProductPr
/**原则从前端的明细list中判断先拿出有id的明细更新再插入没id的明细最后删除前端已移除的明细即库表中在前端找不到对应id的明细**/ /**原则从前端的明细list中判断先拿出有id的明细更新再插入没id的明细最后删除前端已移除的明细即库表中在前端找不到对应id的明细**/
if(null!=batchDetListFront && batchDetListFront.size()!=0){//如果前端有明细 if(null!=batchDetListFront && batchDetListFront.size()!=0){//如果前端有明细
//已有非新增明细放入一个list //存放库表已有非新增明细
List<ProductProcessBatchDet> updateList = new ArrayList<ProductProcessBatchDet>(); List<ProductProcessBatchDet> updateList = new ArrayList<ProductProcessBatchDet>();
//将新增明细放入一个list //存放新增明细
List<ProductProcessBatchDet> addList = new ArrayList<ProductProcessBatchDet>(); List<ProductProcessBatchDet> addList = new ArrayList<ProductProcessBatchDet>();
for (ProductProcessBatchDet productProcessBatchDet : batchDetListFront){ for (ProductProcessBatchDet productProcessBatchDet : batchDetListFront){
if(null!=productProcessBatchDet.getId()){//已有的明细非新增明细有id if(null!=productProcessBatchDet.getId()){//库表已有的明细非新增明细有id
productProcessBatchDet.setUpdateTime(date); 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); updateList.add(productProcessBatchDet);
}else{//新增明细没有id }else{//新增明细没有id
productProcessBatchDet.setCreateTime(date); productProcessBatchDet.setCreateTime(date);
@ -95,14 +97,15 @@ public class ProductProcessBatchDetServiceImpl extends AbstractService<ProductPr
productProcessBatchDet.setDeliveryCode(currentProductProcess.getDeliveryCode()); productProcessBatchDet.setDeliveryCode(currentProductProcess.getDeliveryCode());
productProcessBatchDet.setProductProcessId(currentProductProcess.getId()); productProcessBatchDet.setProductProcessId(currentProductProcess.getId());
productProcessBatchDet.setVolumeNum((maxVolumeNumDB++)+""); productProcessBatchDet.setVolumeNum((maxVolumeNumDB++)+"");
productProcessBatchDet.setBatchCode(ProduceManagePublicMethod.creatBatchDetCode(date, currentProductProcess.getId(), currentProductProcess.getBatchCode(), productProcessBatchDet.getVolumeNum())); productProcessBatchDet.setBatchDetCode(ProduceManagePublicMethod.creatBatchDetCode(date, currentProductProcess.getId(), currentProductProcess.getBatchCode(), productProcessBatchDet.getVolumeNum()));
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()+""));
productProcessBatchDet.setCompanyId(currentUser.getCompanyId()); productProcessBatchDet.setCompanyId(currentUser.getCompanyId());
addList.add(productProcessBatchDet); addList.add(productProcessBatchDet);
} }
} }
//批量删除前端已移除的明细及其瑕疵 //批量删除前端已移除的明细及其瑕疵
if(null!=batchDetVoListDB && batchDetVoListDB.size()!=0){ if(null!=batchDetVoListDB && batchDetVoListDB.size()!=0){
//获取所有前端明细的id //获取所有前端明细的id
List<Integer> idsFront = batchDetListFront.stream().map(ProductProcessBatchDet::getId).collect(Collectors.toList()); 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) { if(null!=idsDB && idsDB.size()!=0) {
List<Integer> deleteIdsDB = new ArrayList<Integer>(idsDB); List<Integer> deleteIdsDB = new ArrayList<Integer>(idsDB);
deleteIdsDB.removeAll(idsFront); deleteIdsDB.removeAll(idsFront);
productProcessBatchDetService.deleteByIdsList(deleteIdsDB); if(deleteIdsDB.size()!=0) {
ProductBatchDetectParams batchDetectParams = new ProductBatchDetectParams(); productProcessBatchDetService.deleteByIdsList(deleteIdsDB);
batchDetectParams.setBatchDetIdList(deleteIdsDB); ProductBatchDetectParams batchDetectParams = new ProductBatchDetectParams();
batchDetectParams.setCompanyId(currentProductProcess.getCompanyId()); batchDetectParams.setBatchDetIdList(deleteIdsDB);
productBatchDetectService.deleteByBatchDet(batchDetectParams); batchDetectParams.setCompanyId(currentProductProcess.getCompanyId());
productBatchDetectService.deleteByBatchDet(batchDetectParams);
}
} }
} }