|
@@ -1,19 +1,31 @@
|
|
|
package com.zkqy.amichi.service.impl;
|
|
|
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
-import com.zkqy.amichi.domain.ProductionPlanningManagement;
|
|
|
-import com.zkqy.amichi.domain.ReportInformationSheet;
|
|
|
+import cn.hutool.core.date.DateTime;
|
|
|
+import com.zkqy.amichi.domain.*;
|
|
|
+import com.zkqy.amichi.mapper.ExceptionReportInformationSheetMapper;
|
|
|
import com.zkqy.amichi.mapper.ProductionPlanningManagementMapper;
|
|
|
import com.zkqy.amichi.mapper.ReportInformationSheetMapper;
|
|
|
+import com.zkqy.amichi.utils.WarehouseEntryNumberGenerator;
|
|
|
import com.zkqy.common.annotation.Log;
|
|
|
import com.zkqy.common.core.domain.AjaxResult;
|
|
|
import com.zkqy.common.utils.DateUtils;
|
|
|
import com.zkqy.common.utils.SecurityUtils;
|
|
|
+import com.zkqy.execution.produce.dispersed.controller.BpmExecuteNodeController;
|
|
|
+import com.zkqy.execution.produce.dispersed.entity.BpmExecuteNodeLog;
|
|
|
+import com.zkqy.execution.produce.dispersed.entity.BpmExecuteProcess;
|
|
|
+import com.zkqy.execution.produce.dispersed.mapper.BpmExecuteNodeLogMapper;
|
|
|
+import com.zkqy.execution.produce.dispersed.mapper.BpmExecuteProcessMapper;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.zkqy.amichi.mapper.StationInformationMapper;
|
|
|
-import com.zkqy.amichi.domain.StationInformation;
|
|
|
import com.zkqy.amichi.service.IStationInformationService;
|
|
|
|
|
|
/**
|
|
@@ -30,9 +42,20 @@ public class StationInformationServiceImpl implements IStationInformationService
|
|
|
@Autowired
|
|
|
private ReportInformationSheetMapper reportInformationSheetMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ExceptionReportInformationSheetMapper exceptionReportInformationSheetMapper;
|
|
|
+
|
|
|
@Autowired
|
|
|
private ProductionPlanningManagementMapper productionPlanningManagementMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private BpmExecuteProcessMapper bpmExecuteProcessMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private BpmExecuteNodeLogMapper bpmExecuteNodeLogMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PlanTaskDetailsServiceImpl planTaskDetailsService;
|
|
|
|
|
|
/**
|
|
|
* 查询工位信息
|
|
@@ -108,31 +131,64 @@ public class StationInformationServiceImpl implements IStationInformationService
|
|
|
return stationInformationMapper.deleteStationInformationById(id);
|
|
|
}
|
|
|
|
|
|
+ @Autowired
|
|
|
+ WarehouseEntryNumberGenerator warehouseEntryNumberGenerator;
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public String stationProductScanning(String contentString) {
|
|
|
try {
|
|
|
- if(contentString.contains("scan@")){//这个是工位码扫描逻辑
|
|
|
+ if (contentString.contains("scan@")) {//这个是工位码扫描逻辑
|
|
|
String[] content = contentString.split("&");
|
|
|
//更改当前工位码的设备信息
|
|
|
- StationInformation stationInformation=new StationInformation();
|
|
|
+ StationInformation stationInformation = new StationInformation();
|
|
|
stationInformation.setDeviceName(content[2]);//设备信息
|
|
|
//查询当前设备是否已经绑定了工位信息
|
|
|
List<StationInformation> stationInformations = stationInformationMapper.selectStationInformationList(stationInformation);
|
|
|
- if(stationInformations.size()>0){ //更新原先绑定的工位信息为空
|
|
|
+ if (stationInformations.size() > 0) { //更新原先绑定的工位信息为空
|
|
|
stationInformation.setDeviceName("");//设备信息
|
|
|
+ stationInformation.setTeamCode("");//班组码信息
|
|
|
stationInformation.setStationCode(stationInformations.get(0).getStationCode());//工位码信息
|
|
|
stationInformationMapper.updateStationInformationByStationUpdateEquipment(stationInformation);
|
|
|
}
|
|
|
stationInformation.setDeviceName(content[2]);//设备信息
|
|
|
stationInformation.setStationCode(content[1]);//工位码
|
|
|
int i = stationInformationMapper.updateStationInformationByStationUpdateEquipment(stationInformation);
|
|
|
- return "工位信息绑定成功";
|
|
|
- }else{ //产品扫描逻辑
|
|
|
+ return "手持机工位信息绑定成功";
|
|
|
+ } else if (contentString.contains("team@")){
|
|
|
+ String[] content = contentString.split("&");
|
|
|
+ //扫工位码之前先判断你当前手持机扫没扫过工位码信息
|
|
|
+ StationInformation stationInformationByDeviceName=new StationInformation();
|
|
|
+ stationInformationByDeviceName.setDeviceName(content[2]);//手持机标识
|
|
|
+ List<StationInformation> stationInformationsByDeviceName = stationInformationMapper.selectStationInformationList(stationInformationByDeviceName);
|
|
|
+ if(stationInformationsByDeviceName.size()<=0){
|
|
|
+ return "请先用当前手持先扫工位码";
|
|
|
+ }
|
|
|
+ //先查询当前班组码有没有在其他工位上有就先给他清空
|
|
|
+ StationInformation stationInformation=new StationInformation();
|
|
|
+ stationInformation.setTeamCode(content[1]);//班组码信息
|
|
|
+ List<StationInformation> stationInformations = stationInformationMapper.selectStationInformationList(stationInformation);
|
|
|
+ if (stationInformations.size() > 0) { //更新原先绑定的工位信息为空
|
|
|
+ stationInformation.setTeamName("");//班组码信息
|
|
|
+ stationInformation.setStationCode(stationInformations.get(0).getStationCode());//工位码信息
|
|
|
+ stationInformationMapper.updateStationInformationByStationUpdateEquipment(stationInformation);
|
|
|
+ }
|
|
|
+ stationInformation.setTeamCode(content[1]);//班组码
|
|
|
+ stationInformation.setDeviceName(content[2]);//手持机码
|
|
|
+ int i = stationInformationMapper.updateStationInformationByStationUpdateByDeviceName(stationInformation);
|
|
|
+
|
|
|
+ List<StationInformation> stationInformationsTwo = stationInformationMapper.selectStationInformationList(stationInformation);
|
|
|
+ //拿到工位id
|
|
|
+ StationInformation stationInformation1 = stationInformationsTwo.get(0);
|
|
|
+ return "工位:"+stationInformation1.getStationName()+" 班组:"+stationInformation1.getTeamName();
|
|
|
+ }
|
|
|
+ else{ //产品扫描逻辑
|
|
|
String[] content = contentString.split("&");
|
|
|
StationInformation stationInformation=new StationInformation();
|
|
|
stationInformation.setDeviceName(content[1]);//设备名称
|
|
|
- //插入节点产品运行日志信息
|
|
|
+ //查询工位信息表
|
|
|
List<StationInformation> stationInformations = stationInformationMapper.selectStationInformationList(stationInformation);
|
|
|
+ //节点.
|
|
|
if(stationInformations.size()>0){
|
|
|
StationInformation stationInformation1 = stationInformations.get(0);//根据手持机设备名称得到工位信息
|
|
|
ReportInformationSheet reportInformationSheet=new ReportInformationSheet();
|
|
@@ -140,34 +196,159 @@ public class StationInformationServiceImpl implements IStationInformationService
|
|
|
reportInformationSheet.setStationCode(stationInformation1.getStationCode());//工位码
|
|
|
reportInformationSheet.setProcess(stationInformation1.getStationName());//工序名称
|
|
|
reportInformationSheet.setProductCode(content[0]);//产品码
|
|
|
+ reportInformationSheet.setHandheldDevice(content[1]);//手持机
|
|
|
+ reportInformationSheet.setCreateTime(new DateTime());//创建时间
|
|
|
//推算出来产品编号或者订单编号
|
|
|
String modifiedString = "DQY" + content[0].substring(0, content[0].length() - 3);
|
|
|
reportInformationSheet.setOrderNumber(modifiedString);//订单号或任务号
|
|
|
//更新节点生产数量
|
|
|
//先拿到当前任务数量
|
|
|
List<ProductionPlanningManagement> productionPlanningManagements = productionPlanningManagementMapper.selectProductionPlanningManagementByOrderNumebrOrPlanNumber(modifiedString, modifiedString);
|
|
|
- if(productionPlanningManagements.size()<0){
|
|
|
- return "未找到当前产品计划报工失败";
|
|
|
+ if(productionPlanningManagements.size()<=0){
|
|
|
+ //插入异常报工信息
|
|
|
+ extracted(reportInformationSheet,"未找到当前产品计划报工失败--信息不匹配");
|
|
|
+ return "未找到当前产品计划报工失败--信息不匹配";
|
|
|
}else {
|
|
|
- //找到计划了先确认下数量
|
|
|
- ProductionPlanningManagement productionPlanningManagement = productionPlanningManagements.get(0);
|
|
|
- //拿到数量
|
|
|
- String quantity = productionPlanningManagement.getQuantity();
|
|
|
- //拿到计划id------->根据计划id查询流程信息
|
|
|
+ boolean equals = productionPlanningManagements.get(0).getPlanType().equals("3");
|
|
|
+ if(equals){
|
|
|
+ //插入异常报工信息
|
|
|
+ extracted(reportInformationSheet,"该计划已经完成--信息不匹配");
|
|
|
+ return "该计划已经完成--信息不匹配";
|
|
|
+ }else {
|
|
|
+ //找到计划了先确认下数量(我计划下的数量)
|
|
|
+ ProductionPlanningManagement productionPlanningManagement = productionPlanningManagements.get(0);
|
|
|
+ //拿到计划id------->根据计划id查询流程信息
|
|
|
+ BpmExecuteProcess process=new BpmExecuteProcess();
|
|
|
+ process.setTaskPlanKey(productionPlanningManagement.getId().toString());//计划id
|
|
|
+ List<BpmExecuteProcess> bpmExecuteProcesses = bpmExecuteProcessMapper.selectBpmExecuteProcessListfjqy(process);
|
|
|
+ if(bpmExecuteProcesses.size()<=0){
|
|
|
+ //插入异常报工信息
|
|
|
+ extracted(reportInformationSheet,"没有找到当前计划的流程管道--信息不匹配");
|
|
|
+ return "没有找到当前计划的流程管道--信息不匹配";
|
|
|
+ }else {
|
|
|
+ //管道
|
|
|
+ String taskKey = bpmExecuteProcesses.get(0).getTaskKey();
|
|
|
+ BpmExecuteNodeLog bpmExecuteNodeLog=new BpmExecuteNodeLog();
|
|
|
+ bpmExecuteNodeLog.setTaskProcessKey(taskKey);//流程编号
|
|
|
+ bpmExecuteNodeLog.setTaskNodeName(stationInformation1.getStationName());//工序名称
|
|
|
+ List<BpmExecuteNodeLog> bpmExecuteNodeLogs = bpmExecuteNodeLogMapper.selectBpmExecuteNodeLogListfjqy(bpmExecuteNodeLog);
|
|
|
+ String taskNodeNumber = bpmExecuteNodeLogs.get(0).getTaskNodeNumber();//节点数量
|
|
|
+ //判断你当前报工工序节点是否已经报够数量了
|
|
|
+ if(taskNodeNumber==null||taskNodeNumber.equals("")){
|
|
|
+ taskNodeNumber="0";
|
|
|
+ }
|
|
|
+ if(Integer.parseInt(taskNodeNumber)>=Integer.parseInt(productionPlanningManagement.getQuantity())){
|
|
|
+ //插入异常报工信息
|
|
|
+ extracted(reportInformationSheet,"当前工序已完成计划数量");
|
|
|
+ return "当前工序已完成计划数量";
|
|
|
+ }else {
|
|
|
+ //否则更新接单已完成数量
|
|
|
+ int i = Math.addExact(Integer.parseInt(taskNodeNumber), 1);
|
|
|
+ BpmExecuteNodeLog upBpmExecuteNodeLog=new BpmExecuteNodeLog();
|
|
|
+ upBpmExecuteNodeLog.setTaskNodeNumber(String.valueOf(i));//更新数量
|
|
|
+ upBpmExecuteNodeLog.setId(bpmExecuteNodeLogs.get(0).getId());//节点日志id
|
|
|
+ //判断同一部手持机扫描时间间隔是否超过一分钟
|
|
|
+ ReportInformationSheet sheetsjjg=new ReportInformationSheet();
|
|
|
+ sheetsjjg.setProcess(stationInformation1.getStationName());//工序
|
|
|
+ sheetsjjg.setHandheldDevice(content[2]);//设备信息
|
|
|
+ ReportInformationSheet reportInformationSheetsSc = reportInformationSheetMapper.selectReportInformationSheetListOrderBy(sheetsjjg);
|
|
|
+ Date date1 = reportInformationSheetsSc.getCreateTime(); //上次扫码时间
|
|
|
+ Date date2 = new Date();//当前时间
|
|
|
+ String s = DateUtils.timeDistanceMin(date2, date1);
|
|
|
+ if(Integer.parseInt(s)<1){
|
|
|
+ //插入异常报工信息
|
|
|
+ extracted(reportInformationSheet,"两次扫码之间的间隔不能小于1分钟");//???? 看看那个小工人有这个坏心思
|
|
|
+ return "两次扫码之间的间隔不能小于1分钟";
|
|
|
+ }
|
|
|
+ //工序--产品重复扫描
|
|
|
+ ReportInformationSheet reportInformationSheet1=new ReportInformationSheet();
|
|
|
+ reportInformationSheet1.setProcess(stationInformation1.getStationName());//工序名称
|
|
|
+ reportInformationSheet1.setProductCode(stationInformation1.getStationName());//产品码
|
|
|
+ List<ReportInformationSheet> reportInformationSheets = reportInformationSheetMapper.selectReportInformationSheetList(reportInformationSheet1);
|
|
|
+ if(reportInformationSheets.size()>0){
|
|
|
+ //插入异常报工信息
|
|
|
+ extracted(reportInformationSheet,"产品不能重复扫描");
|
|
|
+ return "产品不能重复扫描";
|
|
|
+ }
|
|
|
|
|
|
+ //当前产品只能被下一个工序进行扫描
|
|
|
+ //查询当前计划的所有工序信息
|
|
|
+ BpmExecuteNodeLog bpmExecuteNodeLogString=new BpmExecuteNodeLog();
|
|
|
+ bpmExecuteNodeLog.setTaskProcessKey(taskKey);//流程编号
|
|
|
+ List<BpmExecuteNodeLog> bpmExecuteNodeLogsString = bpmExecuteNodeLogMapper.selectBpmExecuteNodeLogListfjqy(bpmExecuteNodeLogString);
|
|
|
+ List<String> collect = bpmExecuteNodeLogsString.stream().map(BpmExecuteNodeLog::getTaskNodeName).collect(Collectors.toList());
|
|
|
+ //所有的集合我拿到了
|
|
|
+ ReportInformationSheet reportInformationSheet1String=new ReportInformationSheet();
|
|
|
+ reportInformationSheet1String.setProductCode(stationInformation1.getStationName());//产品码
|
|
|
+ List<ReportInformationSheet> reportInformationSheetsString = reportInformationSheetMapper.selectReportInformationSheetList(reportInformationSheet1String);
|
|
|
+ ReportInformationSheet reportInformationSheet2 = reportInformationSheetsString.get(0);
|
|
|
+ String process1 = reportInformationSheet2.getProcess();//这个产品编码上一次是那个工序扫的?
|
|
|
+ int nextIndex=0;
|
|
|
+ for (int i1 = 0; i1 < collect.size(); i1++) {
|
|
|
+ //如果工序名称相同
|
|
|
+ if(collect.get(i1).equals(process1)){
|
|
|
+ nextIndex=i1+1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //说明已经在最后一个节点了,你前边的手持工序在怎么扫都扫不上的
|
|
|
+ if(nextIndex>=collect.size()){
|
|
|
+ //插入异常报工信息
|
|
|
+ extracted(reportInformationSheet,"请选择对应工序的手持机进行扫描");
|
|
|
+ return "请选择对应工序的手持机进行扫描";
|
|
|
+ }else {
|
|
|
+ if(!stationInformation1.getStationName().equals(collect.get(nextIndex))){
|
|
|
+ //插入异常报工信息
|
|
|
+ extracted(reportInformationSheet,"请选择当前产品对应的工序信息进行扫描");
|
|
|
+ return "请选择当前产品对应的工序信息进行扫描";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //当前工序有没有漏扫
|
|
|
+ int result = Math.subtractExact(Integer.parseInt(stationInformation1.getStationName()), 1);
|
|
|
+ reportInformationSheet1.setProductCode(String.valueOf(result));//产品码
|
|
|
+ List<ReportInformationSheet> reportInformationSheetsLS = reportInformationSheetMapper.selectReportInformationSheetList(reportInformationSheet1);
|
|
|
+ if(reportInformationSheetsLS.size()>0){
|
|
|
+ //插入异常报工信息
|
|
|
+ extracted(reportInformationSheet,"当前工序漏扫了一个产品信息--请核对信息");
|
|
|
+ return "当前工序漏扫了一个产品信息--请核对信息";
|
|
|
+ }
|
|
|
+ //根据工位码查询 ---->节点报工日志
|
|
|
+ reportInformationSheetMapper.insertReportInformationSheet(reportInformationSheet);
|
|
|
+ int i1 = bpmExecuteNodeLogMapper.updateBpmExecuteNodeLogfjqy(upBpmExecuteNodeLog);
|
|
|
+ //更新当前工序节点信息
|
|
|
+ if(i1 >0){
|
|
|
+ return "产品信息扫描成功";
|
|
|
+ }else {
|
|
|
+ extracted(reportInformationSheet,"更新节点管道工序任务数量失败");
|
|
|
+ return "扫码报工失败";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- //根据工位码查询
|
|
|
- int i = reportInformationSheetMapper.insertReportInformationSheet(reportInformationSheet);
|
|
|
- return "产品信息扫描成功";
|
|
|
}else{
|
|
|
return "当前设备未绑定工位信息";
|
|
|
}
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
+ System.out.println(
|
|
|
+ e.getMessage()
|
|
|
+ );
|
|
|
return "扫描失败";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 插入异常报工信息
|
|
|
+ * @param reportInformationSheet
|
|
|
+ * @param msg
|
|
|
+ */
|
|
|
+ private void extracted(ReportInformationSheet reportInformationSheet,String msg) {
|
|
|
+ ExceptionReportInformationSheet exceptionReportInformationSheet = new ExceptionReportInformationSheet();
|
|
|
+ BeanUtils.copyProperties(reportInformationSheet, exceptionReportInformationSheet);
|
|
|
+ exceptionReportInformationSheet.setExceptionMessage(msg);
|
|
|
+ exceptionReportInformationSheetMapper.insertExceptionReportInformationSheet(exceptionReportInformationSheet);
|
|
|
+ }
|
|
|
+
|
|
|
public static void main(String[] args) {
|
|
|
String aaa="scan@&GWM-001&SMSB001";
|
|
|
boolean contains = aaa.contains("scan@");
|