生产计划自动化 2.23

zhc4dev
zhc077 2 years ago
parent 9c83e02237
commit 25fa982cde
  1. 2
      ant-design-vue-jeecg/src/views/productplan/modules/ZyProductPlanForm.vue
  2. 56
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/productplan/controller/ZyProductPlanAutoController.java
  3. 49
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/productplan/controller/ZyProductPlanController.java
  4. 20
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/productplan/service/IZyProductPlanAutoService.java
  5. 2
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/productplan/service/IZyProductPlanService.java
  6. 281
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/productplan/service/impl/IZyProductPlanAutoServiceImpl.java
  7. 46
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/productplan/service/impl/ZyPlanProcessServiceImpl.java
  8. 33
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/productplan/service/impl/ZyProductPlanServiceImpl.java
  9. 67
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/workorder/enums/WorkOrderStatusEnum.java

@ -63,7 +63,7 @@
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="生产时长()" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="duration">
<a-form-model-item label="生产时长(分钟)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="duration">
<a-input-number v-model="model.duration" placeholder="请输入生产时长" style="width: 100%"/>
</a-form-model-item>
</a-col>

@ -0,0 +1,56 @@
package org.jeecg.modules.productplan.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.productplan.entity.ZyProductPlan;
import org.jeecg.modules.productplan.entity.vo.PaiWeiTuVo;
import org.jeecg.modules.productplan.service.IZyProductPlanAutoService;
import org.jeecg.modules.productplan.service.IZyProductPlanService;
import org.jeecg.modules.system.entity.SysDepart;
import org.jeecg.modules.system.entity.SysUser;
import org.jeecg.modules.system.service.ISysDepartService;
import org.jeecg.modules.system.service.ISysUserService;
import org.jeecg.modules.workproduct.entity.ZyProduct;
import org.jeecg.modules.workproduct.service.IZyProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
/**
* @Description: 生产计划自动化
* @Author: jeecg-boot
* @Date: 2023-2-22
* @Version: V1.0
*/
@Api(tags = "生产计划自动化")
@RestController
@RequestMapping("/zyProductPlanAuto")
@Slf4j
public class ZyProductPlanAutoController extends JeecgController<ZyProductPlan, IZyProductPlanService> {
@Autowired
private IZyProductPlanAutoService iZyProductPlanAutoService;
@ApiOperation(value = "生产计划自动化", notes = "生产计划自动化")
@GetMapping(value = "/auto")
public Result<?> auto(HttpServletRequest req) {
iZyProductPlanAutoService.doAuto(req);
return Result.OK();
}
}

