|
|
@@ -28,6 +28,7 @@ import com.usoftchina.saas.storage.po.ProdInOut;
|
|
|
import com.usoftchina.saas.storage.service.MakeService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Isolation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
@@ -87,7 +88,8 @@ public class MakeServiceImpl extends CommonBaseServiceImpl<MakeMapper, Make> imp
|
|
|
String code = pushMaxnubmer(make.getMa_code(), make.getId());
|
|
|
make.setMa_code(code);
|
|
|
make.setCompanyId(BaseContextHolder.getCompanyId());
|
|
|
- make.setCreateTime(new Date());
|
|
|
+ //make.setCreateTime(new Date());
|
|
|
+ make.setMa_recorddate(make.getCreateTime());
|
|
|
make.setCreatorId(BaseContextHolder.getUserId());
|
|
|
|
|
|
getMapper().insertSelective(make);
|
|
|
@@ -164,7 +166,12 @@ public class MakeServiceImpl extends CommonBaseServiceImpl<MakeMapper, Make> imp
|
|
|
}
|
|
|
}else if ("拆件".equals(make.getMa_type())){
|
|
|
double qty = make.getMa_qty();
|
|
|
- double onHand = getMapper().getOnHand(make.getMa_prodcode(),make.getMa_whcode(),BaseContextHolder.getCompanyId());
|
|
|
+ double onHand = 0;
|
|
|
+ try {
|
|
|
+ onHand = getMapper().getOnHand(make.getMa_prodcode(), make.getMa_whcode(), BaseContextHolder.getCompanyId());
|
|
|
+ }catch (Exception e){
|
|
|
+ throw new BizException(79402, make.getMa_prodcode() + ":库存不足");
|
|
|
+ }
|
|
|
if(onHand < qty){
|
|
|
throw new BizException(79402, make.getMa_prodcode() + ":库存不足");
|
|
|
}
|
|
|
@@ -215,24 +222,36 @@ public class MakeServiceImpl extends CommonBaseServiceImpl<MakeMapper, Make> imp
|
|
|
|
|
|
@Override
|
|
|
public boolean delete(Long id) {
|
|
|
+ DocBaseDTO docBaseDTO = generateMsgObj(id, getMapper().selectByPrimaryKey(id).getMa_code());
|
|
|
getMapper().deleteByPrimaryKey(id);
|
|
|
makeMaterialMapper.deleteByFK(id, BaseContextHolder.getCompanyId());
|
|
|
+ //记录LOG
|
|
|
+ messageLogService.delete(docBaseDTO);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public boolean deleteDetail(Long id) {
|
|
|
- makeMaterialMapper.deleteByFK(id, BaseContextHolder.getCompanyId());
|
|
|
+ Long ma_id = makeMaterialMapper.selectByPrimaryKey(id).getMm_maid();
|
|
|
+ String code = getMapper().selectByPrimaryKey(ma_id).getMa_code();
|
|
|
+ makeMaterialMapper.deleteByPrimaryKey(id);
|
|
|
+ DocBaseDTO docBaseDTO = generateMsgObj(id, code);
|
|
|
+ //记录LOG
|
|
|
+ messageLogService.deleteDetail(docBaseDTO);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- @Transactional
|
|
|
- public DocBaseDTO audit(Long id) {
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public DocBaseDTO audit(MakeListDTO makeListDTO) {
|
|
|
//1.获取主从表数据
|
|
|
- Make make = getMapper().selectByPrimaryKey(id);
|
|
|
- List<MakeMaterial> items = makeMaterialMapper.selectByFK(id, BaseContextHolder.getCompanyId());
|
|
|
- MakeListDTO makeListDTO = new MakeListDTO(make, items);
|
|
|
+ Make make = makeListDTO.getMain();
|
|
|
+ List<MakeMaterial> items = makeListDTO.getItems();
|
|
|
+ //如果ID为0,先执行保存
|
|
|
+ if (makeListDTO.getMain().getId() == 0){
|
|
|
+ DocBaseDTO docBaseDTO = saveOrUpdate(makeListDTO);
|
|
|
+ make.setId(docBaseDTO.getId());
|
|
|
+ }
|
|
|
//2.校验库存是否足够
|
|
|
validStorage(makeListDTO);
|
|
|
//3.生成 完工入库单和领料单 并 过账
|
|
|
@@ -243,7 +262,8 @@ public class MakeServiceImpl extends CommonBaseServiceImpl<MakeMapper, Make> imp
|
|
|
make.setMa_statuscode(Status.AUDITED.name());
|
|
|
make.setUpdateTime(new Date());
|
|
|
make.setUpdaterId(BaseContextHolder.getUserId());
|
|
|
- DocBaseDTO docBaseDTO = generateMsgObj(id, make.getMa_code());
|
|
|
+ getMapper().updateByPrimaryKeySelective(make);
|
|
|
+ DocBaseDTO docBaseDTO = generateMsgObj(make.getId(), make.getMa_code());
|
|
|
//5.记录LOG
|
|
|
messageLogService.audit(docBaseDTO);
|
|
|
return docBaseDTO;
|
|
|
@@ -311,9 +331,9 @@ public class MakeServiceImpl extends CommonBaseServiceImpl<MakeMapper, Make> imp
|
|
|
map.put("commitid", BaseContextHolder.getUserId());
|
|
|
map.put("companyId", BaseContextHolder.getCompanyId());
|
|
|
map.put("result", null);
|
|
|
- Result result = warehouseApi.post(map);
|
|
|
- if (!StringUtils.isEmpty(result.getData())){
|
|
|
- throw new BizException(76201, result.getData().toString());
|
|
|
+ prodInOutMapper.post(map);
|
|
|
+ if (!StringUtils.isEmpty(map.get("result"))){
|
|
|
+ throw new BizException(76201, map.get("result").toString());
|
|
|
}
|
|
|
/** 2.完工入库单 **/
|
|
|
//a.主表
|
|
|
@@ -360,9 +380,9 @@ public class MakeServiceImpl extends CommonBaseServiceImpl<MakeMapper, Make> imp
|
|
|
map.put("commitid", BaseContextHolder.getUserId());
|
|
|
map.put("companyId", BaseContextHolder.getCompanyId());
|
|
|
map.put("result", null);
|
|
|
- result = warehouseApi.post(map);
|
|
|
- if (!StringUtils.isEmpty(result.getData())){
|
|
|
- throw new BizException(76202, result.getData().toString());
|
|
|
+ prodInOutMapper.post(map);
|
|
|
+ if (!StringUtils.isEmpty(map.get("result"))){
|
|
|
+ throw new BizException(76201, map.get("result").toString());
|
|
|
}
|
|
|
}else if ("拆件".equals(make.getMa_type())){
|
|
|
/** 1.生产领料单 **/
|
|
|
@@ -412,9 +432,9 @@ public class MakeServiceImpl extends CommonBaseServiceImpl<MakeMapper, Make> imp
|
|
|
map.put("commitid", BaseContextHolder.getUserId());
|
|
|
map.put("companyId", BaseContextHolder.getCompanyId());
|
|
|
map.put("result", null);
|
|
|
- Result result = warehouseApi.post(map);
|
|
|
- if (!StringUtils.isEmpty(result.getData())){
|
|
|
- throw new BizException(76201, result.getData().toString());
|
|
|
+ prodInOutMapper.post(map);
|
|
|
+ if (!StringUtils.isEmpty(map.get("result"))){
|
|
|
+ throw new BizException(76201, map.get("result").toString());
|
|
|
}
|
|
|
/** 2.完工入库单 **/
|
|
|
//a.主表
|
|
|
@@ -467,15 +487,15 @@ public class MakeServiceImpl extends CommonBaseServiceImpl<MakeMapper, Make> imp
|
|
|
map.put("commitid", BaseContextHolder.getUserId());
|
|
|
map.put("companyId", BaseContextHolder.getCompanyId());
|
|
|
map.put("result", null);
|
|
|
- result = warehouseApi.post(map);
|
|
|
- if (!StringUtils.isEmpty(result.getData())){
|
|
|
- throw new BizException(76202, result.getData().toString());
|
|
|
+ prodInOutMapper.post(map);
|
|
|
+ if (!StringUtils.isEmpty(map.get("result"))){
|
|
|
+ throw new BizException(76202, map.get("result").toString());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- @Transactional
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public DocBaseDTO resAudit(Long id) {
|
|
|
//1.获取主从表数据
|
|
|
Make make = getMapper().selectByPrimaryKey(id);
|
|
|
@@ -492,6 +512,7 @@ public class MakeServiceImpl extends CommonBaseServiceImpl<MakeMapper, Make> imp
|
|
|
make.setMa_statuscode(Status.UNAUDITED.name());
|
|
|
make.setUpdateTime(new Date());
|
|
|
make.setUpdaterId(BaseContextHolder.getUserId());
|
|
|
+ getMapper().updateByPrimaryKeySelective(make);
|
|
|
DocBaseDTO docBaseDTO = generateMsgObj(id, make.getMa_code());
|
|
|
//6.记录LOG
|
|
|
messageLogService.unAudit(docBaseDTO);
|
|
|
@@ -544,26 +565,31 @@ public class MakeServiceImpl extends CommonBaseServiceImpl<MakeMapper, Make> imp
|
|
|
private void selectProdIO(Make make) {
|
|
|
String code = make.getMa_code();
|
|
|
Long companyId = BaseContextHolder.getCompanyId();
|
|
|
- String InCode = getMapper().selectMakeInOutCode(code, companyId, "完工入库单");
|
|
|
+ String inCode = getMapper().selectMakeInOutCode(code, companyId, "完工入库单");
|
|
|
String outCode = getMapper().selectMakeInOutCode(code, companyId, "生产领料单");
|
|
|
Map<String, Object> map = new HashMap<String, Object>();
|
|
|
- map.put("inoutNo", InCode);
|
|
|
+ map.put("inoutNo", inCode);
|
|
|
map.put("class", "完工入库单");
|
|
|
map.put("commitid", BaseContextHolder.getUserId());
|
|
|
map.put("companyId", companyId);
|
|
|
map.put("result", null);
|
|
|
//完工入库单反过账
|
|
|
- Result result = warehouseApi.unPost(map);
|
|
|
- if(!StringUtils.isEmpty(result)){
|
|
|
- throw new BizException(76203, result.getData().toString());
|
|
|
+ prodInOutMapper.unPost(map);
|
|
|
+ if(!StringUtils.isEmpty(map.get("result"))){
|
|
|
+ throw new BizException(76203, map.get("result").toString());
|
|
|
}
|
|
|
+ prodInOutMapper.deleteByInOutNo(inCode, "完工入库单", BaseContextHolder.getCompanyId());
|
|
|
+ prodIODetailMapper.deleteByInOutNo(inCode, "完工入库单", BaseContextHolder.getCompanyId());
|
|
|
+
|
|
|
map.put("inoutNo", outCode);
|
|
|
map.put("class", "生产领料单");
|
|
|
//生产领料单反过账
|
|
|
- result = warehouseApi.unPost(map);
|
|
|
- if(!StringUtils.isEmpty(result)){
|
|
|
- throw new BizException(76204, result.getData().toString());
|
|
|
+ prodInOutMapper.unPost(map);
|
|
|
+ if(!StringUtils.isEmpty(map.get("result"))){
|
|
|
+ throw new BizException(76204, map.get("result").toString());
|
|
|
}
|
|
|
+ prodInOutMapper.deleteByInOutNo(outCode, "生产领料单", BaseContextHolder.getCompanyId());
|
|
|
+ prodIODetailMapper.deleteByInOutNo(outCode, "生产领料单", BaseContextHolder.getCompanyId());
|
|
|
}
|
|
|
|
|
|
/**
|