加工单物料批量更新

This commit is contained in:
hy2250089 2020-01-16 09:32:18 +08:00
parent 297cbaa591
commit ae7bb481cc
8 changed files with 52 additions and 48 deletions

View File

@ -10,4 +10,6 @@ import java.util.List;
public interface ProcessMaterialsMapper extends Mapper<ProcessMaterials> { public interface ProcessMaterialsMapper extends Mapper<ProcessMaterials> {
List<ProcessMaterialsVo> findProcMatVoListByProcess(MtAloneProcessParams params); List<ProcessMaterialsVo> findProcMatVoListByProcess(MtAloneProcessParams params);
void updateList(List<ProcessMaterials> procMatList);
} }

View File

@ -55,4 +55,15 @@
</where> ORDER BY procmaterials.id </where> ORDER BY procmaterials.id
</select> </select>
<update id="updateList" parameterType="java.util.List">
<foreach collection="list" index="index" item="item" open="" separator=";" close="">
UPDATE mt_alone_process_materials
<set>
dosage = #{item.dosage},
update_time = #{item.updateTime}
</set>
WHERE id = #{item.id} AND company_id = #{item.companyId}
</foreach>
</update>
</mapper> </mapper>

View File

@ -14,4 +14,5 @@ import java.util.List;
public interface ProcessMaterialsService extends Service<ProcessMaterials, Integer> { public interface ProcessMaterialsService extends Service<ProcessMaterials, Integer> {
List<ProcessMaterialsVo> findProcMatVoListByProcess(MtAloneProcessParams params); List<ProcessMaterialsVo> findProcMatVoListByProcess(MtAloneProcessParams params);
void updateList(List<ProcessMaterials> procMatList);
} }

View File

@ -69,7 +69,7 @@ public class MaterialsInfoServiceImpl extends AbstractService<MaterialsInfo, Int
ids.add(materialsOutgoingLogVo.getId()); ids.add(materialsOutgoingLogVo.getId());
} }
if((null!=ids) && (ids.size()!=0)) { if(null!=ids && ids.size()!=0) {
HashMap outgoingParam = new HashMap(); HashMap outgoingParam = new HashMap();
outgoingParam.put("companyId", currentUser.getCompanyId()); outgoingParam.put("companyId", currentUser.getCompanyId());
outgoingParam.put("ids", ids); outgoingParam.put("ids", ids);

View File

@ -42,7 +42,7 @@ public class MtAloneProcessServiceImpl extends AbstractService<MtAloneProcess, I
List<ProcessBom> processBomList = processBomService.findListByProductBom(params); List<ProcessBom> processBomList = processBomService.findListByProductBom(params);
List<MtAloneProcess> processList = new ArrayList<MtAloneProcess>(); List<MtAloneProcess> processList = new ArrayList<MtAloneProcess>();
if(processBomList!=null && processBomList.size()!=0){ if (processBomList != null && processBomList.size() != 0) {
//循环工序bom给工序初步赋值先不保存 //循环工序bom给工序初步赋值先不保存
for (ProcessBom processBom : processBomList) { for (ProcessBom processBom : processBomList) {
MtAloneProcess process = new MtAloneProcess(); MtAloneProcess process = new MtAloneProcess();
@ -66,9 +66,9 @@ public class MtAloneProcessServiceImpl extends AbstractService<MtAloneProcess, I
//根据工序id查询物料信息 //根据工序id查询物料信息
List<ProcessMaterialsVo> procMatVoList = processMaterialsService.findProcMatVoListByProcess(params); List<ProcessMaterialsVo> procMatVoList = processMaterialsService.findProcMatVoListByProcess(params);
ProcessHo processHo = new ProcessHo(); ProcessHo processHo = new ProcessHo();
if(null != processVo){ if (null != processVo) {
System.out.println("----------"+processVo.getId()); System.out.println("----------" + processVo.getId());
System.out.println("----------"+processVo.getProcessName()); System.out.println("----------" + processVo.getProcessName());
BeanUtils.copyProperties(processVo, processHo); BeanUtils.copyProperties(processVo, processHo);
processHo.setProcessMaterialsVoList(procMatVoList); processHo.setProcessMaterialsVoList(procMatVoList);
} }
@ -98,27 +98,16 @@ public class MtAloneProcessServiceImpl extends AbstractService<MtAloneProcess, I
BeanUtils.copyProperties(processHo, process); BeanUtils.copyProperties(processHo, process);
this.update(process); this.update(process);
//if(null != processHo.getProcessMaterialsVoList()) { List<ProcessMaterialsVo> procMatVoList = processHo.getProcessMaterialsVoList();
// List<ProcessMaterialsVo> procMatVoList = processHo.getProcessMaterialsVoList(); if (null != procMatVoList && procMatVoList.size() != 0) {
// List<ProcessMaterials> procMatList = new ArrayList<ProcessMaterials>(procMatVoList.size()); List<ProcessMaterials> procMatList = new ArrayList<ProcessMaterials>(procMatVoList.size());
// for (ProcessMaterialsVo processMaterialsVo : procMatVoList){ for (ProcessMaterialsVo processMaterialsVo : procMatVoList) {
// ProcessMaterials processMaterials = new ProcessMaterials();
// processMaterialsVo.setUpdateTime(date);
// BeanUtils.copyProperties(processMaterialsVo, processMaterials);
// procMatList.add(processMaterials);
// }
// processMaterialsService.update(procMatList);
//}
if(null != processHo.getProcessMaterialsVoList()) {
List<ProcessMaterialsVo> procMatVoList = processHo.getProcessMaterialsVoList();
for (ProcessMaterialsVo processMaterialsVo : procMatVoList){
ProcessMaterials processMaterials = new ProcessMaterials(); ProcessMaterials processMaterials = new ProcessMaterials();
processMaterialsVo.setUpdateTime(date); processMaterialsVo.setUpdateTime(date);
BeanUtils.copyProperties(processMaterialsVo, processMaterials); BeanUtils.copyProperties(processMaterialsVo, processMaterials);
processMaterialsService.update(processMaterials); procMatList.add(processMaterials);
} }
processMaterialsService.updateList(procMatList);
} }
} }

View File

@ -28,9 +28,9 @@ public class ProcessMaterialsServiceImpl extends AbstractService<ProcessMaterial
return processMaterialsMapper.findProcMatVoListByProcess(params); return processMaterialsMapper.findProcMatVoListByProcess(params);
} }
@Override
public void updateList(List<ProcessMaterials> procMatList) {
processMaterialsMapper.updateList(procMatList);
}
//@Override
//public List<ProcessMaterials> findList(ProcessMaterialsParams params) {
// return processMaterialsMapper.findList(params);
//}
} }