@ -15,11 +15,16 @@ import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.productplan.entity.ZyProductPlan;
import org.jeecg.modules.productplan.entity.vo.PaiWeiTuVo;
import org.jeecg.modules.productplan.enums.ProductPlanStatusEnum;
import org.jeecg.modules.productplan.service.IZyProductPlanService;
import org.jeecg.modules.system.entity.SysDepart;
import org.jeecg.modules.system.entity.SysUser;
import org.jeecg.modules.system.service.ISysDepartService;
import org.jeecg.modules.system.service.ISysUserService;
import org.jeecg.modules.team.entity.Station;
import org.jeecg.modules.workorder.entity.WorkOrder;
import org.jeecg.modules.workorder.enums.WorkOrderStatusEnum;
import org.jeecg.modules.workorder.service.IWorkOrderService;
import org.jeecg.modules.workproduct.entity.ZyProduct;
import org.jeecg.modules.workproduct.service.IZyProductService;
import org.springframework.beans.factory.annotation.Autowired;
@ -46,12 +51,14 @@ public class ZyProductPlanController extends JeecgController<ZyProductPlan, IZyP
private IZyProductPlanService zyProductPlanService;
@Autowired
private IZyProductService iZyProductService;
@Autowired
private ISysDepartService iSysDepartService;
@Autowired
private ISysUserService iSysUserService;
private IWorkOrderService iWorkOrderService;
// @Autowired
// private IZyProductService iZyProductService;
// @Autowired
// private ISysDepartService iSysDepartService;
//
// @Autowired
// private ISysUserService iSysUserService;
/**
* 分页列表查询
@ -92,18 +99,21 @@ public class ZyProductPlanController extends JeecgController<ZyProductPlan, IZyP
@ApiOperation(value = "生产计划-添加", notes = "生产计划-添加")
@PostMapping(value = "/add")
public Result<?> add(@RequestBody ZyProductPlan zyProductPlan) {
String productCode = zyProductPlan.getProductCode();
ZyProduct zyProduct = iZyProductService.getOne(new LambdaQueryWrapper<ZyProduct>().eq(ZyProduct::getWorkOrderId, productCode));
zyProductPlan.setProductNo(StringUtils.isNotBlank(zyProduct.getProductCode()) ? zyProduct.getProductCode() : "");
zyProductPlan.setProductName(StringUtils.isNotBlank(zyProduct.getProductName()) ? zyProduct.getProductName() : "");
if (StringUtils.isNotBlank(zyProduct.getEnterprisesId())) {
SysDepart sysDepart = iSysDepartService.getById(zyProduct.getEnterprisesId());
zyProductPlan.setProductOrg(StringUtils.isNotBlank(sysDepart.getDepartName()) ? sysDepart.getDepartName() : "");
}
SysUser sysUser = iSysUserService.getOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getRealname, zyProductPlan.getTeamLeader()));
zyProductPlan.setTeamLeader(sysUser.getUsername());
zyProductPlanService.save(zyProductPlan);
//TODO 更新work_order表work_order_status为“1” (不能为其新增生产计划)
// String productCode = zyProductPlan.getProductCode();
// ZyProduct zyProduct = iZyProductService.getOne(new LambdaQueryWrapper<ZyProduct>().eq(ZyProduct::getWorkOrderId, productCode));
// zyProductPlan.setProductNo(StringUtils.isNotBlank(zyProduct.getProductCode()) ? zyProduct.getProductCode() : "");
// zyProductPlan.setProductName(StringUtils.isNotBlank(zyProduct.getProductName()) ? zyProduct.getProductName() : "");
// if (StringUtils.isNotBlank(zyProduct.getEnterprisesId())) {
// SysDepart sysDepart = iSysDepartService.getById(zyProduct.getEnterprisesId());
// zyProductPlan.setProductOrg(StringUtils.isNotBlank(sysDepart.getDepartName()) ? sysDepart.getDepartName() : "");
// }
// SysUser sysUser = iSysUserService.getOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getRealname, zyProductPlan.getTeamLeader()));
// zyProductPlan.setTeamLeader(sysUser.getUsername());
// zyProductPlanService.save(zyProductPlan);
//
// //更新work_order表work_order_status为“1” (不能为其新增生产计划)
// iWorkOrderService.lambdaUpdate().set(WorkOrder::getWorkOrderStatus, WorkOrderStatusEnum.REVIEWED.getCode()).update();
zyProductPlanService.create(zyProductPlan);
return Result.OK("添加成功!");
}
@ -132,7 +142,8 @@ public class ZyProductPlanController extends JeecgController<ZyProductPlan, IZyP
@DeleteMapping(value = "/delete")
public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
zyProductPlanService.removeById(id);
//TODO 更新work_order表work_order_status为“0” (可以为其新增生产计划)
//更新work_order表work_order_status为“0” (可以为其新增生产计划)
iWorkOrderService.lambdaUpdate().set(WorkOrder::getWorkOrderStatus, WorkOrderStatusEnum.UNAUDITED.getCode()).update();
return Result.OK("删除成功!");
}

@ -0,0 +1,20 @@
package org.jeecg.modules.productplan.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.productplan.entity.ZyProductPlan;
import org.jeecg.modules.productplan.entity.vo.PaiWeiTuVo;
import javax.servlet.http.HttpServletRequest;
/**
* @Description: 生产计划
* @Author: jeecg-boot
* @Date: 2022-12-12
* @Version: V1.0
*/
public interface IZyProductPlanAutoService extends IService<ZyProductPlan> {
void doAuto(HttpServletRequest req);
void filling4Auto(String planId);
}

