From d145c704d4cdd8f6afad234d2c2914475bb4db7f Mon Sep 17 00:00:00 2001
From: Mr.Zhang <710666463@qq.com>
Date: 星期四, 17 八月 2023 09:23:05 +0800
Subject: [PATCH] gitignore
---
server/src/main/java/doumeemes/service/ext/impl/WorkorderRecordStandardServiceImpl.java | 168 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 163 insertions(+), 5 deletions(-)
diff --git a/server/src/main/java/doumeemes/service/ext/impl/WorkorderRecordStandardServiceImpl.java b/server/src/main/java/doumeemes/service/ext/impl/WorkorderRecordStandardServiceImpl.java
index f649584..ffb5760 100644
--- a/server/src/main/java/doumeemes/service/ext/impl/WorkorderRecordStandardServiceImpl.java
+++ b/server/src/main/java/doumeemes/service/ext/impl/WorkorderRecordStandardServiceImpl.java
@@ -16,7 +16,9 @@
import doumeemes.core.utils.redis.RedisUtil;
import doumeemes.dao.business.BackOrderDetailMapper;
import doumeemes.dao.business.BackorderMapper;
+import doumeemes.dao.business.SalaryParamMapper;
import doumeemes.dao.business.dto.CreateMaterialDTO;
+import doumeemes.dao.business.dto.CreateWorkorderRecordDTO;
import doumeemes.dao.business.dto.DealWorkorderRecordDTO;
import doumeemes.dao.business.dto.MaterialListDTO;
import doumeemes.dao.business.model.*;
@@ -79,6 +81,12 @@
private WOutboundRecordExtMapper wOutboundRecordExtMapper;
@Autowired
private MaterialExtMapper materialExtMapper;
+ @Autowired
+ private SalaryParamMapper salaryParamMapper;
+ @Autowired
+ private PlansExtMapper plansExtMapper;
+ @Autowired
+ private DeviceExtMapper deviceExtMapper;
@Transactional(rollbackFor = {BusinessException.class,Exception.class})
@Override
@@ -184,6 +192,14 @@
return mp;
}
+ private void getPlansAndValid(LoginUserInfo user, Plans mp) throws BusinessException{
+ if(mp== null){
+ throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "瀵逛笉璧凤紝璇ヨ褰曚笉瀛樺湪锛�");
+ }
+ if(Constants.equalsInteger(mp.getPaused(),Constants.ONE)){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "瀵逛笉璧凤紝宸ュ崟宸叉殏鍋滐紒");
+ }
+ }
private QueryBomDetailExtDTO initBomParam(LoginUserInfo user, Workorder mp) throws BusinessException{
QueryBomExtDTO bb = new QueryBomExtDTO();
@@ -203,6 +219,27 @@
bom.setBomId(versionBom.getBomVersionId());
// bom.setProcedureId(mp.getProcedureId());
bom.setWorkorderId(mp.getId());
+ return bom;
+ }
+
+ private QueryBomDetailExtDTO initBomParamForPlans(LoginUserInfo user, Plans plans) throws BusinessException{
+ QueryBomExtDTO bb = new QueryBomExtDTO();
+ bb.setDepartId(plans.getDepartId());
+ bb.setDeleted(Constants.ZERO);
+ bb.setRootDepartId(user.getRootDepartment().getId());
+ bb.setMaterialId(plans.getMaterialId());
+ bb.setProcedureId(plans.getProcedureId());
+ BomExtListVO versionBom = bomExtMapper.selectByModel( bb);
+ if(versionBom == null || StringUtils.isBlank(versionBom.getVersion()) || versionBom.getBomVersionId() == null){
+ return null;
+ // throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "瀵逛笉璧凤紝璇ュ伐鍗曠墿鏂橞OM淇℃伅閰嶇疆鏈夎锛岃鑱旂郴绠$悊鍛橈紒");
+ }
+ plans.setBomModel(versionBom);
+ QueryBomDetailExtDTO bom = new QueryBomDetailExtDTO();
+ bom.setDeleted(Constants.ZERO);
+ bom.setBomId(versionBom.getBomVersionId());
+// bom.setProcedureId(mp.getProcedureId());
+ bom.setPlansId(plans.getId());
return bom;
}
@@ -277,7 +314,6 @@
}
private void updateOrderInfo(LoginUserInfo user, Workorder mp,int status) {
-
List<WorkorderHistory> whList = new ArrayList<>();
//宸ュ崟鍘嗗彶鏁版嵁
Workorder order = new Workorder();
@@ -295,7 +331,7 @@
order.setStatus(Constants.WORKORDER_STATUS.material);
}else if(status ==Constants.WORKORDER_HISTORY_STATUS.done){
order.setStatus(Constants.WORKORDER_STATUS.done);
- }else if(status ==Constants.WORKORDER_HISTORY_STATUS.material){
+ }else if(status ==Constants.WORKORDER_HISTORY_STATUS.material ||status ==Constants.WORKORDER_HISTORY_STATUS.produce){
//鎶曟枡鎿嶄綔
if(Constants.equalsInteger(mp.getStatus(),Constants.WORKORDER_STATUS.create)
||Constants.equalsInteger(mp.getStatus(),Constants.WORKORDER_STATUS.material)){
@@ -981,15 +1017,15 @@
throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝璇ュ伐鍗曚俊鎭紒");
}
if(Objects.isNull(dealWorkorderRecordDTO.getDownType())
- ||Objects.isNull(dealWorkorderRecordDTO.getWorkorderId())
- ||Objects.isNull(dealWorkorderRecordDTO.getNum())
+ ||Objects.isNull(dealWorkorderRecordDTO.getWorkorderId())
+ ||Objects.isNull(dealWorkorderRecordDTO.getNum())
){
throw new BusinessException(ResponseStatus.BAD_REQUEST);
}
WorkorderRecord workorderRecord = new WorkorderRecord();
if(Objects.isNull(dealWorkorderRecordDTO.getRecordId())){
//鏌ヨ宸ュ崟涓嬫槸鍚﹀瓨鍦ㄥ搴旇褰�
- workorderRecord = workorderRecordExtMapper.selectOne(new QueryWrapper<WorkorderRecord>()
+ workorderRecord = workorderRecordExtMapper.selectOne(new QueryWrapper<WorkorderRecord>()
.eq("WORKORDER_ID",dealWorkorderRecordDTO.getWorkorderId())
.eq("DONE_TYPE",dealWorkorderRecordDTO.getDownType())
.eq("TYPE",Constants.ONE)
@@ -1107,5 +1143,127 @@
return PageData.from(new PageInfo<>(result));
}
+ @Override
+ public PageData<WStockExtListVO> choiceStockPageForPlans(PageWrap<QueryWStockDto> pageWrap,LoginUserInfo userInfo) {
+ Plans plans =plansExtMapper.selectById(pageWrap.getModel().getPlansId());
+ if(Objects.isNull(plans)){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝鏈煡璇㈠埌宸ュ簭璁″垝淇℃伅锛�");
+ }
+ Device device = deviceExtMapper.selectById(pageWrap.getModel().getDeviceId());
+ if(Objects.isNull(plans)){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝鏈煡璇㈠埌璁惧淇℃伅锛�");
+ }
+ //鏌ヨ骞堕獙璇佸伐鍗曚俊鎭�
+ this.getPlansAndValid(userInfo,plans);
+ //鏌ヨ鍏ㄩ儴bom缁勬垚鏁版嵁锛屽鏋滄湁BOM閰嶇疆锛屾寜鐓OM缁勬垚杩涜鎶曟枡锛屽鏋滄病鏈塀OM閰嶇疆锛屽垯鎶曟枡鐗╂枡涓哄緟鐢熶骇搴撲綅鐨勭墿鏂欐湰韬�
+ QueryBomDetailExtDTO bdparam = initBomParamForPlans(userInfo,plans);
+ List<BomDetailExtListVO> bomDetailList = null;
+ if(bdparam!=null){
+ bomDetailList = bomDetailExtMapper.selectList(bdparam);
+ List<Integer> materialDistributeId = bomDetailList.stream().map(BomDetailExtListVO::getMaterialId).collect(Collectors.toList());
+ pageWrap.getModel().setMaterialDistributeId(materialDistributeId);
+ }else{
+ //鏌ヨ鐗╂枡BOM淇℃伅
+ Bom bom = bomExtMapper.selectOne(new QueryWrapper<Bom>().eq("MATERIAL_ID",plans.getMaterialId()).eq("DELETED",Constants.ZERO).last(" limit 1 "));
+ if(Objects.isNull(bom)){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝鏈煡璇㈠埌BOM淇℃伅锛�");
+ }
+ RouteProcedure currentRouteProcedure = routeProcedureExtMapper.selectOne(new QueryWrapper<RouteProcedure>()
+ .eq("ROUTE_ID",bom.getRouteId())
+ .eq("PROCEDURE_ID",plans.getProcedureId())
+ .last(" limit 1 ")
+ );
+ if(currentRouteProcedure!=null){
+ RouteProcedure routeProcedure = routeProcedureExtMapper.selectOne(new QueryWrapper<RouteProcedure>()
+ .eq("ROUTE_ID",currentRouteProcedure.getRouteId()).apply(" SORTNUM < " + currentRouteProcedure.getSortnum() ).eq("STATUS",Constants.ONE).orderByDesc(" SORTNUM ").last(" limit 1 ")
+ );
+ if(Objects.isNull(routeProcedure)){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝鏈煡璇㈠埌鐢熶骇鐗╂枡涓婁竴姝ュ伐搴忎俊鎭紒");
+ }
+ pageWrap.getModel().setProcedureId(routeProcedure.getProcedureId());
+ pageWrap.getModel().setMaterialId(plans.getMaterialId());
+ }
+ }
+ pageWrap.getModel().setLocationId(device.getProduceWarehouseLocationId());
+ PageHelper.startPage(pageWrap.getPage(), pageWrap.getCapacity());
+ List<WStockExtListVO> result = wStockExtMapper.choiceStockList(pageWrap.getModel());
+ return PageData.from(new PageInfo<>(result));
+ }
+
+ @Override
+ @Transactional(rollbackFor = {BusinessException.class,Exception.class})
+ public WorkorderRecord createWorkorderRecord(CreateWorkorderRecordDTO createWorkorderRecordDTO, LoginUserInfo loginUserInfo){
+ Workorder workorder = workorderExtMapper.selectById(createWorkorderRecordDTO.getWorkorderId());
+ if(Objects.isNull(workorder)){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝鏈煡璇㈠埌璇ュ伐鍗曚俊鎭紒");
+ }
+ if(Objects.isNull(createWorkorderRecordDTO.getUnQualifiedNum())
+ ||Objects.isNull(createWorkorderRecordDTO.getUnQualifiedNum())
+ ||Objects.isNull(createWorkorderRecordDTO.getWorkorderId())
+ ){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST);
+ }
+ BigDecimal num = createWorkorderRecordDTO.getQualifiedNum().add(createWorkorderRecordDTO.getUnQualifiedNum());
+ WorkorderRecord workorderRecord = new WorkorderRecord();
+ //鏌ヨ宸ュ崟涓嬫槸鍚﹀瓨鍦ㄥ搴旇褰�
+ workorderRecord = workorderRecordExtMapper.selectOne(new QueryWrapper<WorkorderRecord>()
+ .eq("WORKORDER_ID",createWorkorderRecordDTO.getWorkorderId())
+ .eq("TYPE",Constants.ONE)
+ .eq("DELETED",Constants.ZERO)
+ .last(" limit 1 ")
+ );
+ if(!Objects.isNull(workorderRecord)){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝璇ュ伐鍗曠殑璇ョ被浜у嚭璁板綍宸插瓨鍦紒");
+ }
+ if(num.compareTo(BigDecimal.valueOf(workorder.getPlanNum()))>Constants.ZERO){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝璇ュ伐鍗曠殑浜у嚭鏁伴噺涓嶈兘澶т簬宸ュ崟璁″垝鏁伴噺锛�");
+ }
+ //鏁版嵁瀛樺偍
+ workorderRecord = new WorkorderRecord();
+ workorderRecord.setDeleted(Constants.ZERO);
+ workorderRecord.setCreateUser(loginUserInfo.getId());
+ workorderRecord.setCreateTime(new Date());
+ workorderRecord.setNum(num);
+ workorderRecord.setRootDepartId(loginUserInfo.getRootDepartment().getId());
+ workorderRecord.setDepartId(loginUserInfo.getCurComDepartment().getId());
+ workorderRecord.setPlanId(workorder.getPlanId());
+ workorderRecord.setWorkorderId(createWorkorderRecordDTO.getWorkorderId());
+ workorderRecord.setBatch(workorder.getBatch());
+ workorderRecord.setFactoryId(workorder.getFactoryId());
+ workorderRecord.setProcedureId(workorder.getProcedureId());
+ workorderRecord.setProDate(new Date());
+ workorderRecord.setType(Constants.ONE);
+ workorderRecord.setMaterialId(workorder.getMaterialId());
+ workorderRecord.setUnitId(workorder.getUnitId());
+ workorderRecord.setMaterialBatch(workorder.getBatch());
+ workorderRecord.setUnqualifiedNum(createWorkorderRecordDTO.getUnQualifiedNum());
+ workorderRecord.setQualifiedNum(createWorkorderRecordDTO.getQualifiedNum());
+ //璁$畻宸ヨ祫淇℃伅
+ SalaryParam salaryParam = salaryParamMapper.selectOne(new QueryWrapper<SalaryParam>().eq("DELETED",Constants.ZERO).eq("MATERIAL_ID",workorderRecord.getMaterialId())
+ .eq("DEPART_ID",workorderRecord.getFactoryId()).eq("PROCEDURE_ID",workorderRecord.getProcedureId()).last(" limit 1 "));
+ if(Objects.isNull(salaryParam)){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鏈厤缃伐璧勭哗鏁堥厤缃紒");
+ }
+ workorderRecord.setSalaryPrice(salaryParam.getSalary());
+ workorderRecord.setSalaryType(salaryParam.getType());
+ workorderRecord.setSalaryUnqualified(salaryParam.getUnqualified());
+
+ //璁′欢宸ヨ祫
+ if(salaryParam.getType().equals(Constants.ZERO)){
+ workorderRecord.setSalaryNum(salaryParam.getNum());
+ workorderRecord.setSalary(salaryParam.getSalary().multiply(salaryParam.getUnqualified()==Constants.ZERO?num:createWorkorderRecordDTO.getUnQualifiedNum()));
+ }else{
+ workorderRecord.setDuration(createWorkorderRecordDTO.getDuration());
+ workorderRecord.setSalary(BigDecimal.valueOf(createWorkorderRecordDTO.getDuration()).multiply(salaryParam.getSalary()).divide(new BigDecimal(3600)));
+ }
+
+ //鎻掑叆宸ュ崟鎿嶄綔璁板綍锛屽苟涓斿垽鏂槸鍚︽洿鏀逛负宸ュ崟鐨勭姸鎬併�愮敓浜т腑銆�
+ updateOrderInfo(loginUserInfo,workorder,Constants.WORKORDER_HISTORY_STATUS.produce);
+ workorderRecordExtMapper.insert(workorderRecord);
+ return workorderRecord;
+ }
+
+
+
}
--
Gitblit v1.9.3