View File

@ -60,7 +60,7 @@ public class ProductProcessServiceImpl extends AbstractService<ProductProcess, I
productProcess.setVersion("1.1"); productProcess.setVersion("1.1");
productProcess.setStatus(ProduceManageConstant.STATUS_AVAILABLE); productProcess.setStatus(ProduceManageConstant.STATUS_AVAILABLE);
productProcess.setWorkOrderCode(ProduceManagePublicMethod.creatUniqueCode("PCJGD")); productProcess.setWorkOrderCode(ProduceManagePublicMethod.creatUniqueCode("PCJGD"));
productProcess.setShrinkage((productProcess.getDetectionLen()/productProcess.getLen())*100+"%"); productProcess.setShrinkage((productProcess.getDetectionLen() / productProcess.getLen()) * 100 + "%");
productProcess.setReviewStatus(ProduceManageConstant.REVIEW_STATUS_FORREVIEW); productProcess.setReviewStatus(ProduceManageConstant.REVIEW_STATUS_FORREVIEW);
productProcess.setCompanyId(currentUser.getCompanyId()); productProcess.setCompanyId(currentUser.getCompanyId());
productProcessMapper.insert(productProcess); productProcessMapper.insert(productProcess);
@ -77,14 +77,14 @@ public class ProductProcessServiceImpl extends AbstractService<ProductProcess, I
productProcess.setVersion("1.1"); productProcess.setVersion("1.1");
productProcess.setStatus(ProduceManageConstant.STATUS_AVAILABLE); productProcess.setStatus(ProduceManageConstant.STATUS_AVAILABLE);
productProcess.setWorkOrderCode(ProduceManagePublicMethod.creatUniqueCode("PCJGD")); productProcess.setWorkOrderCode(ProduceManagePublicMethod.creatUniqueCode("PCJGD"));
productProcess.setShrinkage((productProcess.getDetectionLen()/productProcess.getLen())*100+"%"); productProcess.setShrinkage((productProcess.getDetectionLen() / productProcess.getLen()) * 100 + "%");
productProcess.setReviewStatus(ProduceManageConstant.REVIEW_STATUS_FORREVIEW); productProcess.setReviewStatus(ProduceManageConstant.REVIEW_STATUS_FORREVIEW);
productProcess.setCompanyId(currentUser.getCompanyId()); productProcess.setCompanyId(currentUser.getCompanyId());
productProcessMapper.insert(productProcess); productProcessMapper.insert(productProcess);
//保存由前端获取的工序信息 //保存由前端获取的工序信息
List<MtAloneProcessVo> processVoList = productAndProcess.getProcessVoList(); List<MtAloneProcessVo> processVoList = productAndProcess.getProcessVoList();
if(null != processVoList) { if (null != processVoList) {
List<MtAloneProcess> processList = new ArrayList<MtAloneProcess>(processVoList.size()); List<MtAloneProcess> processList = new ArrayList<MtAloneProcess>(processVoList.size());
for (MtAloneProcess processVo : processVoList) { for (MtAloneProcess processVo : processVoList) {
MtAloneProcess process = new MtAloneProcess(); MtAloneProcess process = new MtAloneProcess();
@ -104,7 +104,7 @@ public class ProductProcessServiceImpl extends AbstractService<ProductProcess, I
List<MtAloneProcessVo> tempProcessVoList = processService.findProcessVoListByProductProcess(params); List<MtAloneProcessVo> tempProcessVoList = processService.findProcessVoListByProductProcess(params);
ProductProcessHo productProcessHo = new ProductProcessHo(); ProductProcessHo productProcessHo = new ProductProcessHo();
if(null != productProcess) { if (null != productProcess) {
BeanUtils.copyProperties(productProcess, productProcessHo); BeanUtils.copyProperties(productProcess, productProcessHo);
if (null != tempProcessVoList) { if (null != tempProcessVoList) {
List<ProcessHo> processHoList = new ArrayList<ProcessHo>(tempProcessVoList.size()); List<ProcessHo> processHoList = new ArrayList<ProcessHo>(tempProcessVoList.size());
@ -127,7 +127,7 @@ public class ProductProcessServiceImpl extends AbstractService<ProductProcess, I
//批次产品加工单初步赋值关联bom //批次产品加工单初步赋值关联bom
ProductProcessBom productProcessBom = productProcessBomService.selectByProdProcBom(params); ProductProcessBom productProcessBom = productProcessBomService.selectByProdProcBom(params);
if(null != productProcessBom) { if (null != productProcessBom) {
productProcessHo.setProductBomId(productProcessBom.getId()); productProcessHo.setProductBomId(productProcessBom.getId());
productProcessHo.setProductProcessBomName(productProcessBom.getProductProcessName()); productProcessHo.setProductProcessBomName(productProcessBom.getProductProcessName());
//工序初步赋值关联bom //工序初步赋值关联bom
@ -189,18 +189,15 @@ public class ProductProcessServiceImpl extends AbstractService<ProductProcess, I
productProcess.setVersion("1.1"); productProcess.setVersion("1.1");
productProcess.setStatus(ProduceManageConstant.STATUS_AVAILABLE); productProcess.setStatus(ProduceManageConstant.STATUS_AVAILABLE);
productProcess.setWorkOrderCode(ProduceManagePublicMethod.creatUniqueCode("PCJGD")); productProcess.setWorkOrderCode(ProduceManagePublicMethod.creatUniqueCode("PCJGD"));
productProcess.setShrinkage((productProcess.getDetectionLen()/productProcess.getLen())*100+"%"); productProcess.setShrinkage((productProcess.getDetectionLen() / productProcess.getLen()) * 100 + "%");
productProcess.setReviewStatus(ProduceManageConstant.REVIEW_STATUS_FORREVIEW); productProcess.setReviewStatus(ProduceManageConstant.REVIEW_STATUS_FORREVIEW);
productProcess.setCompanyId(currentUser.getCompanyId()); productProcess.setCompanyId(currentUser.getCompanyId());
productProcessMapper.insert(productProcess); productProcessMapper.insert(productProcess);
//保存工序和物料信息避免循环操作数据库 //保存工序和物料信息避免循环操作数据库
List<ProcessHo> processHoList = productProcessHo.getProcessHoList(); List<ProcessHo> processHoList = productProcessHo.getProcessHoList();
List<MtAloneProcess> processList; if (null != processHoList && processHoList.size() != 0) {
List<ProcessMaterials> processMaterialsList; List<MtAloneProcess> processList = new ArrayList<MtAloneProcess>(processHoList.size());
if((null!=processHoList) && (0!=processHoList.size())) {
processList = new ArrayList<MtAloneProcess>(processHoList.size());
processMaterialsList = new ArrayList<ProcessMaterials>();
for (ProcessHo processHo : processHoList) { for (ProcessHo processHo : processHoList) {
MtAloneProcess process = new MtAloneProcess(); MtAloneProcess process = new MtAloneProcess();
BeanUtils.copyProperties(processHo, process); BeanUtils.copyProperties(processHo, process);
@ -210,12 +207,18 @@ public class ProductProcessServiceImpl extends AbstractService<ProductProcess, I
process.setVersion("1.1"); process.setVersion("1.1");
process.setStatus(ProduceManageConstant.STATUS_AVAILABLE); process.setStatus(ProduceManageConstant.STATUS_AVAILABLE);
process.setProductProcessId(productProcess.getId()); process.setProductProcessId(productProcess.getId());
process.setCode(ProduceManagePublicMethod.creatUniqueCode("GX")); process.setCode(ProduceManagePublicMethod.creatUniqueCode("JGGX"));
process.setCompanyId(currentUser.getCompanyId()); process.setCompanyId(currentUser.getCompanyId());
processList.add(process); processList.add(process);
}
processService.save(processList);
List<ProcessMaterials> processMaterialsList = new ArrayList<ProcessMaterials>();
for (int i = 0; i < processHoList.size(); i++) {
ProcessHo processHo = processHoList.get(i);
MtAloneProcess process = processList.get(i);
List<ProcessMaterialsVo> processMaterialsVoList = processHo.getProcessMaterialsVoList(); List<ProcessMaterialsVo> processMaterialsVoList = processHo.getProcessMaterialsVoList();
if((null!=processMaterialsVoList) && (0!=processMaterialsVoList.size())){ if (null != processMaterialsVoList && processMaterialsVoList.size() != 0) {
for (ProcessMaterialsVo processMaterialsVo : processMaterialsVoList) { for (ProcessMaterialsVo processMaterialsVo : processMaterialsVoList) {
ProcessMaterials processMaterials = new ProcessMaterials(); ProcessMaterials processMaterials = new ProcessMaterials();
BeanUtils.copyProperties(processMaterialsVo, processMaterials); BeanUtils.copyProperties(processMaterialsVo, processMaterials);
@ -225,20 +228,18 @@ public class ProductProcessServiceImpl extends AbstractService<ProductProcess, I
processMaterials.setVersion("1.1"); processMaterials.setVersion("1.1");
processMaterials.setStatus(ProduceManageConstant.STATUS_AVAILABLE); processMaterials.setStatus(ProduceManageConstant.STATUS_AVAILABLE);
processMaterials.setProcessId(process.getId()); processMaterials.setProcessId(process.getId());
processMaterials.setCode(ProduceManagePublicMethod.creatUniqueCode("SCWL")); processMaterials.setCode(ProduceManagePublicMethod.creatUniqueCode("JGWL"));
processMaterials.setDosage(productProcess.getPiNum()*processMaterials.getDosage()); processMaterials.setDosage(productProcess.getPiNum() * processMaterials.getDosage());
processMaterials.setCompanyId(currentUser.getCompanyId()); processMaterials.setCompanyId(currentUser.getCompanyId());
processMaterialsList.add(processMaterials); processMaterialsList.add(processMaterials);
} }
} }
} }
processService.save(processList); if (processMaterialsList.size() != 0)
if (0 != processMaterialsList.size())
processMaterialsService.save(processMaterialsList); processMaterialsService.save(processMaterialsList);
} }
} }
} }

View File

@ -124,12 +124,12 @@ public class MaterialsInfoController {
@ApiOperation(value = "获取某种物料详细信息", notes = "获取某种物料详细信息") @ApiOperation(value = "获取某种物料详细信息", notes = "获取某种物料详细信息")
@GetMapping("/detail") @GetMapping("/detail")
public Result detail(MaterialsInfoParams params, @ApiIgnore @User CurrentUser currentUser) { public Result detail(MaterialsInfoParams params, @ApiIgnore @User CurrentUser currentUser) {
//if(currentUser==null){ if(currentUser==null){
// return ResultGenerator.genFailResult(CommonCode.SERVICE_ERROR,"未登录错误",null ); return ResultGenerator.genFailResult(CommonCode.SERVICE_ERROR,"未登录错误",null );
//} }
StringUtil.trimObjectStringProperties(params); StringUtil.trimObjectStringProperties(params);
params.setCompanyId(1); params.setCompanyId(currentUser.getCompanyId());
MaterialsInfoDto materialsInfoDto = materialsInfoService.findDetailById(params); MaterialsInfoDto materialsInfoDto = materialsInfoService.findDetailById(params);
return ResultGenerator.genSuccessResult(materialsInfoDto); return ResultGenerator.genSuccessResult(materialsInfoDto);
} }