@ -15,4 +15,6 @@ import java.util.List;
public interface IZyProductPlanService extends IService<ZyProductPlan> {
PaiWeiTuVo paiweitu(ZyProductPlan zyProductPlan);
void create(ZyProductPlan zyProductPlan);
}

@ -0,0 +1,281 @@
package org.jeecg.modules.productplan.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.modules.demo.pro.entity.ZyProcessMachine;
import org.jeecg.modules.demo.pro.service.IZyProcessMachineService;
import org.jeecg.modules.productplan.entity.ZyPlanProcess;
import org.jeecg.modules.productplan.entity.ZyProductPlan;
import org.jeecg.modules.productplan.enums.ProductPlanStatusEnum;
import org.jeecg.modules.productplan.mapper.ZyProductPlanMapper;
import org.jeecg.modules.productplan.service.IZyPlanProcessService;
import org.jeecg.modules.productplan.service.IZyProductPlanAutoService;
import org.jeecg.modules.productplan.service.IZyProductPlanService;
import org.jeecg.modules.system.entity.SysDepart;
import org.jeecg.modules.system.entity.SysUser;
import org.jeecg.modules.system.service.ISysDepartService;
import org.jeecg.modules.system.service.ISysUserService;
import org.jeecg.modules.team.entity.Groupx;
import org.jeecg.modules.team.entity.Station;
import org.jeecg.modules.team.entity.StationMachine;
import org.jeecg.modules.team.service.IGroupxService;
import org.jeecg.modules.team.service.IStationMachineService;
import org.jeecg.modules.team.service.IStationService;
import org.jeecg.modules.workorder.entity.WorkOrder;
import org.jeecg.modules.workorder.enums.WorkOrderStatusEnum;
import org.jeecg.modules.workorder.service.IWorkOrderService;
import org.jeecg.modules.workproduct.entity.ZyProduct;
import org.jeecg.modules.workproduct.service.IZyProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
@Service
public class IZyProductPlanAutoServiceImpl extends ServiceImpl<ZyProductPlanMapper, ZyProductPlan> implements IZyProductPlanAutoService {
@Autowired
private IWorkOrderService iWorkOrderService;
@Autowired
private IZyProductPlanService iZyProductPlanService;
@Autowired
private IZyPlanProcessService zyPlanProcessService;
@Autowired
private IZyProductService iZyProductService;
@Autowired
private ISysDepartService iSysDepartService;
@Autowired
private ISysUserService iSysUserService;
@Autowired
private IGroupxService iGroupxService;
@Autowired
private IStationService iStationService;
@Autowired
private IZyProcessMachineService iZyProcessMachineService;
@Autowired
private IStationMachineService iStationMachineService;
@Transactional(rollbackFor = Exception.class, readOnly = false)
List<ZyProductPlan> saveProductPlan(List<WorkOrder> workOrderList) {
if (ObjectUtils.isEmpty(workOrderList)) return Collections.EMPTY_LIST;
Set<String> zyProductPlanProductCodes = 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);
//生产时长,取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.getRealname());
}
//车间
zyProductPlan.setWorkshopId(sysDepart.getId());
List<Groupx> groupxList = iGroupxService.list(new LambdaQueryWrapper<Groupx>().eq(Groupx::getDepartId, sysDepart));
if (!ObjectUtils.isEmpty(groupxList)) {
Groupx groupx = groupxList.get(0);
//班组
zyProductPlan.setTeamId(groupx.getId());
//班长
zyProductPlan.setTeamLeader(groupx.getEnterprisesManager());
}
//保存生产计划
iZyProductPlanService.create(zyProductPlan);
zyProductPlanProductCodes.add(productCode);
});
//根据productCode,查询本次创建生产计划
List<ZyProductPlan> productPlanList = iZyProductPlanService.list(new LambdaQueryWrapper<ZyProductPlan>()
.eq(ZyProductPlan::getStatus, ProductPlanStatusEnum.UNAUDITED.getCode())
.in(ZyProductPlan::getStatus, zyProductPlanProductCodes));
return productPlanList;
}
private List<SysDepart> copyList(List<WorkOrder> workOrderList, List<SysDepart> sysDepartList) {
if (ObjectUtils.isEmpty(workOrderList) || ObjectUtils.isEmpty(sysDepartList)) return Collections.EMPTY_LIST;
int size = workOrderList.size();
List<SysDepart> sysDepartList2 = new LinkedList<>();
sysDepartList2.addAll(sysDepartList);
int size2 = sysDepartList2.size();
while (size2 < size) {
sysDepartList2.addAll(sysDepartList);
size2 = sysDepartList2.size();
}
return sysDepartList2;
}
public static void main(String[] args) {
List list = new LinkedList();
List list2 = new LinkedList();
list.add("1");
list.add("2");
list.add("3");
list.add("4");
list.add("5");
list.add("6");
list.add("7");
list.add("8");
list2.add("a");
list2.add("b");
list2.add("c");
list2.add("c");
list2.add("c");
list2.add("c");
int size = list.size();
List<String> sysDepartList2 = new LinkedList<>();
sysDepartList2.addAll(list2);
int size2 = sysDepartList2.size();
while (size2 < size) {
sysDepartList2.addAll(list2);
size2 = sysDepartList2.size();
}
System.out.println("sysDepartList2 = " + sysDepartList2.size());
System.out.println("list2 = " + list2.size());
System.out.println("list = " + list.size());
}
@Override
public void doAuto(HttpServletRequest req) {
//1,获取未排产工单
List<WorkOrder> workOrderList = iWorkOrderService.list(new LambdaQueryWrapper<WorkOrder>()
.eq(WorkOrder::getWorkOrderStatus, WorkOrderStatusEnum.UNAUDITED.getCode()));
//2,保存生产计划
List<ZyProductPlan> productPlanList = this.saveProductPlan(workOrderList);
if (ObjectUtils.isEmpty(productPlanList)) return;
//3,保存计划生产工序
productPlanList.stream().forEach(f -> {
ZyPlanProcess zyPlanProcess = new ZyPlanProcess();
zyPlanProcess.setPlanId(f.getId());
zyPlanProcessService.syncProductBaseProcess(zyPlanProcess);
});
//4,自动排位
productPlanList.stream().forEach(k -> {
this.filling4Auto(k.getId());
});
}
/**
* 匹配车间工位设备与工序设备工位设备包含工序设备即匹配成功匹配失败做异常处理
* 匹配车间工位工具与工序设备工位设备包含工序设备即匹配成功匹配失败做异常处理
*
* @param planId
*/
@Override
public void filling4Auto(String planId) {
ZyProductPlan zyProductPlan = iZyProductPlanService.getById(planId);
if (ObjectUtils.isEmpty(zyProductPlan)) {
throw new JeecgBootException("生产计划不存在!");
}
List<ZyPlanProcess> planProcessList = zyPlanProcessService.list(new LambdaQueryWrapper<ZyPlanProcess>().eq(ZyPlanProcess::getPlanId, planId));
//是否有计划工序
if (ObjectUtils.isEmpty(planProcessList)) return;
//生产计划车间工位列表
List<Station> stationList = iStationService.list(new LambdaQueryWrapper<Station>().eq(Station::getDepartId, zyProductPlan.getWorkshopId()));
/**
* 遍历计划工序
* 用工序设备表数据与工位设备进行匹配
* 依次用该生产计划的车间工位设备循环与工序设备比对(工位设备包含工序设备即是匹配成功则自动填充工位设备字段数据匹配不上则不自动填充由用户自己录入)
* 根据工序查询工序设备表zy_process_machine
*/
if(this.diffMachine(planProcessList, stationList, planId)){
//TODO 匹配工具
}
}
/**
* 工位设备与产品工序设备匹配
* 只要有一个工序匹配不上就算匹配失败撤回前面匹配的工序标记该工单异常然后匹配下一个工单
*
* @param planProcessList
* @param stationList
*/
@Transactional(rollbackFor = Exception.class, readOnly = false)
public boolean diffMachine(List<ZyPlanProcess> planProcessList, List<Station> stationList, final String planId) {
if (ObjectUtils.isEmpty(stationList) || ObjectUtils.isEmpty(planProcessList)) return false;
AtomicBoolean b = new AtomicBoolean(true);
List<ZyPlanProcess> updateList = new LinkedList<>();
k: if (b.get()) {
f: for (int i = 0; i < planProcessList.size(); i++) {
ZyPlanProcess obj = planProcessList.get(i);
List<ZyProcessMachine> machineList = iZyProcessMachineService.list(new LambdaQueryWrapper<ZyProcessMachine>().eq(ZyProcessMachine::getProcessId, obj.getProcessId()));
List<String> zyProcessMachineIds = machineList.stream().map(ZyProcessMachine::getMachineId).collect(Collectors.toList());
for (int j = 0; j < stationList.size(); j++) {
Station station = stationList.get(j);
List<StationMachine> stationMachineList = iStationMachineService.list(new LambdaQueryWrapper<StationMachine>().eq(StationMachine::getStationId, station.getId()));
List<String> stationMachineIds = Optional.ofNullable(stationMachineList).orElse(new ArrayList<>()).stream()
.map(StationMachine::getMachineId).collect(Collectors.toList());
// 设备匹配成功
if (stationMachineIds.containsAll(zyProcessMachineIds)) {
String collect = zyProcessMachineIds.stream().collect(Collectors.joining(","));
obj.setMachineIds(collect);
obj.setMachineNames(iStationMachineService.convertByMachineIds(zyProcessMachineIds));
obj.setStationId(station.getId());
obj.setStationName(station.getStationName());
obj.setStationNum(station.getStationNum());
updateList.add(obj);
break f;
} else {
// 作工单异常处理,删除该工单的生产计划,删除生产计划工序
ZyProductPlan zyProductPlan = iZyProductPlanService.getById(planId);
iWorkOrderService.lambdaUpdate()
.set(WorkOrder::getWorkOrderStatus, WorkOrderStatusEnum.EXCEPTION.getCode())
.eq(WorkOrder::getProductCode, zyProductPlan.getProductCode()).update();
zyPlanProcessService.remove(new LambdaQueryWrapper<ZyPlanProcess>().in(ZyPlanProcess::getPlanId, planId));
iZyProductPlanService.remove(new LambdaQueryWrapper<ZyProductPlan>().in(ZyProductPlan::getId, planId));
b.set(false);
break k;
}
}
}
}
if (b.get()) {
zyPlanProcessService.saveOrUpdateBatch(updateList);
}
return b.get();
}
}

