|
|
|
@ -88,73 +88,79 @@ public class IZyProductPlanAutoServiceImpl extends ServiceImpl<ZyProductPlanMapp |
|
|
|
|
|
|
|
|
|
if (ObjectUtils.isEmpty(workOrderList)) return Collections.EMPTY_LIST; |
|
|
|
|
|
|
|
|
|
Set<String> zyProductPlanProductCodes = new LinkedHashSet<>(); |
|
|
|
|
Set<String> zyProductPlanProductNos = new LinkedHashSet<>(); |
|
|
|
|
List<SysDepart> sysDepartList = iSysDepartService.list(new LambdaQueryWrapper<SysDepart>().eq(SysDepart::getOrgCategory, "2")); |
|
|
|
|
List<SysDepart> sysDepartList2 = this.copyList(workOrderList, sysDepartList); |
|
|
|
|
|
|
|
|
|
AtomicInteger i = new AtomicInteger(0); |
|
|
|
|
workOrderList.stream().forEach(e -> { |
|
|
|
|
String productCode = e.getProductCode(); |
|
|
|
|
ZyProduct zyProduct = iZyProductService.getOne(new LambdaQueryWrapper<ZyProduct>() |
|
|
|
|
.eq(ZyProduct::getWorkOrderId, productCode)); |
|
|
|
|
Optional.ofNullable(zyProduct).orElseThrow(() -> new JeecgBootException(productCode + ":产品不存在")); |
|
|
|
|
|
|
|
|
|
//2,保存生产计划
|
|
|
|
|
ZyProductPlan zyProductPlan = new ZyProductPlan(); |
|
|
|
|
zyProductPlan.setProductCode(productCode); |
|
|
|
|
zyProductPlan.setProductNo(zyProduct.getProductCode()); |
|
|
|
|
zyProductPlan.setProductName(zyProduct.getProductName()); |
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(zyProduct.getEnterprisesId())) { |
|
|
|
|
SysDepart sysDepart = iSysDepartService.getById(zyProduct.getEnterprisesId()); |
|
|
|
|
//生产企业
|
|
|
|
|
zyProductPlan.setProductOrg(StringUtils.isNotBlank(sysDepart.getDepartName()) ? sysDepart.getDepartName() : ""); |
|
|
|
|
} |
|
|
|
|
//生产时长,取zy_product表生产时间
|
|
|
|
|
zyProductPlan.setDuration(zyProduct.getProduceTime()); |
|
|
|
|
SysDepart sysDepart = sysDepartList2.get(i.get()); |
|
|
|
|
i.set(i.get() + 1); |
|
|
|
|
List<String> sysDeparts = new LinkedList<>(); |
|
|
|
|
sysDeparts.add(sysDepart.getId()); |
|
|
|
|
List<SysUser> sysUserList = iSysUserService.getUserByDepIds(sysDeparts, null); |
|
|
|
|
if (!ObjectUtils.isEmpty(sysUserList)) { |
|
|
|
|
SysUser sysUser = sysUserList.get(0); |
|
|
|
|
//车间负责人
|
|
|
|
|
zyProductPlan.setResponsiblePerson(sysUser.getUsername()); |
|
|
|
|
} |
|
|
|
|
//车间
|
|
|
|
|
zyProductPlan.setWorkshopId(sysDepart.getId()); |
|
|
|
|
List<Groupx> groupxList = iGroupxService.list(new LambdaQueryWrapper<Groupx>().eq(Groupx::getDepartId, sysDepart.getId())); |
|
|
|
|
if (!ObjectUtils.isEmpty(groupxList)) { |
|
|
|
|
Groupx groupx = groupxList.get(0); |
|
|
|
|
//班组
|
|
|
|
|
zyProductPlan.setTeamId(groupx.getId()); |
|
|
|
|
//班长
|
|
|
|
|
SysUser sysUser = iSysUserService.getById(groupx.getEnterprisesManager()); |
|
|
|
|
zyProductPlan.setTeamLeader(sysUser.getUsername()); |
|
|
|
|
//工单id
|
|
|
|
|
String workOrderId = e.getId(); |
|
|
|
|
//一个工单对应一个产品
|
|
|
|
|
ZyProduct zyProduct = iZyProductService.getOne(new LambdaQueryWrapper<ZyProduct>().eq(ZyProduct::getWorkOrderId, workOrderId)); |
|
|
|
|
if (!ObjectUtils.isEmpty(zyProduct)) { |
|
|
|
|
//2,保存生产计划
|
|
|
|
|
ZyProductPlan zyProductPlan = new ZyProductPlan(); |
|
|
|
|
//工单编号
|
|
|
|
|
zyProductPlan.setProductCode(e.getProductCode()); |
|
|
|
|
//产品编号
|
|
|
|
|
zyProductPlan.setProductNo(zyProduct.getProductCode()); |
|
|
|
|
zyProductPlan.setProductName(zyProduct.getProductName()); |
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(zyProduct.getEnterprisesId())) { |
|
|
|
|
SysDepart sysDepart = iSysDepartService.getById(zyProduct.getEnterprisesId()); |
|
|
|
|
//生产企业
|
|
|
|
|
zyProductPlan.setProductOrg(StringUtils.isNotBlank(sysDepart.getDepartName()) ? sysDepart.getDepartName() : ""); |
|
|
|
|
} |
|
|
|
|
//生产时长,取zy_product表生产时间
|
|
|
|
|
zyProductPlan.setDuration(zyProduct.getProduceTime()); |
|
|
|
|
SysDepart sysDepart = sysDepartList2.get(i.get()); |
|
|
|
|
i.set(i.get() + 1); |
|
|
|
|
List<String> sysDeparts = new LinkedList<>(); |
|
|
|
|
sysDeparts.add(sysDepart.getId()); |
|
|
|
|
List<SysUser> sysUserList = iSysUserService.getUserByDepIds(sysDeparts, null); |
|
|
|
|
if (!ObjectUtils.isEmpty(sysUserList)) { |
|
|
|
|
SysUser sysUser = sysUserList.get(0); |
|
|
|
|
//车间负责人
|
|
|
|
|
zyProductPlan.setResponsiblePerson(sysUser.getUsername()); |
|
|
|
|
} |
|
|
|
|
//车间
|
|
|
|
|
zyProductPlan.setWorkshopId(sysDepart.getId()); |
|
|
|
|
List<Groupx> groupxList = iGroupxService.list(new LambdaQueryWrapper<Groupx>().eq(Groupx::getDepartId, sysDepart.getId())); |
|
|
|
|
if (!ObjectUtils.isEmpty(groupxList)) { |
|
|
|
|
Groupx groupx = groupxList.get(0); |
|
|
|
|
//班组
|
|
|
|
|
zyProductPlan.setTeamId(groupx.getId()); |
|
|
|
|
//班长
|
|
|
|
|
SysUser sysUser = iSysUserService.getById(groupx.getEnterprisesManager()); |
|
|
|
|
zyProductPlan.setTeamLeader(sysUser.getUsername()); |
|
|
|
|
} |
|
|
|
|
Date date = new Date(); |
|
|
|
|
//开始时间
|
|
|
|
|
zyProductPlan.setWorkTime(date); |
|
|
|
|
//审核人
|
|
|
|
|
zyProductPlan.setAuditBy("admin"); |
|
|
|
|
//审核时间
|
|
|
|
|
zyProductPlan.setAuditTimr(date); |
|
|
|
|
//生产计划状态为未审核
|
|
|
|
|
zyProductPlan.setStatus(new Integer(ProductPlanStatusEnum.UNAUDITED.getCode())); |
|
|
|
|
//保存生产计划
|
|
|
|
|
iZyProductPlanService.save(zyProductPlan); |
|
|
|
|
|
|
|
|
|
//更新work_order表work_order_status为“1” (不能为其新增生产计划)
|
|
|
|
|
iWorkOrderService.lambdaUpdate() |
|
|
|
|
.set(WorkOrder::getWorkOrderStatus, WorkOrderStatusEnum.REVIEWED.getCode()) |
|
|
|
|
.eq(WorkOrder::getProductCode, zyProductPlan.getProductCode()) |
|
|
|
|
.update(); |
|
|
|
|
zyProductPlanProductNos.add(zyProduct.getProductCode()); |
|
|
|
|
} |
|
|
|
|
Date date = new Date(); |
|
|
|
|
//开始时间
|
|
|
|
|
zyProductPlan.setWorkTime(date); |
|
|
|
|
//审核人
|
|
|
|
|
zyProductPlan.setAuditBy("admin"); |
|
|
|
|
//审核时间
|
|
|
|
|
zyProductPlan.setAuditTimr(date); |
|
|
|
|
//生产计划状态为未审核
|
|
|
|
|
zyProductPlan.setStatus(new Integer(ProductPlanStatusEnum.UNAUDITED.getCode())); |
|
|
|
|
//保存生产计划
|
|
|
|
|
iZyProductPlanService.save(zyProductPlan); |
|
|
|
|
|
|
|
|
|
//更新work_order表work_order_status为“1” (不能为其新增生产计划)
|
|
|
|
|
iWorkOrderService.lambdaUpdate().set(WorkOrder::getWorkOrderStatus, WorkOrderStatusEnum.REVIEWED.getCode()).update(); |
|
|
|
|
|
|
|
|
|
zyProductPlanProductCodes.add(productCode); |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
//根据productCode,查询本次创建生产计划
|
|
|
|
|
//根据产品编号,查询本次创建成功的生产计划
|
|
|
|
|
List<ZyProductPlan> productPlanList = iZyProductPlanService.list(new LambdaQueryWrapper<ZyProductPlan>() |
|
|
|
|
.eq(ZyProductPlan::getStatus, ProductPlanStatusEnum.UNAUDITED.getCode()) |
|
|
|
|
.in(ZyProductPlan::getStatus, zyProductPlanProductCodes)); |
|
|
|
|
.in(ZyProductPlan::getProductNo, zyProductPlanProductNos)); |
|
|
|
|
return productPlanList; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -168,72 +174,78 @@ public class IZyProductPlanAutoServiceImpl extends ServiceImpl<ZyProductPlanMapp |
|
|
|
|
List<ZyProductPlan> saveProductPlan4Mock(List<WorkOrder> workOrderList) { |
|
|
|
|
if (ObjectUtils.isEmpty(workOrderList)) return Collections.EMPTY_LIST; |
|
|
|
|
|
|
|
|
|
Set<String> zyProductPlanProductCodes = new LinkedHashSet<>(); |
|
|
|
|
Set<String> zyProductPlanProductNos = new LinkedHashSet<>(); |
|
|
|
|
/** |
|
|
|
|
* 模拟测试 车间、负责人、班组、组长使用固定值 |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
workOrderList.stream().forEach(e -> { |
|
|
|
|
String productCode = e.getProductCode(); |
|
|
|
|
// 工单编号
|
|
|
|
|
String productCode = e.getId(); |
|
|
|
|
ZyProduct zyProduct = iZyProductService.getOne(new LambdaQueryWrapper<ZyProduct>() |
|
|
|
|
.eq(ZyProduct::getWorkOrderId, productCode)); |
|
|
|
|
Optional.ofNullable(zyProduct).orElseThrow(() -> new JeecgBootException(productCode + ":产品不存在")); |
|
|
|
|
|
|
|
|
|
//2,保存生产计划
|
|
|
|
|
ZyProductPlan zyProductPlan = new ZyProductPlan(); |
|
|
|
|
zyProductPlan.setProductCode(productCode); |
|
|
|
|
zyProductPlan.setProductNo(zyProduct.getProductCode()); |
|
|
|
|
zyProductPlan.setProductName(zyProduct.getProductName()); |
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(zyProduct.getEnterprisesId())) { |
|
|
|
|
SysDepart sysDepart = iSysDepartService.getById(zyProduct.getEnterprisesId()); |
|
|
|
|
//生产企业
|
|
|
|
|
zyProductPlan.setProductOrg(StringUtils.isNotBlank(sysDepart.getDepartName()) ? sysDepart.getDepartName() : ""); |
|
|
|
|
.eq(ZyProduct::getWorkOrderId, productCode) |
|
|
|
|
); |
|
|
|
|
if (!ObjectUtils.isEmpty(zyProduct)) { |
|
|
|
|
//2,保存生产计划
|
|
|
|
|
ZyProductPlan zyProductPlan = new ZyProductPlan(); |
|
|
|
|
zyProductPlan.setProductCode(e.getProductCode()); |
|
|
|
|
zyProductPlan.setProductNo(zyProduct.getProductCode()); |
|
|
|
|
zyProductPlan.setProductName(zyProduct.getProductName()); |
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(zyProduct.getEnterprisesId())) { |
|
|
|
|
SysDepart sysDepart = iSysDepartService.getById(zyProduct.getEnterprisesId()); |
|
|
|
|
//生产企业
|
|
|
|
|
zyProductPlan.setProductOrg(StringUtils.isNotBlank(sysDepart.getDepartName()) ? sysDepart.getDepartName() : ""); |
|
|
|
|
} |
|
|
|
|
//生产时长,取zy_product表生产时间
|
|
|
|
|
zyProductPlan.setDuration(zyProduct.getProduceTime()); |
|
|
|
|
|
|
|
|
|
SysDepart sysDepart = iSysDepartService.getOne(new LambdaQueryWrapper<SysDepart>() |
|
|
|
|
.eq(SysDepart::getOrgCategory, "2") |
|
|
|
|
.eq(SysDepart::getDepartName, "测试生产企业")); |
|
|
|
|
if (ObjectUtils.isEmpty(sysDepart)) |
|
|
|
|
throw new JeecgBootException("生产计划自动化-mock-[企业信息]数据异常!"); |
|
|
|
|
|
|
|
|
|
//车间
|
|
|
|
|
zyProductPlan.setWorkshopId(sysDepart.getId()); |
|
|
|
|
List<String> sysDepartIds = new LinkedList<>(); |
|
|
|
|
sysDepartIds.add(sysDepart.getId()); |
|
|
|
|
List<SysUser> sysUserList = iSysUserService.getUserByDepIds(sysDepartIds, null); |
|
|
|
|
//车间负责人
|
|
|
|
|
zyProductPlan.setResponsiblePerson(sysUserList.get(0).getUsername()); |
|
|
|
|
Groupx groupx = iGroupxService.getOne(new LambdaQueryWrapper<Groupx>().eq(Groupx::getDepartId, sysDepart.getId()).eq(Groupx::getGroupName, "测试班组")); |
|
|
|
|
if (ObjectUtils.isEmpty(groupx)) throw new JeecgBootException("生产计划自动化-mock-[班组]数据异常!"); |
|
|
|
|
//班组
|
|
|
|
|
zyProductPlan.setTeamId(groupx.getId()); |
|
|
|
|
//班长
|
|
|
|
|
SysUser sysUser = iSysUserService.getById(groupx.getEnterprisesManager()); |
|
|
|
|
zyProductPlan.setTeamLeader(sysUser.getUsername()); |
|
|
|
|
Date date = new Date(); |
|
|
|
|
//开始时间
|
|
|
|
|
zyProductPlan.setWorkTime(date); |
|
|
|
|
//审核人
|
|
|
|
|
zyProductPlan.setAuditBy("admin"); |
|
|
|
|
//审核时间
|
|
|
|
|
zyProductPlan.setAuditTimr(date); |
|
|
|
|
//生产计划状态为未审核
|
|
|
|
|
zyProductPlan.setStatus(new Integer(ProductPlanStatusEnum.UNAUDITED.getCode())); |
|
|
|
|
//保存生产计划
|
|
|
|
|
iZyProductPlanService.save(zyProductPlan); |
|
|
|
|
|
|
|
|
|
//更新work_order表work_order_status为“1” (不能为其新增生产计划)
|
|
|
|
|
iWorkOrderService.lambdaUpdate() |
|
|
|
|
.set(WorkOrder::getWorkOrderStatus, WorkOrderStatusEnum.REVIEWED.getCode()) |
|
|
|
|
.eq(WorkOrder::getProductCode, zyProductPlan.getProductCode()) |
|
|
|
|
.update(); |
|
|
|
|
|
|
|
|
|
zyProductPlanProductNos.add(zyProduct.getProductCode()); |
|
|
|
|
} |
|
|
|
|
//生产时长,取zy_product表生产时间
|
|
|
|
|
zyProductPlan.setDuration(zyProduct.getProduceTime()); |
|
|
|
|
|
|
|
|
|
SysDepart sysDepart = iSysDepartService.getOne(new LambdaQueryWrapper<SysDepart>() |
|
|
|
|
.eq(SysDepart::getOrgCategory, "2") |
|
|
|
|
.eq(SysDepart::getDepartName, "测试生产企业")); |
|
|
|
|
if (ObjectUtils.isEmpty(sysDepart)) throw new JeecgBootException("生产计划自动化-mock-[企业信息]数据异常!"); |
|
|
|
|
|
|
|
|
|
//车间
|
|
|
|
|
zyProductPlan.setWorkshopId(sysDepart.getId()); |
|
|
|
|
List<String> sysDepartIds = new LinkedList<>(); |
|
|
|
|
sysDepartIds.add(sysDepart.getId()); |
|
|
|
|
List<SysUser> sysUserList = iSysUserService.getUserByDepIds(sysDepartIds, null); |
|
|
|
|
//车间负责人
|
|
|
|
|
zyProductPlan.setResponsiblePerson(sysUserList.get(0).getUsername()); |
|
|
|
|
Groupx groupx = iGroupxService.getOne(new LambdaQueryWrapper<Groupx>().eq(Groupx::getDepartId, sysDepart.getId()).eq(Groupx::getGroupName, "测试班组")); |
|
|
|
|
if (ObjectUtils.isEmpty(groupx)) throw new JeecgBootException("生产计划自动化-mock-[班组]数据异常!"); |
|
|
|
|
//班组
|
|
|
|
|
zyProductPlan.setTeamId(groupx.getId()); |
|
|
|
|
//班长
|
|
|
|
|
SysUser sysUser = iSysUserService.getById(groupx.getEnterprisesManager()); |
|
|
|
|
zyProductPlan.setTeamLeader(sysUser.getUsername()); |
|
|
|
|
Date date = new Date(); |
|
|
|
|
//开始时间
|
|
|
|
|
zyProductPlan.setWorkTime(date); |
|
|
|
|
//审核人
|
|
|
|
|
zyProductPlan.setAuditBy("admin"); |
|
|
|
|
//审核时间
|
|
|
|
|
zyProductPlan.setAuditTimr(date); |
|
|
|
|
//生产计划状态为未审核
|
|
|
|
|
zyProductPlan.setStatus(new Integer(ProductPlanStatusEnum.UNAUDITED.getCode())); |
|
|
|
|
//保存生产计划
|
|
|
|
|
iZyProductPlanService.save(zyProductPlan); |
|
|
|
|
|
|
|
|
|
//更新work_order表work_order_status为“1” (不能为其新增生产计划)
|
|
|
|
|
iWorkOrderService.lambdaUpdate().set(WorkOrder::getWorkOrderStatus, WorkOrderStatusEnum.REVIEWED.getCode()).update(); |
|
|
|
|
|
|
|
|
|
zyProductPlanProductCodes.add(productCode); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
//根据productCode,查询本次创建生产计划
|
|
|
|
|
List<ZyProductPlan> productPlanList = iZyProductPlanService.list(new LambdaQueryWrapper<ZyProductPlan>() |
|
|
|
|
.eq(ZyProductPlan::getStatus, ProductPlanStatusEnum.UNAUDITED.getCode()) |
|
|
|
|
.in(ZyProductPlan::getStatus, zyProductPlanProductCodes)); |
|
|
|
|
.eq(ZyProductPlan::getProductNo, zyProductPlanProductNos)); |
|
|
|
|
return productPlanList; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -270,9 +282,9 @@ public class IZyProductPlanAutoServiceImpl extends ServiceImpl<ZyProductPlanMapp |
|
|
|
|
if (ObjectUtils.isEmpty(workOrderList)) return Collections.EMPTY_LIST; |
|
|
|
|
|
|
|
|
|
//2,保存生产计划
|
|
|
|
|
// List<ZyProductPlan> productPlanList = this.saveProductPlan(workOrderList);
|
|
|
|
|
List<ZyProductPlan> productPlanList = this.saveProductPlan(workOrderList); |
|
|
|
|
//TODO
|
|
|
|
|
List<ZyProductPlan> productPlanList = this.saveProductPlan4Mock(workOrderList); |
|
|
|
|
// List<ZyProductPlan> productPlanList = this.saveProductPlan4Mock(workOrderList);
|
|
|
|
|
if (ObjectUtils.isEmpty(productPlanList)) return Collections.EMPTY_LIST; |
|
|
|
|
|
|
|
|
|
//3,同步计划生产工序、同步生产计划工序面料、同步生产计划辅料
|
|
|
|
|