|
|
@@ -2,6 +2,7 @@ package com.usoftchina.saas.storage.service.impl;
|
|
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
+import com.usoftchina.saas.base.Result;
|
|
|
import com.usoftchina.saas.base.service.CommonBaseServiceImpl;
|
|
|
import com.usoftchina.saas.commons.api.CommonService;
|
|
|
import com.usoftchina.saas.commons.api.MaxnumberService;
|
|
|
@@ -295,8 +296,7 @@ public class MakeServiceImpl extends CommonBaseServiceImpl<MakeMapper, Make> imp
|
|
|
String ma_statuscode = make.getMa_statuscode();
|
|
|
if(StringUtils.isEmpty(ma_statuscode)||(!StringUtils.isEmpty(ma_statuscode)&&!ma_statuscode.equals(Status.UNAUDITED.name()))){
|
|
|
throw new BizException(BizExceptionCode.BIZ_AUDITED);
|
|
|
- };
|
|
|
-
|
|
|
+ }
|
|
|
//2.校验库存是否足够
|
|
|
validStorage(makeListDTO);
|
|
|
//3.生成 完工入库单和领料单 并 过账
|
|
|
@@ -347,12 +347,14 @@ public class MakeServiceImpl extends CommonBaseServiceImpl<MakeMapper, Make> imp
|
|
|
* 2.过账
|
|
|
* @param makeListDTO
|
|
|
*/
|
|
|
+
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void generateProdIO(MakeListDTO makeListDTO) {
|
|
|
Make make = makeListDTO.getMain();
|
|
|
Long ma_id = make.getId();
|
|
|
List<MakeMaterial> items = makeListDTO.getItems();
|
|
|
-
|
|
|
+ Result res = null;
|
|
|
+ Object result = null;
|
|
|
if ("组装".equals(make.getMa_type())){
|
|
|
/** 1.生产领料单 **/
|
|
|
//a.主表
|
|
|
@@ -361,7 +363,6 @@ public class MakeServiceImpl extends CommonBaseServiceImpl<MakeMapper, Make> imp
|
|
|
String code = maxnumberService.getMaxnumber("MakeOut", true).getData();
|
|
|
prodInOut.setPi_inoutno(code);
|
|
|
prodInOut.setPi_date(new Date()); //出入库日期
|
|
|
-// prodInOut.setPi_recordmanid(BaseContextHolder.getUserId()); //录入人ID
|
|
|
prodInOut.setPi_recorddate(new Date()); //录入日期
|
|
|
prodInOut.setPi_auditdate(new Date()); //审核日期
|
|
|
prodInOut.setPi_auditman(""); //审核人
|
|
|
@@ -399,7 +400,6 @@ public class MakeServiceImpl extends CommonBaseServiceImpl<MakeMapper, Make> imp
|
|
|
prodIODetailList.add(prodIODetail);
|
|
|
}
|
|
|
prodIODetailMapper.batchInsert(prodIODetailList);
|
|
|
-
|
|
|
//c.领料单过账
|
|
|
Map<String, Object> map = new HashMap<String, Object>();
|
|
|
map.put("inoutNo", code);
|
|
|
@@ -407,14 +407,14 @@ public class MakeServiceImpl extends CommonBaseServiceImpl<MakeMapper, Make> imp
|
|
|
map.put("commitid", BaseContextHolder.getUserId());
|
|
|
map.put("companyId", BaseContextHolder.getCompanyId());
|
|
|
map.put("result", null);
|
|
|
- prodInOutMapper.post(map);
|
|
|
- if (!StringUtils.isEmpty(map.get("result"))){
|
|
|
- throw new BizException(76201, map.get("result").toString());
|
|
|
+ res = warehouseApi.post(map);
|
|
|
+ result = res.getData();
|
|
|
+ if (!StringUtils.isEmpty(result)){
|
|
|
+ unPostPicking(make);
|
|
|
+ throw new BizException(76201, result.toString());
|
|
|
}
|
|
|
-
|
|
|
//重新获取更新后的工单
|
|
|
make = getMapper().selectByPrimaryKey(ma_id);
|
|
|
-
|
|
|
/** 2.完工入库单 **/
|
|
|
//a.主表
|
|
|
prodInOut = new ProdInOut();
|
|
|
@@ -422,7 +422,6 @@ public class MakeServiceImpl extends CommonBaseServiceImpl<MakeMapper, Make> imp
|
|
|
code = maxnumberService.getMaxnumber("MakeIn", true).getData();
|
|
|
prodInOut.setPi_inoutno(code);
|
|
|
prodInOut.setPi_date(new Date()); //出入库日期
|
|
|
-// prodInOut.setPi_recordmanid(BaseContextHolder.getUserId()); //录入人ID
|
|
|
prodInOut.setPi_recorddate(new Date()); //录入日期
|
|
|
prodInOut.setPi_auditdate(new Date()); //审核日期
|
|
|
prodInOut.setPi_auditman(""); //审核人
|
|
|
@@ -455,15 +454,17 @@ public class MakeServiceImpl extends CommonBaseServiceImpl<MakeMapper, Make> imp
|
|
|
prodIODetail.setCompanyId(BaseContextHolder.getCompanyId()); //公司ID
|
|
|
prodIODetail.setPd_status(0); //单据状态
|
|
|
prodIODetailMapper.insertSelective(prodIODetail);
|
|
|
-
|
|
|
map.put("inoutNo", code);
|
|
|
map.put("class", "完工入库单");
|
|
|
map.put("commitid", BaseContextHolder.getUserId());
|
|
|
map.put("companyId", BaseContextHolder.getCompanyId());
|
|
|
map.put("result", null);
|
|
|
- prodInOutMapper.post(map);
|
|
|
- if (!StringUtils.isEmpty(map.get("result"))){
|
|
|
- throw new BizException(76201, map.get("result").toString());
|
|
|
+ res = warehouseApi.post(map);
|
|
|
+ result = res.getData();
|
|
|
+ if (!StringUtils.isEmpty(result)){
|
|
|
+ unPostPicking(make);
|
|
|
+ unPostMakeIn(make);
|
|
|
+ throw new BizException(76201, result.toString());
|
|
|
}
|
|
|
}else if ("拆件".equals(make.getMa_type())){
|
|
|
/** 1.拆件领料单 **/
|
|
|
@@ -473,8 +474,6 @@ public class MakeServiceImpl extends CommonBaseServiceImpl<MakeMapper, Make> imp
|
|
|
String code = maxnumberService.getMaxnumber("MakeOut", true).getData();
|
|
|
prodInOut.setPi_inoutno(code);
|
|
|
prodInOut.setPi_date(new Date()); //出入库日期
|
|
|
- //prodInOut.setPi_total(make.getMa_price());
|
|
|
-// prodInOut.setPi_recordmanid(BaseContextHolder.getUserId()); //录入人ID
|
|
|
prodInOut.setPi_recorddate(new Date()); //录入日期
|
|
|
prodInOut.setPi_auditdate(new Date()); //审核日期
|
|
|
prodInOut.setPi_auditman(""); //审核人
|
|
|
@@ -514,9 +513,11 @@ public class MakeServiceImpl extends CommonBaseServiceImpl<MakeMapper, Make> imp
|
|
|
map.put("commitid", BaseContextHolder.getUserId());
|
|
|
map.put("companyId", BaseContextHolder.getCompanyId());
|
|
|
map.put("result", null);
|
|
|
- prodInOutMapper.post(map);
|
|
|
- if (!StringUtils.isEmpty(map.get("result"))){
|
|
|
- throw new BizException(76201, map.get("result").toString());
|
|
|
+ res = warehouseApi.post(map);
|
|
|
+ result = res.getData();
|
|
|
+ if (!StringUtils.isEmpty(result)){
|
|
|
+ unPostPicking(make);
|
|
|
+ throw new BizException(76201, result.toString());
|
|
|
}
|
|
|
|
|
|
//重新获取更新后的工单
|
|
|
@@ -533,7 +534,6 @@ public class MakeServiceImpl extends CommonBaseServiceImpl<MakeMapper, Make> imp
|
|
|
code = maxnumberService.getMaxnumber("MakeIn", true).getData();
|
|
|
prodInOut.setPi_inoutno(code);
|
|
|
prodInOut.setPi_date(new Date()); //出入库日期
|
|
|
-// prodInOut.setPi_recordmanid(BaseContextHolder.getUserId()); //录入人ID
|
|
|
prodInOut.setPi_recorddate(new Date()); //录入日期
|
|
|
prodInOut.setPi_auditdate(new Date()); //审核日期
|
|
|
prodInOut.setPi_auditman(""); //审核人
|
|
|
@@ -578,9 +578,12 @@ public class MakeServiceImpl extends CommonBaseServiceImpl<MakeMapper, Make> imp
|
|
|
map.put("commitid", BaseContextHolder.getUserId());
|
|
|
map.put("companyId", BaseContextHolder.getCompanyId());
|
|
|
map.put("result", null);
|
|
|
- prodInOutMapper.post(map);
|
|
|
- if (!StringUtils.isEmpty(map.get("result"))){
|
|
|
- throw new BizException(76202, map.get("result").toString());
|
|
|
+ res = warehouseApi.post(map);
|
|
|
+ result = res.getData();
|
|
|
+ if (!StringUtils.isEmpty(result)){
|
|
|
+ unPostPicking(make);
|
|
|
+ unPostMakeIn(make);
|
|
|
+ throw new BizException(76202,result.toString());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -688,54 +691,93 @@ public class MakeServiceImpl extends CommonBaseServiceImpl<MakeMapper, Make> imp
|
|
|
* 2.反过账
|
|
|
* @param make
|
|
|
*/
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
public void selectProdIO(Make make) {
|
|
|
+ unPostMakeIn(make);
|
|
|
+ unPostPicking(make);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除,反审核完工入库单
|
|
|
+ * @param make
|
|
|
+ */
|
|
|
+ @Transactional
|
|
|
+ public void unPostMakeIn(Make make){
|
|
|
String code = make.getMa_code();
|
|
|
String type = make.getMa_type();
|
|
|
- String outCode="";
|
|
|
Long companyId = BaseContextHolder.getCompanyId();
|
|
|
- String inCode = getMapper().selectMakeInOutCode(code, companyId, "完工入库单");
|
|
|
- if ("拆件".equals(type)){
|
|
|
- outCode = getMapper().selectMakeInOutCode(code, companyId, "拆件领料单");
|
|
|
- }else if ("组装".equals(type)){
|
|
|
- outCode = getMapper().selectMakeInOutCode(code, companyId, "生产领料单");
|
|
|
- }
|
|
|
- Map<String, Object> map = new HashMap<String, Object>();
|
|
|
- map.put("inoutNo", inCode);
|
|
|
- map.put("class", "完工入库单");
|
|
|
- map.put("commitid", BaseContextHolder.getUserId());
|
|
|
- map.put("companyId", companyId);
|
|
|
- map.put("result", null);
|
|
|
- //完工入库单反过账
|
|
|
- prodInOutMapper.unPost(map);
|
|
|
- if(!StringUtils.isEmpty(map.get("result"))){
|
|
|
- throw new BizException(76203, map.get("result").toString());
|
|
|
+ String inCode="";
|
|
|
+ ProdInOut prodInOut = null;
|
|
|
+ prodInOut = getMapper().selectMakeInOutCode(code, companyId, "完工入库单");
|
|
|
+ if (!StringUtils.isEmpty(prodInOut)){
|
|
|
+ String status = prodInOut.getPi_statuscode();
|
|
|
+ inCode = prodInOut.getPi_inoutno();
|
|
|
+ if ("AUDITED".equals(status)){
|
|
|
+ Map<String, Object> map = new HashMap<String, Object>();
|
|
|
+ map.put("inoutNo", inCode);
|
|
|
+ map.put("class", "完工入库单");
|
|
|
+ map.put("commitid", BaseContextHolder.getUserId());
|
|
|
+ map.put("companyId", companyId);
|
|
|
+ map.put("result", null);
|
|
|
+ //完工入库单反过账
|
|
|
+ Result res = warehouseApi.unPost(map);
|
|
|
+ Object result = res.getData();
|
|
|
+ if (!StringUtils.isEmpty(result)){
|
|
|
+ throw new BizException(76201, result.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ prodIODetailMapper.deleteByInOutNo(inCode, "完工入库单", BaseContextHolder.getCompanyId());
|
|
|
+ prodInOutMapper.deleteByInOutNo(inCode, "完工入库单", BaseContextHolder.getCompanyId());
|
|
|
}
|
|
|
- prodIODetailMapper.deleteByInOutNo(inCode, "完工入库单", BaseContextHolder.getCompanyId());
|
|
|
- prodInOutMapper.deleteByInOutNo(inCode, "完工入库单", BaseContextHolder.getCompanyId());
|
|
|
-
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * 删除,反审核领料单
|
|
|
+ * @param make
|
|
|
+ */
|
|
|
+ @Transactional
|
|
|
+ public void unPostPicking(Make make){
|
|
|
+ String code = make.getMa_code();
|
|
|
+ String type = make.getMa_type();
|
|
|
+ Long companyId = BaseContextHolder.getCompanyId();
|
|
|
+ String outCode="";
|
|
|
+ ProdInOut prodInOut = null;
|
|
|
if ("拆件".equals(type)){
|
|
|
- map.put("class", "拆件领料单");
|
|
|
+ prodInOut = getMapper().selectMakeInOutCode(code, companyId, "拆件领料单");
|
|
|
}else if ("组装".equals(type)){
|
|
|
- map.put("class", "生产领料单");
|
|
|
- }
|
|
|
- map.put("inoutNo", outCode);
|
|
|
- map.put("result", null);
|
|
|
- //生产领料单/拆件领料反过账
|
|
|
- prodInOutMapper.unPost(map);
|
|
|
- if(!StringUtils.isEmpty(map.get("result"))){
|
|
|
- throw new BizException(76204, map.get("result").toString());
|
|
|
+ prodInOut = getMapper().selectMakeInOutCode(code, companyId, "生产领料单");
|
|
|
}
|
|
|
- if ("拆件".equals(type)){
|
|
|
- prodIODetailMapper.deleteByInOutNo(outCode, "拆件领料单", BaseContextHolder.getCompanyId());
|
|
|
- prodInOutMapper.deleteByInOutNo(outCode, "拆件领料单", BaseContextHolder.getCompanyId());
|
|
|
- }else if ("组装".equals(type)){
|
|
|
- prodIODetailMapper.deleteByInOutNo(outCode, "生产领料单", BaseContextHolder.getCompanyId());
|
|
|
- prodInOutMapper.deleteByInOutNo(outCode, "生产领料单", BaseContextHolder.getCompanyId());
|
|
|
+ if (!StringUtils.isEmpty(prodInOut)){
|
|
|
+ String status = prodInOut.getPi_statuscode();
|
|
|
+ outCode = prodInOut.getPi_inoutno();
|
|
|
+ if ("AUDITED".equals(status)) {
|
|
|
+ Map<String, Object> map = new HashMap<String, Object>();
|
|
|
+ map.put("inoutNo", outCode);
|
|
|
+ if ("拆件".equals(type)){
|
|
|
+ map.put("class", "拆件领料单");
|
|
|
+ }else if ("组装".equals(type)){
|
|
|
+ map.put("class", "生产领料单");
|
|
|
+ }
|
|
|
+ map.put("commitid", BaseContextHolder.getUserId());
|
|
|
+ map.put("companyId", companyId);
|
|
|
+ map.put("result", null);
|
|
|
+ //生产领料单/拆件领料反过账
|
|
|
+ Result res = warehouseApi.unPost(map);
|
|
|
+ Object result = res.getData();
|
|
|
+ if (!StringUtils.isEmpty(result)){
|
|
|
+ throw new BizException(76201, result.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ("拆件".equals(type)){
|
|
|
+ prodIODetailMapper.deleteByInOutNo(outCode, "拆件领料单", BaseContextHolder.getCompanyId());
|
|
|
+ prodInOutMapper.deleteByInOutNo(outCode, "拆件领料单", BaseContextHolder.getCompanyId());
|
|
|
+ }else if ("组装".equals(type)){
|
|
|
+ prodIODetailMapper.deleteByInOutNo(outCode, "生产领料单", BaseContextHolder.getCompanyId());
|
|
|
+ prodInOutMapper.deleteByInOutNo(outCode, "生产领料单", BaseContextHolder.getCompanyId());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 构造日记记录对象
|
|
|
* @param id
|