@ -515,51 +515,6 @@ public class ZyPlanProcessServiceImpl extends ServiceImpl<ZyPlanProcessMapper, Z
@Override
public void sendToRepository(ZyPlanProcess zyPlanProcess) {
// String planId = zyPlanProcess.getPlanId();
// ZyProductPlan zyProductPlan = iZyProductPlanService.getById(planId);
// if (ObjectUtils.isEmpty(zyProductPlan)) {
// throw new JeecgBootException("生产计划不存在!");
// }
// List<ZyPlanFabric> fabricList = iZyPlanFabricService.list(new LambdaQueryWrapper<ZyPlanFabric>()
// .eq(ZyPlanFabric::getPlanId, zyPlanProcess.getPlanId()));
// List<Delivery> deliveryList4Fabric = new LinkedList<>();
// Optional.ofNullable(fabricList).orElse(new LinkedList<>()).forEach(e -> {
// Delivery delivery = new Delivery();
// delivery.setDeliveryReason("0");
// delivery.setDeliveryTime(new Date());
// delivery.setItemType("0");
// delivery.setAmount(e.getAmount().doubleValue());
// delivery.setCarrierId("admin");
// delivery.setAdminId("admin");
// delivery.setStorehouseId("TODO");
// ZyFabric zyFabric = iZyFabricService.getById(e.getFabricId());
// if (!ObjectUtils.isEmpty(zyFabric)) {
// delivery.setItemCode(zyFabric.getFabricNumber());
// }
// deliveryList4Fabric.add(delivery);
// });
// iDeliveryService.saveBatch(deliveryList4Fabric);
//
// List<ZyPlanAccessories> accessoriesList = iZyPlanAccessoriesService.list(new LambdaQueryWrapper<ZyPlanAccessories>()
// .eq(ZyPlanAccessories::getPlanId, zyPlanProcess.getPlanId()));
// List<Delivery> deliveryList4accessories = new LinkedList<>();
// Optional.ofNullable(accessoriesList).orElse(new LinkedList<>()).forEach(e -> {
// Delivery delivery2 = new Delivery();
// delivery2.setDeliveryReason("0");
// delivery2.setDeliveryTime(new Date());
// delivery2.setItemType("1");
// delivery2.setAmount(e.getAmount().doubleValue());
// delivery2.setCarrierId("admin");
// delivery2.setAdminId("admin");
// delivery2.setStorehouseId("TODO");
// ZyAccessories zyAccessories = iZyAccessoriesService.getById(e.getAccessoriesId());
// if (!ObjectUtils.isEmpty(zyAccessories)) {
// delivery2.setItemCode(zyAccessories.getNums());
// }
// deliveryList4accessories.add(delivery2);
// });
// iDeliveryService.saveBatch(deliveryList4accessories);
iDeliveryService.sendToRepository(zyPlanProcess.getPlanId());
}
@ -597,6 +552,7 @@ public class ZyPlanProcessServiceImpl extends ServiceImpl<ZyPlanProcessMapper, Z
return result;
}
@Deprecated
@Override
public List<ProcessDataVo> getTeamDatalist(ZyPlanProcess zyPlanProcess) {
//生产计划id

@ -11,14 +11,21 @@ import org.jeecg.modules.demo.zyorders.service.IZyOrdersService;
import org.jeecg.modules.productplan.entity.ZyPlanProcess;
import org.jeecg.modules.productplan.entity.ZyProductPlan;
import org.jeecg.modules.productplan.entity.vo.PaiWeiTuVo;
import org.jeecg.modules.productplan.enums.ProductPlanStatusEnum;
import org.jeecg.modules.productplan.mapper.ZyProductPlanMapper;
import org.jeecg.modules.productplan.service.IZyPlanProcessService;
import org.jeecg.modules.productplan.service.IZyProductPlanService;
import org.jeecg.modules.system.entity.SysDepart;
import org.jeecg.modules.system.entity.SysUser;
import org.jeecg.modules.system.service.ISysDepartService;
import org.jeecg.modules.system.service.ISysUserService;
import org.jeecg.modules.team.entity.Groupx;
import org.jeecg.modules.team.service.IGroupxService;
import org.jeecg.modules.workorder.entity.WorkOrder;
import org.jeecg.modules.workorder.enums.WorkOrderStatusEnum;
import org.jeecg.modules.workorder.service.IWorkOrderService;
import org.jeecg.modules.workproduct.entity.ZyProduct;
import org.jeecg.modules.workproduct.service.IZyProductService;
import org.jeecg.modules.zyclothsstyle.entity.ZyClothsStyle;
import org.jeecg.modules.zyclothsstyle.service.IZyClothsStyleService;
import org.springframework.beans.factory.annotation.Autowired;
@ -27,6 +34,7 @@ import org.springframework.util.ObjectUtils;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicInteger;
/**
@ -64,6 +72,11 @@ public class ZyProductPlanServiceImpl extends ServiceImpl<ZyProductPlanMapper, Z
@Autowired
private IGroupxService iGroupxService;
@Autowired
private IZyProductService iZyProductService;
@Autowired
private ISysDepartService iSysDepartService;
@Override
public PaiWeiTuVo paiweitu(ZyProductPlan plan) {
@ -107,4 +120,24 @@ public class ZyProductPlanServiceImpl extends ServiceImpl<ZyProductPlanMapper, Z
vo.setDuration(productPlan.getDuration());
return vo;
}
@Override
public void create(ZyProductPlan zyProductPlan) {
String productCode = zyProductPlan.getProductCode();
ZyProduct zyProduct = iZyProductService.getOne(new LambdaQueryWrapper<ZyProduct>().eq(ZyProduct::getWorkOrderId, productCode));
Optional.ofNullable(zyProduct).orElseThrow(() -> new JeecgBootException(productCode + ":产品不存在"));
zyProductPlan.setProductNo(StringUtils.isNotBlank(zyProduct.getProductCode()) ? zyProduct.getProductCode() : "");
zyProductPlan.setProductName(StringUtils.isNotBlank(zyProduct.getProductName()) ? zyProduct.getProductName() : "");
if (StringUtils.isNotBlank(zyProduct.getEnterprisesId())) {
SysDepart sysDepart = iSysDepartService.getById(zyProduct.getEnterprisesId());
zyProductPlan.setProductOrg(StringUtils.isNotBlank(sysDepart.getDepartName()) ? sysDepart.getDepartName() : "");
}
SysUser sysUser = iSysUserService.getOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getRealname, zyProductPlan.getTeamLeader()));
zyProductPlan.setTeamLeader(sysUser.getUsername());
zyProductPlan.setStatus(new Integer(ProductPlanStatusEnum.UNAUDITED.getCode()));
this.save(zyProductPlan);
//更新work_order表work_order_status为“1” (不能为其新增生产计划)
iWorkOrderService.lambdaUpdate().set(WorkOrder::getWorkOrderStatus, WorkOrderStatusEnum.REVIEWED.getCode()).update();
}
}

@ -0,0 +1,67 @@
package org.jeecg.modules.workorder.enums;
/**
* 工单状态枚举
*/
public enum WorkOrderStatusEnum {
UNAUDITED("0", "未排产"),
REVIEWED("1", "已排产"),
PRODUCTION("2", "生产中"),
COMPLETED("3", "已完成"),
REVOKED("8", "已撤销"),
EXCEPTION("9", "异常");
private String code;
private String val;
private WorkOrderStatusEnum(String code, String val) {
this.code = code;
this.val = val;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getVal() {
return val;
}
public void setVal(String val) {
this.val = val;
}
public static String getValueByCode(String code) {
WorkOrderStatusEnum[] values = WorkOrderStatusEnum.values();
for (WorkOrderStatusEnum type : values) {
if (type.code.equals(code)) {
return type.val;
}
}
return null;
}
public static String getCodeByValue(String value) {
WorkOrderStatusEnum[] values = WorkOrderStatusEnum.values();
for (WorkOrderStatusEnum type : values) {
if (type.val.equals(value)) {
return type.code;
}
}
return null;
}
@Override
public String toString() {
return "ProductPlanStatusEnum{" +
"code='" + code + '\'' +
", val='" + val + '\'' +
'}';
}
}
Loading…
Cancel
Save