|
@@ -10,6 +10,8 @@ import cn.ezhizao.framework.web.domain.AjaxResult;
|
|
import cn.ezhizao.framework.web.page.TableDataInfo;
|
|
import cn.ezhizao.framework.web.page.TableDataInfo;
|
|
import cn.ezhizao.project.business.deptProcess.domain.BizDeptProcess;
|
|
import cn.ezhizao.project.business.deptProcess.domain.BizDeptProcess;
|
|
import cn.ezhizao.project.business.deptProcess.service.IBizDeptProcessService;
|
|
import cn.ezhizao.project.business.deptProcess.service.IBizDeptProcessService;
|
|
|
|
+import cn.ezhizao.project.business.outsource.domain.BizOutsourcedOrderDetailProcess;
|
|
|
|
+import cn.ezhizao.project.business.outsource.service.IBizOutsourcedOrderDetailProcessService;
|
|
import cn.ezhizao.project.business.process.domain.BizProcess;
|
|
import cn.ezhizao.project.business.process.domain.BizProcess;
|
|
import cn.ezhizao.project.business.process.service.IBizProcessService;
|
|
import cn.ezhizao.project.business.process.service.IBizProcessService;
|
|
import cn.ezhizao.project.business.product.domain.*;
|
|
import cn.ezhizao.project.business.product.domain.*;
|
|
@@ -40,6 +42,7 @@ import org.springframework.web.server.ServerErrorException;
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
+import java.math.BigDecimal;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -108,6 +111,8 @@ public class BizDayworkItemController extends BaseController {
|
|
private IBizDayworkItemExamineService bizDayworkItemExamineService;
|
|
private IBizDayworkItemExamineService bizDayworkItemExamineService;
|
|
@Resource
|
|
@Resource
|
|
private IBizTakeStockPeriodService bizTakeStockPeriodService;
|
|
private IBizTakeStockPeriodService bizTakeStockPeriodService;
|
|
|
|
+ @Resource
|
|
|
|
+ private IBizOutsourcedOrderDetailProcessService bizOutsourcedOrderDetailProcessService;
|
|
/**
|
|
/**
|
|
* 查询报工记录列表
|
|
* 查询报工记录列表
|
|
*/
|
|
*/
|
|
@@ -762,6 +767,196 @@ public class BizDayworkItemController extends BaseController {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ // 自动派活
|
|
|
|
+ SysDept sysDept = sysDeptMapper.selectDeptById(bizDayworkItem.getDeptId());
|
|
|
|
+ if (sysDept.getAutoAllocation() == 1) {
|
|
|
|
+ // 查资源组
|
|
|
|
+ List<BizProductionResourceGroup> productionResourceGroupList = bizProductionResourceGroupService.list(new QueryWrapper<BizProductionResourceGroup>().eq("dept_id", bizDayworkItem.getDeptId()));
|
|
|
|
+
|
|
|
|
+ //查询是否已经分配资源组
|
|
|
|
+ BizProductionResourceGroupSubPlan groupSubPlan=new BizProductionResourceGroupSubPlan();
|
|
|
|
+ groupSubPlan.setDeptId(bizDayworkItem.getDeptId());
|
|
|
|
+ groupSubPlan.setProductionPlanDetailId(bizDayworkItem.getProductionPlanDetailId());
|
|
|
|
+ List<BizProductionResourceGroupSubPlan> groupSubPlanList = bizProductionResourceGroupSubPlanService.getList(groupSubPlan);
|
|
|
|
+ //如果没分配
|
|
|
|
+ if(groupSubPlanList.isEmpty()){
|
|
|
|
+ //查产品id
|
|
|
|
+ BizProductionPlanDetail productionPlanDetail = bizProductionPlanDetailService.getOne(new QueryWrapper<BizProductionPlanDetail>().eq("id", bizDayworkItem.getProductionPlanDetailId()));
|
|
|
|
+ //存放保存的subPlanList
|
|
|
|
+ List<BizProductionResourceGroupSubPlan> subPlanList = new ArrayList<>();
|
|
|
|
+ for (BizProductionResourceGroup info : productionResourceGroupList) {
|
|
|
|
+ BizProductionResourceGroupSubPlan subPlan = new BizProductionResourceGroupSubPlan();
|
|
|
|
+ subPlan.setProductId(productionPlanDetail.getProductId());
|
|
|
|
+ subPlan.setProductionPlanDetailId(bizDayworkItem.getProductionPlanDetailId());
|
|
|
|
+ subPlan.setTechnologicalProcessId(bizDayworkItem.getTechnologicalProcessId());
|
|
|
|
+ subPlan.setResourceGroupId(info.getId());
|
|
|
|
+ subPlan.setDeptId(bizDayworkItem.getDeptId());
|
|
|
|
+ subPlan.setResourceGroupCode(info.getCode());
|
|
|
|
+ subPlanList.add(subPlan);
|
|
|
|
+ }
|
|
|
|
+ bizProductionResourceGroupSubPlanService.saveBatch(subPlanList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ bizDayworkItemRejectService.saveBatch(bizDayworkItem.getRejectList());
|
|
|
|
+ return toAjax(batch);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ @Log(title = "新增报工记录", businessType = BusinessType.INSERT)
|
|
|
|
+ @Transactional
|
|
|
|
+ @PostMapping("/saveInnerDayworkItem")
|
|
|
|
+ public AjaxResult saveInnerDayworkItem(@RequestBody BizDayworkItem bizDayworkItem) throws NoSuchFieldException, IllegalAccessException {
|
|
|
|
+ /** 如果是已完成工序,生成一条空报工记录保存下一道工序 */
|
|
|
|
+ BizDaywork daywork = new BizDaywork();
|
|
|
|
+ daywork.setId(bizDayworkItem.getDayworkId());
|
|
|
|
+
|
|
|
|
+ List<BizDaywork> list = bizDayworkService.getList(daywork);
|
|
|
|
+ daywork = list.get(0);
|
|
|
|
+
|
|
|
|
+ //如果是修改工单,则获取该工单工序
|
|
|
|
+ if(daywork.getIsAmend()==1 || daywork.getIsWasteRecycling()==1){
|
|
|
|
+ List<BizProcess> processList=new ArrayList<>();
|
|
|
|
+ List<BizLotTechnologicalProcessDetail> bizLotTechnologicalProcessDetail = bizLotTechnologicalProcessDetailService.query().eq("lot_technological_process_id", daywork.getTechnologicalProcessId()).list();
|
|
|
|
+ bizLotTechnologicalProcessDetail.forEach(item->{
|
|
|
|
+ BizProcess itemProcess = new BizProcess();
|
|
|
|
+ itemProcess.setProcessCode(item.getProcessCode());
|
|
|
|
+ itemProcess.setProcessAlias(item.getProcessAlias());
|
|
|
|
+ itemProcess.setProcessStepNumber(item.getProcessStepNumber());
|
|
|
|
+ processList.add(itemProcess);
|
|
|
|
+ });
|
|
|
|
+ daywork.setProcessSequence(processList);
|
|
|
|
+ }else {
|
|
|
|
+ List<BizProcess> processList=new ArrayList<>();
|
|
|
|
+ List<BizTechnologicalProcessDetail> bizTechnologicalProcessDetail = bizTechnologicalProcessDetailService.query().eq("technological_process_id", daywork.getTechnologicalProcessId()).ne("tenant_id",9).list();
|
|
|
|
+ bizTechnologicalProcessDetail.forEach(item->{
|
|
|
|
+ BizProcess itemProcess = new BizProcess();
|
|
|
|
+ itemProcess.setProcessCode(item.getProcessCode());
|
|
|
|
+ itemProcess.setProcessAlias(item.getProcessAlias());
|
|
|
|
+ itemProcess.setProcessStepNumber(item.getProcessStepNumber());
|
|
|
|
+ processList.add(itemProcess);
|
|
|
|
+ });
|
|
|
|
+ daywork.setProcessSequence(processList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(daywork.getIsAmend()==1){
|
|
|
|
+ bizDayworkItem.setFormDayworkItemId(1L);
|
|
|
|
+ }
|
|
|
|
+ //并且计算该报工批次的当前工序下的合格数总量
|
|
|
|
+ BizDayworkItem bizItem = new BizDayworkItem();
|
|
|
|
+ bizItem.setDayworkId(bizDayworkItem.getDayworkId());
|
|
|
|
+ bizItem.setProcessId(bizDayworkItem.getProcessId());
|
|
|
|
+ bizItem.setTechnologicalProcessDetailId(bizDayworkItem.getTechnologicalProcessDetailId());
|
|
|
|
+ List<BizDayworkItem> itemList = bizDayworkItemService.getList(bizItem);
|
|
|
|
+ //获取当前工序下的总合格数
|
|
|
|
+ Integer lot = 0;
|
|
|
|
+ //如果非手续
|
|
|
|
+ if (bizDayworkItem.getQualifiedNum() != null) {
|
|
|
|
+ lot = bizDayworkItem.getQualifiedNum();
|
|
|
|
+ }
|
|
|
|
+ for (BizDayworkItem dayworkItem : itemList) {
|
|
|
|
+ lot += dayworkItem.getQualifiedNum();
|
|
|
|
+ }
|
|
|
|
+ // 结束报工校验
|
|
|
|
+ //如果是手续(上一道序的合格数是0)校验报工批次的单批数
|
|
|
|
+ if ((bizDayworkItem.getStatus().equals("2") || bizDayworkItem.getStatus().equals("3")) && !bizDayworkItem.getIsPreProcess()) {
|
|
|
|
+ if (daywork.getProcessQualifiedNum() == 0) {
|
|
|
|
+ if (lot > (daywork.getOneLotQuantity() * 1.03)) {
|
|
|
|
+ return error("该批次合格数已超投入数上限(103%)");
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ if (lot > (daywork.getProcessQualifiedNum() * 1.03)) {
|
|
|
|
+ return error("该批次合格数已超投入数上限(103%)");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 已送达状态更改daywork的当前部门
|
|
|
|
+ if (bizDayworkItem.getStatus().equals("7")) {
|
|
|
|
+ daywork.setDeptId(bizDayworkItem.getDeptId());
|
|
|
|
+ daywork.setProcessQualifiedNum(daywork.getTemporaryProcessQualifiedNum());
|
|
|
|
+ daywork.setProtemProcessStepNumber(bizDayworkItem.getProcessStepNumber());
|
|
|
|
+ bizDayworkService.updateById(daywork);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (bizDayworkItem.getStatus().equals("5")) {
|
|
|
|
+ daywork.setProcessQualifiedNum(daywork.getTemporaryProcessQualifiedNum());
|
|
|
|
+ bizDayworkService.updateById(daywork);
|
|
|
|
+ daywork.setProtemProcessStepNumber(bizDayworkItem.getProcessStepNumber());
|
|
|
|
+ }
|
|
|
|
+ /** 当最后一道序完成时,释放该批次下所有载具 */
|
|
|
|
+ if (bizDayworkItem.getStatus().equals("3")) {
|
|
|
|
+ //校验当前序是否还有未完成的报工
|
|
|
|
+ List<BizDayworkItem> items = bizDayworkItemService.query().eq("daywork_id", bizDayworkItem.getDayworkId()).eq("process_id", bizDayworkItem.getProcessId()).lt("status", 2).ne("id", bizDayworkItem.getId()).list();
|
|
|
|
+ if (!items.isEmpty()) {
|
|
|
|
+ return error("当前工序还有其他未完成的报工,不允许工序完成");
|
|
|
|
+ }
|
|
|
|
+ //工序结束时将合格数保存
|
|
|
|
+ daywork.setProtemProcessId(bizDayworkItem.getProcessId());
|
|
|
|
+ //daywork.setTemporaryProcessQualifiedNum(lot);
|
|
|
|
+ // 此处在biz_daywork_qualified中间表中,插入一条数据
|
|
|
|
+ // 记录当前批次,当前工序的投入数、合格数
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //判断当前序为最后一道序
|
|
|
|
+ if (bizDayworkItem.getProcessStepNumber().equals(daywork.getProcessSequence().get(daywork.getProcessSequence().size() - 1).getProcessStepNumber())) {
|
|
|
|
+ bizDayworkCarrierService.removeByDayworkId(daywork.getId());
|
|
|
|
+ //最后一道序的时候,把daywork表的status设置为2
|
|
|
|
+ daywork.setStatus(2);
|
|
|
|
+ }
|
|
|
|
+ bizDayworkService.updateById(daywork);
|
|
|
|
+ //修改发出单报工合格数,投产数及折损率
|
|
|
|
+ BizOutsourcedOrderDetailProcess outsourcedOrderDetailProcess = bizOutsourcedOrderDetailProcessService.query().eq("daywork_id", bizDayworkItem.getDayworkId()).eq("process_step_number", bizDayworkItem.getProcessStepNumber()).one();
|
|
|
|
+ outsourcedOrderDetailProcess.setProductionNum(bizDayworkItem.getProdNum());
|
|
|
|
+ List<BizDayworkItem> currentDayworkItem = bizDayworkItemService.query().eq("daywork_id", bizDayworkItem.getDayworkId()).eq("process_step_number", bizDayworkItem.getProcessStepNumber()).in("status", Arrays.asList("2", "3")).list();
|
|
|
|
+ int sum = currentDayworkItem.stream().mapToInt(BizDayworkItem::getQualifiedNum).sum() + bizDayworkItem.getQualifiedNum();
|
|
|
|
+ outsourcedOrderDetailProcess.setQualifiedNum(sum);
|
|
|
|
+ float percent = ((outsourcedOrderDetailProcess.getProductionNum() - outsourcedOrderDetailProcess.getQualifiedNum()) / (float) outsourcedOrderDetailProcess.getProductionNum()) * 100;
|
|
|
|
+ outsourcedOrderDetailProcess.setLoss(BigDecimal.valueOf(percent));
|
|
|
|
+ outsourcedOrderDetailProcess.setStatus(1);
|
|
|
|
+ bizOutsourcedOrderDetailProcessService.updateById(outsourcedOrderDetailProcess);
|
|
|
|
+ }
|
|
|
|
+ //如果没有合格数,则投产数量为总数量,上道序的合格数为下到序的投产数
|
|
|
|
+ if (daywork.getProcessQualifiedNum() == 0) {
|
|
|
|
+ bizDayworkItem.setProdNum(daywork.getProductionQuantity());
|
|
|
|
+ } else {
|
|
|
|
+ bizDayworkItem.setProdNum(daywork.getProcessQualifiedNum());
|
|
|
|
+ }
|
|
|
|
+ // 现在等于4的时候就要能扫码开始批次,所以要设置一下部门pc查询计划单分配活
|
|
|
|
+// if(bizDayworkItem.getStatus().equals("4")){
|
|
|
|
+// daywork.setDeptId(bizDayworkItem.getDeptId());
|
|
|
|
+// bizDayworkService.updateById(daywork);
|
|
|
|
+// }
|
|
|
|
+ bizDayworkItem.setLotId(daywork.getLotId());
|
|
|
|
+ bizDayworkItem.setLotCode(daywork.getLotCode());
|
|
|
|
+ SysUser user = SecurityUtils.getLoginUser().getUser();
|
|
|
|
+ bizDayworkItem.setUserId(user.getUserId());
|
|
|
|
+ bizDayworkItem.setUserName(user.getUserName());
|
|
|
|
+ bizDayworkItem.setNickName(user.getNickName());
|
|
|
|
+ String[] statusArr = {"0", "4", "5", "7"};
|
|
|
|
+ if (Arrays.asList(statusArr).contains(bizDayworkItem.getStatus())) {
|
|
|
|
+ bizDayworkItem.setWorkingHours(0L);
|
|
|
|
+ } else {
|
|
|
|
+ bizDayworkItem.setWorkingHours(bizDayworkItem.getEndTime().getTime() - bizDayworkItem.getStartTime().getTime());
|
|
|
|
+ }
|
|
|
|
+ boolean batch = bizDayworkItemService.saveOrUpdate(bizDayworkItem);
|
|
|
|
+ //先保存item再保存废品原因
|
|
|
|
+ if ("2".equals(bizDayworkItem.getStatus()) || "3".equals(bizDayworkItem.getStatus())) {
|
|
|
|
+ for (BizDayworkItemReject item : bizDayworkItem.getRejectList()) {
|
|
|
|
+ item.setDayworkItemId(bizDayworkItem.getId());
|
|
|
|
+ item.setDayworkId(bizDayworkItem.getDayworkId());
|
|
|
|
+ item.setLotId(bizDayworkItem.getLotId());
|
|
|
|
+ item.setDeptId(bizDayworkItem.getDeptId());
|
|
|
|
+ item.setProcessId(bizDayworkItem.getProcessId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //保存箱数
|
|
|
|
+ List<BizDayworkItem>bizDayworkItems =new ArrayList<>();
|
|
|
|
+ bizDayworkItems.add(bizDayworkItem);
|
|
|
|
+ bizDayworkItemService.saveCarrierNum(bizDayworkItems);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
// 自动派活
|
|
// 自动派活
|
|
SysDept sysDept = sysDeptMapper.selectDeptById(bizDayworkItem.getDeptId());
|
|
SysDept sysDept = sysDeptMapper.selectDeptById(bizDayworkItem.getDeptId());
|
|
if (sysDept.getAutoAllocation() == 1) {
|
|
if (sysDept.getAutoAllocation() == 1) {
|
|
@@ -1097,7 +1292,14 @@ public class BizDayworkItemController extends BaseController {
|
|
public AjaxResult remove(@PathVariable List<Long> ids) {
|
|
public AjaxResult remove(@PathVariable List<Long> ids) {
|
|
return toAjax(bizDayworkItemService.removeBatchByIds(ids));
|
|
return toAjax(bizDayworkItemService.removeBatchByIds(ids));
|
|
}
|
|
}
|
|
- //修改周转信息
|
|
|
|
|
|
+ @PostMapping("/addEquipmentInfo")
|
|
|
|
+ @Log(title = "新增分选设备信息", businessType = BusinessType.SELECT)
|
|
|
|
+ public AjaxResult addEquipmentInfo(@RequestBody BizDayworkItem bizDayworkItem) {
|
|
|
|
+ bizDayworkItemService.updateById(bizDayworkItem);
|
|
|
|
+ return success();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //修改周转信息
|
|
@Transactional
|
|
@Transactional
|
|
@PutMapping("/updateTurnoverInfo")
|
|
@PutMapping("/updateTurnoverInfo")
|
|
@Log(title = "修改周转信息", businessType = BusinessType.INSERT)
|
|
@Log(title = "修改周转信息", businessType = BusinessType.INSERT)
|
|
@@ -1370,6 +1572,7 @@ public class BizDayworkItemController extends BaseController {
|
|
bizItem.setTurnoverId(bizDayworkItem.getTurnoverId());
|
|
bizItem.setTurnoverId(bizDayworkItem.getTurnoverId());
|
|
bizItem.setTurnoverType(bizDayworkItem.getTurnoverType());
|
|
bizItem.setTurnoverType(bizDayworkItem.getTurnoverType());
|
|
bizItem.setTurnoverArea(bizDayworkItem.getTurnoverArea());
|
|
bizItem.setTurnoverArea(bizDayworkItem.getTurnoverArea());
|
|
|
|
+ bizItem.setTenantId(bizDayworkItem.getTenantId());
|
|
bizItem.setPlaceId(bizDayworkItem.getPlaceId());
|
|
bizItem.setPlaceId(bizDayworkItem.getPlaceId());
|
|
bizItem.setPlace(bizDayworkItem.getPlace());
|
|
bizItem.setPlace(bizDayworkItem.getPlace());
|
|
bizItem.setProcessStepNumber(lastItem.getProcessStepNumber());
|
|
bizItem.setProcessStepNumber(lastItem.getProcessStepNumber());
|
|
@@ -1411,5 +1614,157 @@ public class BizDayworkItemController extends BaseController {
|
|
bizDayworkItemExamineService.saveBatch(needAddList);
|
|
bizDayworkItemExamineService.saveBatch(needAddList);
|
|
return toAjax(batch);
|
|
return toAjax(batch);
|
|
}
|
|
}
|
|
|
|
+ @Log(title="内部外协周转申请")
|
|
|
|
+ @Transactional
|
|
|
|
+ @PostMapping("/turnoverInner")
|
|
|
|
+ public AjaxResult turnoverInner(@RequestBody BizDayworkItem bizDayworkItem) throws NoSuchFieldException,IllegalAccessException {
|
|
|
|
+ //判断当前是否在盘点
|
|
|
|
+ BizTakeStockPeriod bizTakeStockPeriod = bizTakeStockPeriodService.query().eq("status",1).one();
|
|
|
|
+ if(bizTakeStockPeriod!=null && bizTakeStockPeriod.getStatus() == 1) {
|
|
|
|
+ return error("当前在盘点,禁止投产");
|
|
|
|
+ }
|
|
|
|
+ // 设置工时
|
|
|
|
+ // 获取箱子关联的所有批次
|
|
|
|
+ boolean batch = true;
|
|
|
|
+// bizDayworkItem.getCarrierId();
|
|
|
|
+ // 根据 daywork_item 中的 daywork_id,获取到所有未解绑的【daywork 与 箱子】的集合,通过这个集合,可以知道该批次下绑定了多少个箱子
|
|
|
|
+ List<BizDayworkCarrier> dayworkCarriers = bizDayworkCarrierService.query().eq("is_changed", 0).eq("process_inspection_id", 0L).eq("daywork_id", bizDayworkItem.getDayworkId()).list();
|
|
|
|
+ // 再根据上面获得到的数据,通过箱子的id(carrier_id),再进行查找,有多少个批次与该箱子绑定,这是因为存在一箱多批的情况。这样就获得到了所有的批次
|
|
|
|
+ List<BizDayworkCarrier> allCarries = bizDayworkCarrierService.query().eq("process_inspection_id", 0L).eq("is_changed", 0).in("carrier_id", dayworkCarriers.isEmpty() ? Collections.singletonList(0L) : dayworkCarriers.stream().map(BizDayworkCarrier::getCarrierId).collect(Collectors.toList())).list();
|
|
|
|
+
|
|
|
|
+ // 根据获取到的所有批次的id,查询出所有批次的报工信息,并且状态是【"0", "1", "2", "3"】,按状态值倒序、创建日期的倒序,对数据进行排序,得到的数据是还未周转的数据。
|
|
|
|
+ // 后续会通过该集合,获取某批次的最后一条报工信息
|
|
|
|
+ List<BizDayworkItem> bizDayworkItems = bizDayworkItemService.query().in("daywork_id", allCarries.isEmpty() ? Collections.singletonList(0L) : allCarries.stream().map(BizDayworkCarrier::getDayworkId).collect(Collectors.toList())).in("status", Arrays.asList("0", "1", "2", "3")).orderByDesc("status").orderByDesc("create_time").list();
|
|
|
|
+ List<BizDayworkItem> bizDayworkItemsAll = bizDayworkItemService.query().in("daywork_id", allCarries.isEmpty() ? Collections.singletonList(0L) : allCarries.stream().map(BizDayworkCarrier::getDayworkId).collect(Collectors.toList())).orderByDesc("create_time").list();
|
|
|
|
+ // 根据获取到的所有批次的id,查询出所有批次的报工信息,不需要判断状态
|
|
|
|
+ List<BizDayworkItem> bizDayworkItemList = bizDayworkItemService.query().in("daywork_id", allCarries.isEmpty() ? Collections.singletonList(0L) : allCarries.stream().map(BizDayworkCarrier::getDayworkId).collect(Collectors.toList())).list();
|
|
|
|
+ // 获取所有的 daywork 数据集合
|
|
|
|
+ List<BizDaywork> bizDayworks = bizDayworkService.query().in("id", allCarries.isEmpty() ? Collections.singletonList(0L) : allCarries.stream().map(BizDayworkCarrier::getDayworkId).collect(Collectors.toList())).list();
|
|
|
|
+ //获取周转工段的周转区
|
|
|
|
+ List<BizTurnover> turnoverList = bizTurnoverService.query().eq("dept_id", bizDayworkItem.getDeptId()).eq("status", 9).list();
|
|
|
|
+ // 遍历 daywork 数据集合
|
|
|
|
+ for (BizDaywork v : bizDayworks) {
|
|
|
|
+ // 获取该批次的最后一条报工
|
|
|
|
+ BizDayworkItem lastItem = bizDayworkItems.stream().filter(l -> l.getDayworkId().equals(v.getId())).findFirst().orElse(null);
|
|
|
|
+ //批次所有报工,判断是否已经周转了,如果周转返回报错信息
|
|
|
|
+ BizDayworkItem lastItemAll = bizDayworkItemsAll.stream().filter(l -> l.getDayworkId().equals(v.getId())).findFirst().orElse(null);
|
|
|
|
+ //为了防止该工序已经周转到下一道序,且已经干了,所以判断如果当前processStepNumber和最新一条的步骤是否相同
|
|
|
|
+ if(lastItemAll != null && (!lastItemAll.getProcessStepNumber().equals(bizDayworkItem.getProcessStepNumber()) || (lastItemAll.getStatus().equals("4") || lastItemAll.getStatus().equals("5") || lastItemAll.getStatus().equals("7")))) {
|
|
|
|
+ return error( v.getLotCode()+"批次已周转,请勿重复操作");
|
|
|
|
+ }
|
|
|
|
+ // 如果最后一条报工信息存在,并且报工状态为:3,则说明该报工已经工序完成
|
|
|
|
+ if (lastItem != null && lastItem.getStatus().equals("3")) {
|
|
|
|
+ // 根据当前批次的id,获取该批次下的工序id与最后一条报工的工序id相同的所有报工信息
|
|
|
|
+ // 因为同一工序可能存在多次报工,所以需要获取该批次下,该工序的所有报工信息,后续会进行合格数的统计
|
|
|
|
+ List<BizDayworkItem> allItem = bizDayworkItemList.stream().filter(l -> l.getDayworkId().equals(v.getId()) && l.getTechnologicalProcessDetailId().equals(lastItem.getTechnologicalProcessDetailId())).collect(Collectors.toList());
|
|
|
|
+ // 根据获得到的某工序的报工信息,进行合格数统计
|
|
|
|
+ Integer lot = allItem.stream().mapToInt(BizDayworkItem::getQualifiedNum).sum();
|
|
|
|
+
|
|
|
|
+ // 实例化一个报工信息对象,用于保存【周转】的报工记录
|
|
|
|
+ BizDayworkItem bizItem = new BizDayworkItem();
|
|
|
|
+ bizItem.setDayworkId(lastItem.getDayworkId());
|
|
|
|
+ bizItem.setProcessId(lastItem.getProcessId());
|
|
|
|
+ bizItem.setTechnologicalProcessDetailId(lastItem.getTechnologicalProcessDetailId());
|
|
|
|
+ bizItem.setStatus(bizDayworkItem.getStatus());
|
|
|
|
+ bizItem.setFromDeptId(lastItem.getDeptId());
|
|
|
|
+ bizItem.setFromDeptName(lastItem.getDeptName());
|
|
|
|
+ bizItem.setOutsourceDetailId(lastItem.getOutsourceDetailId());
|
|
|
|
+ // 如果报工状态为:7(已送达)或者4(待周转),则需要设置对应的daywork的当前部门id,以及合格数
|
|
|
|
+ // 这里的状态值4/7,是由前端传递过来的。
|
|
|
|
+ if (bizDayworkItem.getStatus().equals("7") || bizDayworkItem.getStatus().equals("4")) {
|
|
|
|
+ v.setDeptId(bizDayworkItem.getDeptId());
|
|
|
|
+ int sum = bizDayworkItems.stream()
|
|
|
|
+ .filter(l -> l.getProcessStepNumber().equals(bizDayworkItem.getProcessStepNumber()))
|
|
|
|
+ .mapToInt(BizDayworkItem::getQualifiedNum) // 假设 getNum 返回一个 int 类型的值
|
|
|
|
+ .sum();
|
|
|
|
+ v.setTemporaryProcessQualifiedNum(sum);
|
|
|
|
+ bizDayworkService.updateById(v);
|
|
|
|
+ }
|
|
|
|
+ // 周转后如果是车间内的,状态为7,则需要从当前资源组中删除被邀请人
|
|
|
|
+ if(bizDayworkItem.getStatus().equals("7") || bizDayworkItem.getStatus().equals("5")) {
|
|
|
|
+ v.setProtemProcessId(lastItem.getProcessId());
|
|
|
|
+ v.setProtemProcessStepNumber(lastItem.getProcessStepNumber());
|
|
|
|
+ // 如果被邀请人不是本工段内的人,则需要从当前资源组中删除被邀请人
|
|
|
|
+ bizProductionResourceGroupDetailService.deleTemporanyPeople(v);
|
|
|
|
+ }
|
|
|
|
+ // 如果是单批单改换,则设置form_daywork_item_id为1,表示没有原来的报工
|
|
|
|
+ if(v.getIsAmend()==1){
|
|
|
|
+ bizItem.setFormDayworkItemId(1L);
|
|
|
|
+ }
|
|
|
|
+ bizItem.setLotId(v.getLotId());
|
|
|
|
+ bizItem.setLotCode(v.getLotCode());
|
|
|
|
+ SysUser user = SecurityUtils.getLoginUser().getUser();
|
|
|
|
+ bizItem.setUserId(user.getUserId());
|
|
|
|
+ bizItem.setUserName(user.getUserName());
|
|
|
|
+ bizItem.setNickName(user.getNickName());
|
|
|
|
+ bizItem.setIsSpecial(lastItem.getIsSpecial());
|
|
|
|
+ bizItem.setSpecialIsFirst(lastItem.getSpecialIsFirst());
|
|
|
|
+ bizItem.setWorkingHours(0L);
|
|
|
|
+ bizItem.setDeptId(lastItem.getDeptId());
|
|
|
|
+ bizItem.setTenantId(lastItem.getTenantId());
|
|
|
|
+ bizItem.setProductionPlanDetailId(lastItem.getProductionPlanDetailId());
|
|
|
|
+ bizItem.setProductionPlanId(lastItem.getProductionPlanId());
|
|
|
|
+ bizItem.setProductionPlanDetailSubDetailId(lastItem.getProductionPlanDetailSubDetailId());
|
|
|
|
+ bizItem.setProductionPlanDetailSubDetailEquipmentId(lastItem.getProductionPlanDetailSubDetailEquipmentId());
|
|
|
|
+ bizItem.setQualifiedNum(lot);
|
|
|
|
+ bizItem.setTechnologicalProcessId(lastItem.getTechnologicalProcessId());
|
|
|
|
+ bizItem.setProdNum(lot);
|
|
|
|
+ bizItem.setEquipmentDetailId(lastItem.getEquipmentDetailId());
|
|
|
|
+ bizItem.setEquipmentDetailCode(lastItem.getEquipmentDetailCode());
|
|
|
|
+ bizItem.setIsSort(lastItem.getIsSort());
|
|
|
|
+ bizItem.setDeptId(bizDayworkItem.getDeptId());
|
|
|
|
+ bizItem.setDeptName(bizDayworkItem.getDeptName());
|
|
|
|
+ bizItem.setStartTime(bizDayworkItem.getStartTime());
|
|
|
|
+ bizItem.setTurnoverId(bizDayworkItem.getTurnoverId());
|
|
|
|
+ bizItem.setTurnoverType(bizDayworkItem.getTurnoverType());
|
|
|
|
+ bizItem.setTurnoverArea(bizDayworkItem.getTurnoverArea());
|
|
|
|
+ bizItem.setTenantId(bizDayworkItem.getTenantId());
|
|
|
|
+ if(bizDayworkItem.getPlaceId()==null){
|
|
|
|
+ bizItem.setPlaceId(turnoverList.stream().map(BizTurnover::getId).map(String::valueOf).collect(Collectors.joining("、")));
|
|
|
|
+ bizItem.setPlace(turnoverList.stream().map(BizTurnover::getCode).collect(Collectors.joining("、")));
|
|
|
|
+ }else{
|
|
|
|
+ bizItem.setPlaceId(bizDayworkItem.getPlaceId());
|
|
|
|
+ bizItem.setPlace(bizDayworkItem.getPlace());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ bizItem.setProcessStepNumber(lastItem.getProcessStepNumber());
|
|
|
|
+ bizItem.setOutsourceDetailId(lastItem.getOutsourceDetailId());
|
|
|
|
+ bizItem.setIsWx(1);
|
|
|
|
+ batch = batch && bizDayworkItemService.saveOrUpdate(bizItem);
|
|
|
|
+ // 自动派活
|
|
|
|
+ SysDept sysDept = sysDeptMapper.selectDeptById(bizDayworkItem.getDeptId());
|
|
|
|
+ if (sysDept.getAutoAllocation() == 1) {
|
|
|
|
+ // 查资源组
|
|
|
|
+ List<BizProductionResourceGroup> productionResourceGroupList = bizProductionResourceGroupService.list(new QueryWrapper<BizProductionResourceGroup>().eq("dept_id", bizDayworkItem.getDeptId()).eq("is_deactivate", 0));
|
|
|
|
+
|
|
|
|
+ //查询是否已经分配资源组
|
|
|
|
+ BizProductionResourceGroupSubPlan groupSubPlan=new BizProductionResourceGroupSubPlan();
|
|
|
|
+ groupSubPlan.setDeptId(bizDayworkItem.getDeptId());
|
|
|
|
+ groupSubPlan.setProductionPlanDetailId(bizDayworkItem.getProductionPlanDetailId());
|
|
|
|
+
|
|
|
|
+ List<BizProductionResourceGroupSubPlan> groupSubPlanList = bizProductionResourceGroupSubPlanService.getAotList(groupSubPlan);
|
|
|
|
+ //如果没分配
|
|
|
|
+ if(groupSubPlanList.isEmpty()){
|
|
|
|
+ //查产品id
|
|
|
|
+ BizProductionPlanDetail productionPlanDetail = bizProductionPlanDetailService.getOne(new QueryWrapper<BizProductionPlanDetail>().eq("id", bizDayworkItem.getProductionPlanDetailId()));
|
|
|
|
+ //存放保存的subPlanList
|
|
|
|
+ List<BizProductionResourceGroupSubPlan> subPlanList = new ArrayList<>();
|
|
|
|
+ for (BizProductionResourceGroup info : productionResourceGroupList) {
|
|
|
|
+ BizProductionResourceGroupSubPlan subPlan = new BizProductionResourceGroupSubPlan();
|
|
|
|
+ subPlan.setProductId(productionPlanDetail.getProductId());
|
|
|
|
+ subPlan.setProductionPlanDetailId(v.getProductionPlanDetailId());
|
|
|
|
+ subPlan.setTechnologicalProcessId(v.getTechnologicalProcessId());
|
|
|
|
+ subPlan.setResourceGroupId(info.getId());
|
|
|
|
+ subPlan.setDeptId(bizDayworkItem.getDeptId());
|
|
|
|
+ subPlan.setResourceGroupCode(info.getCode());
|
|
|
|
+ subPlanList.add(subPlan);
|
|
|
|
+ }
|
|
|
|
+ bizProductionResourceGroupSubPlanService.saveBatch(subPlanList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return toAjax(batch);
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|