|
@@ -0,0 +1,3040 @@
|
|
|
+package com.zkqy.amichi.service.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.date.DateTime;
|
|
|
+import cn.hutool.core.util.CharsetUtil;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.crypto.symmetric.SymmetricAlgorithm;
|
|
|
+import cn.hutool.crypto.symmetric.SymmetricCrypto;
|
|
|
+import com.alibaba.fastjson2.JSON;
|
|
|
+import com.alibaba.fastjson2.JSONArray;
|
|
|
+import com.alibaba.fastjson2.JSONObject;
|
|
|
+import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
+import com.kingdee.bos.webapi.sdk.K3CloudApi;
|
|
|
+import com.zkqy.amichi.domain.*;
|
|
|
+import com.zkqy.amichi.domain.vo.ScanStatistics;
|
|
|
+import com.zkqy.amichi.domain.vo.StationProductScanningRingVo;
|
|
|
+import com.zkqy.amichi.jd.domain.JdProductionOrder;
|
|
|
+import com.zkqy.amichi.jd.domain.MaterialRetentionLogVo;
|
|
|
+import com.zkqy.amichi.mapper.*;
|
|
|
+import com.zkqy.amichi.service.IStationInformationService;
|
|
|
+import com.zkqy.amichi.service.RkService;
|
|
|
+import com.zkqy.amichi.utils.WarehouseEntryNumberGenerator;
|
|
|
+import com.zkqy.common.core.domain.entity.SysTenant;
|
|
|
+import com.zkqy.common.utils.DateUtils;
|
|
|
+import com.zkqy.common.utils.StringUtils;
|
|
|
+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 com.zkqy.framework.web.service.SysLoginService;
|
|
|
+import com.zkqy.system.mapper.SysDictDataMapper;
|
|
|
+import com.zkqy.system.mapper.SysTenantMapper;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.core.io.Resource;
|
|
|
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
+
|
|
|
+import java.io.IOException;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.ZoneOffset;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * 工位信息Service业务层处理
|
|
|
+ *
|
|
|
+ * @author zkqy
|
|
|
+ * @date 2024-08-20
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class StationInformationServiceImpl implements IStationInformationService
|
|
|
+{
|
|
|
+ @Autowired
|
|
|
+ private StationInformationMapper stationInformationMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ReportInformationSheetMapper reportInformationSheetMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExceptionReportInformationSheetMapper exceptionReportInformationSheetMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ProductionPlanningManagementMapper productionPlanningManagementMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private BpmExecuteProcessMapper bpmExecuteProcessMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private BpmExecuteNodeLogMapper bpmExecuteNodeLogMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PlanTaskDetailsServiceImpl planTaskDetailsService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ProductionCardFlowMapper productionCardFlowMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private RingScanInformationMapper ringScanInformationMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TerminalInformationMapper terminalInformationMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MaterialRetentionLogMapper materialRetentionLogMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private RingScanInformationFirstMapper ringScanInformationFirstMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private RingTerminalMapper ringTerminalMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private RingScanInformationProdOrderScanningMapper prodOrderScanningMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PlanTaskDetailsMapper planTaskDetailsMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ProcedureListErpMapper procedureListErpMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ProcedureListMapper procedureListMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ThreadPoolTaskExecutor threadPoolTaskExecutor;
|
|
|
+
|
|
|
+ @Value("classpath:processReport.json")
|
|
|
+ private Resource processReport;
|
|
|
+
|
|
|
+
|
|
|
+ @Value("classpath:storage.json")
|
|
|
+ private Resource storage;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ SysDictDataMapper dictDataMapper;
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ WarehouseEntryNumberGenerator warehouseEntryNumberGenerator;
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ProductionReportingRecordMapper productionReportingRecordMapper;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询工位信息
|
|
|
+ * @param id 工位信息主键
|
|
|
+ * @return 工位信息
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public StationInformation selectStationInformationById(Long id)
|
|
|
+ {
|
|
|
+ return stationInformationMapper.selectStationInformationById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询工位信息列表
|
|
|
+ *
|
|
|
+ * @param stationInformation 工位信息
|
|
|
+ * @return 工位信息
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<StationInformation> selectStationInformationList(StationInformation stationInformation)
|
|
|
+ {
|
|
|
+ return stationInformationMapper.selectStationInformationList(stationInformation);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增工位信息
|
|
|
+ *
|
|
|
+ * @param stationInformation 工位信息
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public int insertStationInformation(StationInformation stationInformation)
|
|
|
+ {
|
|
|
+ stationInformation.setCreateTime(DateUtils.getNowDate());
|
|
|
+ return stationInformationMapper.insertStationInformation(stationInformation);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改工位信息
|
|
|
+ *
|
|
|
+ * @param stationInformation 工位信息
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public int updateStationInformation(StationInformation stationInformation)
|
|
|
+ {
|
|
|
+ stationInformation.setUpdateTime(DateUtils.getNowDate());
|
|
|
+ return stationInformationMapper.updateStationInformation(stationInformation);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量删除工位信息
|
|
|
+ *
|
|
|
+ * @param ids 需要删除的工位信息主键
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public int deleteStationInformationByIds(Long[] ids)
|
|
|
+ {
|
|
|
+ return stationInformationMapper.deleteStationInformationByIds(ids);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除工位信息信息
|
|
|
+ *
|
|
|
+ * @param id 工位信息主键
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public int deleteStationInformationById(Long id)
|
|
|
+ {
|
|
|
+ return stationInformationMapper.deleteStationInformationById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SysLoginService loginService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SysTenantMapper sysTenantMapper;
|
|
|
+ /**
|
|
|
+ * 手持扫描真实逻辑
|
|
|
+ * @param contentString
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public String stationProductScanningTwo2(String contentString) throws Exception {
|
|
|
+ //abc
|
|
|
+ SysTenant sysTenant = sysTenantMapper.selectSysTenantByTenantId(216L);
|
|
|
+ //检查租户过期时间
|
|
|
+ if (sysTenant.getTenantExpirationTime() == null || sysTenant.getTenantExpirationTime().isEmpty()) {
|
|
|
+ return "未激活-系统-扫描失败-0-0-0-0";
|
|
|
+ }
|
|
|
+ SymmetricCrypto symmetricCrypto = new SymmetricCrypto(SymmetricAlgorithm.DES, "sgEsnN6QWq8W7j5H01020304".getBytes());
|
|
|
+ //当前时间
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+ long nowSecond = now.toEpochSecond(ZoneOffset.ofHours(8));
|
|
|
+ //到期时间
|
|
|
+ String LastActiveTimeStr = symmetricCrypto.decryptStr(sysTenant.getTenantExpirationTime(), CharsetUtil.CHARSET_UTF_8);
|
|
|
+ LocalDateTime LastActiveDateTime = DateUtils.toLocalDateTime(LastActiveTimeStr, "yyyy-MM-dd HH:mm:ss");
|
|
|
+ long expirationTimeSecond = LastActiveDateTime.toEpochSecond(ZoneOffset.ofHours(8));
|
|
|
+ //计算时间戳
|
|
|
+ long difference = expirationTimeSecond - nowSecond; //相差的时间数 后边减前边
|
|
|
+ //如果是负数证明已经过期了
|
|
|
+ if (difference < 0) {
|
|
|
+ return "未激活-系统-扫描失败-0-0-0-0";
|
|
|
+ }
|
|
|
+ //扫描人员码信息
|
|
|
+ if(contentString.contains("scan@")){
|
|
|
+ //扫描标记替换为空
|
|
|
+ String replace = contentString.replace("scan@", "");
|
|
|
+ //首先把内容拆分下
|
|
|
+ String[] content = replace.split("&");
|
|
|
+ //人员信息
|
|
|
+ String personneString = content[0];
|
|
|
+ //更改当前人员的扫码信息
|
|
|
+ String[] personneList = personneString.split("#");
|
|
|
+ //设备编码信息
|
|
|
+ String sbMacAddress= content[1];
|
|
|
+ //更改当前工位码的设备信息
|
|
|
+ StationInformation stationInformation = new StationInformation();
|
|
|
+ stationInformation.setDeviceNumber(sbMacAddress);//设备编号
|
|
|
+ List<StationInformation> stationInformations = stationInformationMapper.selectStationInformationListByDEviceNumber(stationInformation);
|
|
|
+
|
|
|
+ if (stationInformations.size()>0){
|
|
|
+ //重置以前的绑定(手持机在哪我就把那变成空)
|
|
|
+ stationInformationMapper.updateStationInformationDeviceNameAndBluetoothName(stationInformation);
|
|
|
+ }
|
|
|
+ stationInformation.setPersonnelId(personneList[0]);//员工id
|
|
|
+// stationInformation.setPersonnelName(personneList[1]);//员工姓名
|
|
|
+ stationInformation.setUpdateTime(new Date()); //从新绑时间
|
|
|
+ int i = stationInformationMapper.updateStationInformationByUseIdAndUserName(stationInformation);
|
|
|
+ if(i>0){
|
|
|
+ System.out.println("手持设备绑定成功");
|
|
|
+ }
|
|
|
+ StationInformation stationInformation2 = new StationInformation();
|
|
|
+ stationInformation2.setPersonnelId(personneList[0]);//设备编号
|
|
|
+ List<StationInformation> stationInformations1 = stationInformationMapper.selectStationInformationList(stationInformation2);
|
|
|
+ if(stationInformations1.size()<=0){
|
|
|
+ return "当前工序没有此-人员-扫描失败-0-0-0-0";
|
|
|
+ }
|
|
|
+ System.out.println("工位:"+stationInformations1.get(0).getStationName()+"人员:"+stationInformations1.get(0).getPersonnelName());
|
|
|
+ return stationInformations1.get(0).getStationName()+"-"+stationInformations1.get(0).getPersonnelName()+"-手持设备绑定成功";
|
|
|
+ }else {
|
|
|
+ //产品编码&mac地址
|
|
|
+ String[] content = contentString.split("&");
|
|
|
+ //产品编码
|
|
|
+ String s1 = content[0];
|
|
|
+ //mac地址
|
|
|
+ String s2 = content[1];
|
|
|
+
|
|
|
+ //1、判断扫的是不是厂内流转卡
|
|
|
+ /*boolean fjqyD = stationProductScanningRingVo.getContentInformation().contains("D");
|
|
|
+ boolean fjqyZ = stationProductScanningRingVo.getContentInformation().contains("Z");
|
|
|
+ if(!fjqyD||!fjqyZ){return "请扫描相关二维码";}*/
|
|
|
+
|
|
|
+ //2、扫描间距判断
|
|
|
+ /* RingScanInformation ringScanInformationQuery=new RingScanInformation();
|
|
|
+ ringScanInformationQuery.setDeviceNumber(split[1]);//设备Mac地址
|
|
|
+ RingScanInformation ringScanInformations = ringScanInformationMapper.selectRingScanInformationListDateTimeMax(ringScanInformationQuery);
|
|
|
+ if(ringScanInformations!=null){
|
|
|
+ //拿到上次扫描的时间
|
|
|
+ LocalDateTime scanningTime1 = ringScanInformations.getScanningTime();
|
|
|
+ //拿到当前系统时间
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+ //计算两次时间的时间差
|
|
|
+ Duration duration = Duration.between(scanningTime1, now);
|
|
|
+ boolean isTwoMinutesPassed = duration.toMinutes() < 1;
|
|
|
+ //判断两次时间是否大于
|
|
|
+ if (isTwoMinutesPassed) {
|
|
|
+ return "同一设备,两分钟之内不能重复扫描";
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+
|
|
|
+ //扫码内容
|
|
|
+ RingScanInformation ringScanInformation=new RingScanInformation();
|
|
|
+ //扫描内容
|
|
|
+ ringScanInformation.setContentInformation(s1);
|
|
|
+ //当前时间
|
|
|
+ ringScanInformation.setScanningTime(LocalDateTime.now());
|
|
|
+ //mac地址
|
|
|
+ ringScanInformation.setDeviceNumber(s2);//mac地址
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //4、查询当前机器绑定的工位信息和人信息
|
|
|
+ StationInformation terminalInformation=new StationInformation();
|
|
|
+ terminalInformation.setDeviceNumber(s2);//mac地址
|
|
|
+ List<StationInformation> stationInformations =
|
|
|
+ stationInformationMapper.selectStationInformationListByDEviceNumber(terminalInformation);
|
|
|
+ if(stationInformations.size()>0){
|
|
|
+ ringScanInformation.setPersonnelName(stationInformations.get(0).getPersonnelName());//人员姓名
|
|
|
+ ringScanInformation.setProcess(stationInformations.get(0).getProcessId()); //工序id
|
|
|
+ ringScanInformation.setProcessName(stationInformations.get(0).getProcessName()); //工序名称
|
|
|
+ ringScanInformation.setStationId(stationInformations.get(0).getId().toString()); //工位id
|
|
|
+ ringScanInformation.setStationName(stationInformations.get(0).getStationName());//工位名称
|
|
|
+ }else {//当前没有绑定Mac地址直接返回
|
|
|
+ ringScanInformation.setExecutionMark("2");//成功
|
|
|
+ ringScanInformation.setExecutionMessage("未绑定-人员-扫描失败");
|
|
|
+ int i2 = ringScanInformationMapper.insertRingScanInformation(ringScanInformation);
|
|
|
+ return "未绑定-人员-扫描失败-0-0-0-0";
|
|
|
+ }
|
|
|
+ String nativeNumber="";
|
|
|
+ if(s1.contains("Z")){nativeNumber = s1.replace("Z", "");}
|
|
|
+ if(s1.contains("D")){nativeNumber=s1.replace("D","");}
|
|
|
+ if(StringUtils.isNotNull(nativeNumber)&&nativeNumber!=""){
|
|
|
+ //取值真实的扫描内容
|
|
|
+ ringScanInformation.setNativeNumbering(nativeNumber);
|
|
|
+ }else {
|
|
|
+ //扫描内容---直接就是产品码
|
|
|
+ ringScanInformation.setNativeNumbering(s1);
|
|
|
+ }
|
|
|
+ //根据扫描内容拿到生产订单号和订单号--查询流转卡序列号
|
|
|
+ ProductionCardFlow productionCardFlow=new ProductionCardFlow();
|
|
|
+ productionCardFlow.setSerialNumber(ringScanInformation.getNativeNumbering());//流转卡序列号
|
|
|
+ List<ProductionCardFlow> productionCardFlows = productionCardFlowMapper.selectProductionCardFlowList(productionCardFlow);
|
|
|
+ if(productionCardFlows.size()>0){
|
|
|
+ ProductionCardFlow productionCardFlow1 = productionCardFlows.get(0);
|
|
|
+ //需求单据号
|
|
|
+ ringScanInformation.setOrderNumber(productionCardFlow1.getProductionOrderListId());
|
|
|
+ //生产订单号
|
|
|
+ ringScanInformation.setProductionOrderNumber(productionCardFlow1.getDemandDocumentNumber());
|
|
|
+ }else {
|
|
|
+ System.out.println("erp未同步当前流转卡序列号");
|
|
|
+ ringScanInformation.setExecutionMark("2");//成功
|
|
|
+ ringScanInformation.setExecutionMessage("失败-未同步ERP");
|
|
|
+ int i2 = ringScanInformationMapper.insertRingScanInformation(ringScanInformation);
|
|
|
+ return stationInformations.get(0).getStationName()+"-"+stationInformations.get(0).getPersonnelName()+"-失败,未同步ERP-无-0-0-0";
|
|
|
+ }
|
|
|
+
|
|
|
+ //判断这个生产订单是否结案
|
|
|
+ String isJn="{\n" +
|
|
|
+ " \"FormId\": \"PRD_MO\",\n" +
|
|
|
+ " \"FieldKeys\": \"FBillNo,FSerialNo\",\n" +
|
|
|
+ " \"FilterString\": [{\"Left\":\"\",\"FieldName\":\"FStatus\",\"Compare\":\"105\",\"Value\":\"6\",\"Right\":\"\",\"Logic\":0}," +
|
|
|
+ " {\"Left\":\"\",\"FieldName\":\"FBillNo\",\"Compare\":\"67\",\"Value\":\""+ringScanInformation.getProductionOrderNumber()+"\",\"Right\":\"\",\"Logic\":0}],\n" +
|
|
|
+ " \"OrderString\": \"\",\n" +
|
|
|
+ " \"TopRowCount\": 0,\n" +
|
|
|
+ " \"StartRow\": 0,\n" +
|
|
|
+ " \"Limit\": 2000,\n" +
|
|
|
+ " \"SubSystemId\": \"\"\n" +
|
|
|
+ "}";
|
|
|
+ K3CloudApi api = new K3CloudApi();
|
|
|
+ String jnIs = api.billQuery(isJn);
|
|
|
+ if (!jnIs.equals("[]")) {
|
|
|
+ System.out.println("该流转卡生产订单已结案");
|
|
|
+ ringScanInformation.setExecutionMark("2");//成功
|
|
|
+ ringScanInformation.setExecutionMessage("失败-已结案");
|
|
|
+ int i2 = ringScanInformationMapper.insertRingScanInformation(ringScanInformation);
|
|
|
+ //改变订单详情的状态
|
|
|
+ PlanTaskDetails planTaskDetails=new PlanTaskDetails();
|
|
|
+ planTaskDetails.setStatus("3");
|
|
|
+ planTaskDetails.setDemandDocument(ringScanInformation.getProductionOrderNumber());
|
|
|
+ int i = planTaskDetailsMapper.updatePlanTaskDetailsByDemandDocument(planTaskDetails);
|
|
|
+ //返回失败信息
|
|
|
+ return stationInformations.get(0).getStationName()+"-"+stationInformations.get(0).getPersonnelName()+"-失败,已结案-无-0-0-0";
|
|
|
+ }
|
|
|
+ //验证重复扫描
|
|
|
+ RingScanInformation prodOrderScanning=new RingScanInformation();
|
|
|
+ prodOrderScanning.setContentInformation(s1);
|
|
|
+ prodOrderScanning.setProcessName(ringScanInformation.getProcessName());
|
|
|
+ List<RingScanInformation> ringScanInformations = ringScanInformationMapper.selectRingScanInformationListisNotNull(prodOrderScanning);
|
|
|
+ if(ringScanInformations.size()>0){
|
|
|
+ ringScanInformation.setExecutionMark("2");//成功
|
|
|
+ ringScanInformation.setExecutionMessage("重复扫描");
|
|
|
+ ringScanInformation.setOverNumber(ringScanInformations.get(0).getOverNumber());
|
|
|
+ int i2 = ringScanInformationMapper.insertRingScanInformation(ringScanInformation);
|
|
|
+ //查询订单号,订单总数量 完成数量,失败数量
|
|
|
+ //查询当前工位信息
|
|
|
+ ScanStatistics scanStatistics = ringScanInformationMapper.selectScanStatistics(ringScanInformation);
|
|
|
+ return stationInformations.get(0).getStationName()+"-"+stationInformations.get(0).getPersonnelName()+"-"+"重复扫描"+"-"
|
|
|
+ +scanStatistics.getdOrder()+"-"+scanStatistics.getdCount()+"-"+scanStatistics.getDsCount()+"-"+scanStatistics.getDfCount();
|
|
|
+ }
|
|
|
+ //查询生产订单日志里有没有这个生产订单有就不添加了
|
|
|
+ RingScanInformationFirst ringScanInformationFirst=new RingScanInformationFirst();
|
|
|
+ ringScanInformationFirst.setProductionOrderNumber(ringScanInformation.getProductionOrderNumber());
|
|
|
+ List<RingScanInformationFirst> ringScanInformationFirsts = ringScanInformationFirstMapper.selectRingScanInformationFirstList(ringScanInformationFirst);
|
|
|
+ if(ringScanInformationFirsts.size()<=0){
|
|
|
+ RingScanInformationFirst ringScanInformationFirst1=new RingScanInformationFirst();
|
|
|
+ ringScanInformationFirst1.setOrderNumber(ringScanInformation.getOrderNumber());//订单号
|
|
|
+ ringScanInformationFirst1.setProductionOrderNumber(ringScanInformation.getProductionOrderNumber());//生产订单号
|
|
|
+ ringScanInformationFirst1.setStatus("1");
|
|
|
+ ringScanInformationFirst1.setStartTime(LocalDateTime.now());//开始时间
|
|
|
+
|
|
|
+ //有多少个序列号就是有多少台
|
|
|
+ ProductionCardFlow productionCardFlow2=new ProductionCardFlow();
|
|
|
+ productionCardFlow2.setProductionOrderListId(ringScanInformation.getOrderNumber());//订单号
|
|
|
+ List<ProductionCardFlow> productionCardFlows2 = productionCardFlowMapper.selectProductionCardFlowList(productionCardFlow2);
|
|
|
+ ringScanInformationFirst1.setTotalQuantity(String.valueOf(productionCardFlows2.size()));//订单的总数
|
|
|
+
|
|
|
+ //判断当前生产订单 到包装还是检验
|
|
|
+ PlanTaskDetails planTaskDetails=new PlanTaskDetails();
|
|
|
+ planTaskDetails.setDemandDocument(ringScanInformation.getProductionOrderNumber());
|
|
|
+ List<PlanTaskDetails> planTaskDetails1 = planTaskDetailsService.selectPlanTaskDetailsList(planTaskDetails);
|
|
|
+
|
|
|
+ //解决老数据单据类型不存在的问题
|
|
|
+ if(planTaskDetails1.size()>0){
|
|
|
+ //更新两个单位不存在的问题
|
|
|
+ PlanTaskDetails planTaskDetails2 = planTaskDetails1.get(0);
|
|
|
+ boolean present1 = Optional.ofNullable(planTaskDetails2.getfSNUnitID()).filter(a -> !a.isEmpty()).isPresent();
|
|
|
+ boolean present2 = Optional.ofNullable(planTaskDetails2.getfBaseUnitId()).filter(a -> !a.isEmpty()).isPresent();
|
|
|
+ //里边有一个是空的那么就更新下生产订单详情表信息
|
|
|
+ if(ObjectUtil.isNull(planTaskDetails2.getfSNUnitID()) ||ObjectUtil.isNull(planTaskDetails2.getfBaseUnitId())){
|
|
|
+ //金蝶工具key
|
|
|
+ K3CloudApi api1 = new K3CloudApi();
|
|
|
+ //定义查询条件
|
|
|
+ //定义查询条件
|
|
|
+ String query = "{\n" +
|
|
|
+ " \"FormId\": \"PRD_MO\",\n" +
|
|
|
+ " \"FieldKeys\": \"FUnitId.FNumber,FSNUnitID.FNumber,FBaseUnitId.FNumber\",\n" +
|
|
|
+ " \"FilterString\": [{\"Left\":\"\",\"FieldName\":\"FBillNo\",\"Compare\":\"67\",\"Value\":\""+planTaskDetails2.getFbillno()+"\",\"Right\":\"\",\"Logic\":0}],\n" +
|
|
|
+ " \"OrderString\": \"\",\n" +
|
|
|
+ " \"TopRowCount\": 0,\n" +
|
|
|
+ " \"StartRow\": 0,\n" +
|
|
|
+ " \"Limit\": 2000,\n" +
|
|
|
+ " \"SubSystemId\": \"\"\n" +
|
|
|
+ "}";
|
|
|
+
|
|
|
+ //查询结果
|
|
|
+ String resultJson = api1.billQuery(query);
|
|
|
+ //生产信息
|
|
|
+ List<JdProductionOrder> jdProductionOrders = JSON.parseArray(resultJson, JdProductionOrder.class);
|
|
|
+ //更新逻辑
|
|
|
+ if (jdProductionOrders.size()>0) {
|
|
|
+ PlanTaskDetails planTaskDetails3=new PlanTaskDetails();
|
|
|
+ planTaskDetails3.setfSNUnitID(jdProductionOrders.get(0).getfSNUnitID());//序列号单位
|
|
|
+ planTaskDetails3.setfBaseUnitId(jdProductionOrders.get(0).getfBaseUnitId());//基本单位
|
|
|
+ planTaskDetails3.setId(planTaskDetails2.getId());//编号id
|
|
|
+ int i = planTaskDetailsMapper.updatePlanTaskDetails(planTaskDetails3);
|
|
|
+ System.out.println(i+"单位类型补充成功");
|
|
|
+ //从新查类型
|
|
|
+ planTaskDetails1 = planTaskDetailsService.selectPlanTaskDetailsList(planTaskDetails);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Double v = Double.parseDouble(planTaskDetails1.get(0).getQuantity());
|
|
|
+ Integer i1 = v.intValue();
|
|
|
+ ringScanInformationFirst1.setProductionOrderTotalQuantity(i1.toString());//生产订单的总数
|
|
|
+
|
|
|
+ if(planTaskDetails1.size()>0){
|
|
|
+ PlanTaskDetails planTaskDetails2 = planTaskDetails1.get(0);
|
|
|
+ String materialId = planTaskDetails2.getMaterialId();
|
|
|
+ //逻辑走包装还是走检验
|
|
|
+ if(materialId.startsWith("1")){// 成品检验
|
|
|
+ ringScanInformationFirst1.setPackingOrInspection("1");//1开头的 成品检验, 入库
|
|
|
+ }else if(materialId.startsWith("2")) { //试机检验
|
|
|
+ ringScanInformationFirst1.setPackingOrInspection("2");//2试机检验,入库
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //扫一次产品记录一次
|
|
|
+ int i = ringScanInformationFirstMapper.insertRingScanInformationFirst(ringScanInformationFirst1);
|
|
|
+ //有可能订单数量就是一台,我扫一回订单就结束掉了
|
|
|
+
|
|
|
+ //这个订单,我直接扫一次,就扫一次,并且扫描的工序是成品检验或者试机检验,那我就进行报工
|
|
|
+ if(planTaskDetails1.size()>0){{
|
|
|
+ PlanTaskDetails planTaskDetails2 = planTaskDetails1.get(0);
|
|
|
+ String materialId = planTaskDetails2.getMaterialId();
|
|
|
+ if(materialId.startsWith("1")&&ringScanInformation.getProcessName().equals("成品检验")){
|
|
|
+ //更新成品检验(只扫一次也需要更新包装或者检验的数量)
|
|
|
+ RingScanInformationFirst ringScanInformationFirstOne=new RingScanInformationFirst();
|
|
|
+ ringScanInformationFirstOne.setProductionOrderNumber(ringScanInformation.getProductionOrderNumber());
|
|
|
+ List<RingScanInformationFirst> ringScanInformationFirsts1 = ringScanInformationFirstMapper.selectRingScanInformationFirstList(ringScanInformationFirstOne);
|
|
|
+ RingScanInformationFirst ringScanInformationFirstNumber = ringScanInformationFirsts1.get(0);
|
|
|
+ RingScanInformationFirst newRingScanInformationFirst = getRingScanInformationFirst(ringScanInformationFirstNumber.getPackingQuantity(), ringScanInformation, "1");
|
|
|
+ ringScanInformationFirstMapper.updateRingScanInformationFirstByproductionOrderNumber(newRingScanInformationFirst);
|
|
|
+ String aa = generateWarehouseWarrant(ringScanInformation.getProductionOrderNumber(), ringScanInformation.getProcessName(), "3", ringScanInformation);//生产订单号,工序名
|
|
|
+ if(aa.equals("工序汇报创建失败")){
|
|
|
+ if(aa.contains("返还件退料套数小于累计汇报数")){
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return "汇报单-创建失败(未退料)-扫描失败-0-0-0-0";
|
|
|
+ }
|
|
|
+ if(aa.contains("下达日期大于生产汇报单的单据日期")){
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return "汇报单-创建失败(下达日期大于单据日期)-扫描失败-0-0-0-0";
|
|
|
+ }
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return "汇报单-创建失败-扫描失败-0-0-0-0";
|
|
|
+ }
|
|
|
+ if(aa.equals("工序汇报提交失败")){
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return "汇报单-提交失败-扫描失败-0-0-0-0";
|
|
|
+ }
|
|
|
+ if(aa.equals("工序汇报审核失败")){
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return "汇报单-审核失败-扫描失败-0-0-0-0";
|
|
|
+ }
|
|
|
+ }else if(materialId.startsWith("2")&&ringScanInformation.getProcessName().equals("试机检验")) {
|
|
|
+
|
|
|
+ //更新成品检验(只扫一次也需要更新包装或者检验的数量)
|
|
|
+ RingScanInformationFirst ringScanInformationFirstOne=new RingScanInformationFirst();
|
|
|
+ ringScanInformationFirstOne.setProductionOrderNumber(ringScanInformation.getProductionOrderNumber());
|
|
|
+ List<RingScanInformationFirst> ringScanInformationFirsts1 = ringScanInformationFirstMapper.selectRingScanInformationFirstList(ringScanInformationFirstOne);
|
|
|
+ RingScanInformationFirst ringScanInformationFirstNumber = ringScanInformationFirsts1.get(0);
|
|
|
+ RingScanInformationFirst newRingScanInformationFirst = getRingScanInformationFirst(ringScanInformationFirstNumber.getPackingQuantity(), ringScanInformation, "1");
|
|
|
+ ringScanInformationFirstMapper.updateRingScanInformationFirstByproductionOrderNumber(newRingScanInformationFirst);
|
|
|
+ String aa= generateWarehouseWarrant(ringScanInformation.getProductionOrderNumber(),ringScanInformation.getProcessName(),"4",ringScanInformation);//生产订单号,工序名
|
|
|
+ if(aa.equals("工序汇报创建失败")){
|
|
|
+ if(aa.contains("返还件退料套数小于累计汇报数")){
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return "汇报单-创建失败(未退料)-扫描失败-0-0-0-0";
|
|
|
+ }
|
|
|
+ if(aa.contains("下达日期大于生产汇报单的单据日期")){
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return "汇报单-创建失败(下达日期大于单据日期)-扫描失败-0-0-0-0";
|
|
|
+ }
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return "汇报单-创建失败-扫描失败-0-0-0-0";
|
|
|
+ }
|
|
|
+ if(aa.equals("工序汇报提交失败")){
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return "汇报单-提交失败-扫描失败-0-0-0-0";
|
|
|
+ }
|
|
|
+ if(aa.equals("工序汇报审核失败")){
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return "汇报单-审核失败-扫描失败-0-0-0-0";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }}
|
|
|
+ }else {
|
|
|
+ //更新包装或者检验的数量
|
|
|
+ //拿到老的包装数量
|
|
|
+ RingScanInformationFirst ringScanInformationFirst1=new RingScanInformationFirst();
|
|
|
+ ringScanInformationFirst1.setProductionOrderNumber(ringScanInformation.getProductionOrderNumber());
|
|
|
+ List<RingScanInformationFirst> ringScanInformationFirsts1 = ringScanInformationFirstMapper.selectRingScanInformationFirstList(ringScanInformationFirst1);
|
|
|
+ RingScanInformationFirst ringScanInformationFirstNumber = ringScanInformationFirsts1.get(0);
|
|
|
+ //判断当前生产订单 到包装还是检验
|
|
|
+ PlanTaskDetails planTaskDetails=new PlanTaskDetails();
|
|
|
+ planTaskDetails.setDemandDocument(ringScanInformation.getProductionOrderNumber());
|
|
|
+ List<PlanTaskDetails> planTaskDetails1 = planTaskDetailsService.selectPlanTaskDetailsList(planTaskDetails);
|
|
|
+
|
|
|
+ //解决老数据单据类型不存在的问题
|
|
|
+ if(planTaskDetails1.size()>0){
|
|
|
+ //更新两个单位不存在的问题
|
|
|
+ PlanTaskDetails planTaskDetails2 = planTaskDetails1.get(0);
|
|
|
+ //里边有一个是空的那么就更新下生产订单详情表信息
|
|
|
+ if(ObjectUtil.isNull(planTaskDetails2.getfSNUnitID()) ||ObjectUtil.isNull(planTaskDetails2.getfBaseUnitId())){
|
|
|
+ //金蝶工具key
|
|
|
+ K3CloudApi api1 = new K3CloudApi();
|
|
|
+ //定义查询条件
|
|
|
+ String query = "{\n" +
|
|
|
+ " \"FormId\": \"PRD_MO\",\n" +
|
|
|
+ " \"FieldKeys\": \"FUnitId.FNumber,FSNUnitID.FNumber,FBaseUnitId.FNumber\",\n" +
|
|
|
+ " \"FilterString\": [{\"Left\":\"\",\"FieldName\":\"FBillNo\",\"Compare\":\"67\",\"Value\":\""+planTaskDetails2.getFbillno()+"\",\"Right\":\"\",\"Logic\":0}],\n" +
|
|
|
+ " \"OrderString\": \"\",\n" +
|
|
|
+ " \"TopRowCount\": 0,\n" +
|
|
|
+ " \"StartRow\": 0,\n" +
|
|
|
+ " \"Limit\": 2000,\n" +
|
|
|
+ " \"SubSystemId\": \"\"\n" +
|
|
|
+ "}";
|
|
|
+
|
|
|
+ //查询结果
|
|
|
+ String resultJson = api1.billQuery(query);
|
|
|
+ //生产信息
|
|
|
+ List<JdProductionOrder> jdProductionOrders = JSON.parseArray(resultJson, JdProductionOrder.class);
|
|
|
+ //更新逻辑
|
|
|
+ if (jdProductionOrders.size()>0) {
|
|
|
+ PlanTaskDetails planTaskDetails3=new PlanTaskDetails();
|
|
|
+ planTaskDetails3.setfSNUnitID(jdProductionOrders.get(0).getfSNUnitID());//序列号单位
|
|
|
+ planTaskDetails3.setfBaseUnitId(jdProductionOrders.get(0).getfBaseUnitId());//基本单位
|
|
|
+ planTaskDetails3.setId(planTaskDetails2.getId());//编号id
|
|
|
+ int i = planTaskDetailsMapper.updatePlanTaskDetails(planTaskDetails3);
|
|
|
+ System.out.println(i+"单位类型补充成功");
|
|
|
+ //从新查类型
|
|
|
+ planTaskDetails1 = planTaskDetailsService.selectPlanTaskDetailsList(planTaskDetails);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(planTaskDetails1.size()>0){
|
|
|
+ PlanTaskDetails planTaskDetails2 = planTaskDetails1.get(0);
|
|
|
+ String materialId = planTaskDetails2.getMaterialId();
|
|
|
+ if(materialId.startsWith("1")&&ringScanInformation.getProcessName().equals("成品检验")){//1卡头并且当前工序未包装,扫描信息为,更新包装数量
|
|
|
+ RingScanInformation ringScanInformation1=new RingScanInformation();
|
|
|
+ ringScanInformation1.setNativeNumbering(ringScanInformation.getNativeNumbering());
|
|
|
+ ringScanInformation1.setProcessName(ringScanInformation.getProcessName());//工序
|
|
|
+ //有关于这个产品的扫描信息就不更新数量了
|
|
|
+ List<RingScanInformation> ringScanInformations1 = ringScanInformationMapper.selectRingScanInformationList(ringScanInformation1);
|
|
|
+ if(ringScanInformations1.size()<=0) {
|
|
|
+ RingScanInformationFirst newRingScanInformationFirst = getRingScanInformationFirst(ringScanInformationFirstNumber.getPackingQuantity(), ringScanInformation, "1");
|
|
|
+ ringScanInformationFirstMapper.updateRingScanInformationFirstByproductionOrderNumber(newRingScanInformationFirst);
|
|
|
+ //生产汇报 等于代表走工序汇报逻辑 1 和 2代表入的什么仓库(1:成品 2:利库) 3和4 代表走工序汇报逻辑(3:成品 4:利库)
|
|
|
+ String aa = generateWarehouseWarrant(ringScanInformation.getProductionOrderNumber(), ringScanInformation.getProcessName(), "3", ringScanInformation);//生产订单号,工序名
|
|
|
+ if(aa.equals("工序汇报创建失败")){
|
|
|
+ if(aa.contains("返还件退料套数小于累计汇报数")){
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return "汇报单-创建失败(未退料)-扫描失败-0-0-0-0";
|
|
|
+ }
|
|
|
+ if(aa.contains("下达日期大于生产汇报单的单据日期")){
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return "汇报单-创建失败(下达日期大于单据日期)-扫描失败-0-0-0-0";
|
|
|
+ }
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return "汇报单-创建失败-扫描失败-0-0-0-0";
|
|
|
+ }
|
|
|
+ if(aa.equals("工序汇报提交失败")){
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return "汇报单-提交失败-扫描失败-0-0-0-0";
|
|
|
+ }
|
|
|
+ if(aa.equals("工序汇报审核失败")){
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return "汇报单-审核失败-扫描失败-0-0-0-0";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else if(materialId.startsWith("2")&&ringScanInformation.getProcessName().equals("试机检验")) {
|
|
|
+ //有关于这个产品的扫描信息就不更新数量了
|
|
|
+ RingScanInformation ringScanInformation1=new RingScanInformation();
|
|
|
+ ringScanInformation1.setNativeNumbering(ringScanInformation.getNativeNumbering());
|
|
|
+ ringScanInformation1.setProcessName(ringScanInformation.getProcessName());//工序
|
|
|
+ List<RingScanInformation> ringScanInformations1 = ringScanInformationMapper.selectRingScanInformationList(ringScanInformation1);
|
|
|
+ if(ringScanInformations1.size()<=0){
|
|
|
+ RingScanInformationFirst newRingScanInformationFirst = getRingScanInformationFirst(ringScanInformationFirstNumber.getInspectionQuantity(), ringScanInformation,"2");
|
|
|
+ ringScanInformationFirstMapper.updateRingScanInformationFirstByproductionOrderNumber(newRingScanInformationFirst);
|
|
|
+ //生产汇报
|
|
|
+ //等于代表走工序汇报逻辑 1 和 2代表入的什么仓库(1:成品 2:利库) 3和4 代表走工序汇报逻辑(3:成品 4:利库)
|
|
|
+ String aa = generateWarehouseWarrant(ringScanInformation.getProductionOrderNumber(), ringScanInformation.getProcessName(), "4", ringScanInformation);//生产订单号,工序名
|
|
|
+ if(aa.equals("工序汇报创建失败")){
|
|
|
+ if(aa.contains("返还件退料套数小于累计汇报数")){
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return "汇报单-创建失败(未退料)-扫描失败-0-0-0-0";
|
|
|
+ }
|
|
|
+ if(aa.contains("下达日期大于生产汇报单的单据日期")){
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return "汇报单-创建失败(下达日期大于单据日期)-扫描失败-0-0-0-0";
|
|
|
+ }
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return "汇报单-创建失败-扫描失败-0-0-0-0";
|
|
|
+ }
|
|
|
+ if(aa.equals("工序汇报提交失败")){
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return "汇报单-提交失败-扫描失败-0-0-0-0";
|
|
|
+ }
|
|
|
+ if(aa.equals("工序汇报审核失败")){
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return "汇报单-审核失败-扫描失败-0-0-0-0";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(materialId.startsWith("1")&&ringScanInformation.getProcessName().equals("入库")){//1开头产品的入库逻辑
|
|
|
+ RingScanInformation ringScanInformation1=new RingScanInformation();
|
|
|
+ ringScanInformation1.setNativeNumbering(ringScanInformation.getNativeNumbering());
|
|
|
+ ringScanInformation1.setProcessName(ringScanInformation.getProcessName());//工序
|
|
|
+ //有关于这个产品的扫描信息就不更新数量了
|
|
|
+ List<RingScanInformation> ringScanInformations1 = ringScanInformationMapper.selectRingScanInformationList(ringScanInformation1);
|
|
|
+ if(ringScanInformations1.size()<=0) {
|
|
|
+ //入库
|
|
|
+ String s = generateWarehouseWarrant(ringScanInformation.getProductionOrderNumber(), ringScanInformation.getProcessName(), "1", ringScanInformation);
|
|
|
+ if(s.contains("未查询到生产汇报信息")){
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return "未查询到-生产汇报信息-扫描失败-0-0-0-0";
|
|
|
+ }
|
|
|
+ if(s.contains("入库单创建失败")){
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return "入库单-"+("创建失败(车间仓物料不足)")+"-扫描失败-0-0-0-0";
|
|
|
+ }
|
|
|
+ if(s.contains("入库单提交失败")){
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return "入库单-提交失败-扫描失败-0-0-0-0";
|
|
|
+ }
|
|
|
+ if(s.contains("入库单审核失败")){
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return "入库单-审核失败-扫描失败-0-0-0-0";
|
|
|
+ }
|
|
|
+ if(s.contains("有问题请联系管理员")){
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return "有问题-请联系管理员-扫描失败-0-0-0-0";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else if(materialId.startsWith("2")&&ringScanInformation.getProcessName().equals("入库")) { //2开头产品的入库逻辑
|
|
|
+ //有关于这个产品的扫描信息就不更新数量了
|
|
|
+ RingScanInformation ringScanInformation1=new RingScanInformation();
|
|
|
+ ringScanInformation1.setNativeNumbering(ringScanInformation.getNativeNumbering());
|
|
|
+ ringScanInformation1.setProcessName(ringScanInformation.getProcessName());//工序
|
|
|
+ List<RingScanInformation> ringScanInformations1 = ringScanInformationMapper.selectRingScanInformationList(ringScanInformation1);
|
|
|
+ if(ringScanInformations1.size()<=0){
|
|
|
+ //入库
|
|
|
+ String s = generateWarehouseWarrant(ringScanInformation.getProductionOrderNumber(), ringScanInformation.getProcessName(), "2", ringScanInformation);//生产订单号,工序名
|
|
|
+ if(s.contains("未查询到生产汇报信息")){
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return "未查询到-生产汇报信息-扫描失败-0-0-0-0";
|
|
|
+ }
|
|
|
+ if(s.contains("入库单创建失败")){
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return "入库单-"+s+"-扫描失败-0-0-0-0";
|
|
|
+ }
|
|
|
+ if(s.contains("入库单提交失败")){
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return "入库单-提交失败-扫描失败-0-0-0-0";
|
|
|
+ }
|
|
|
+ if(s.contains("入库单审核失败")){
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return "入库单-审核失败-扫描失败-0-0-0-0";
|
|
|
+ }
|
|
|
+ if(s.contains("有问题请联系管理员")){
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return "有问题-请联系管理员-扫描失败-0-0-0-0";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //插入扫描日志前判定当前销售订单是否变为生成完成
|
|
|
+ PlanTaskDetails planTaskDetails=new PlanTaskDetails();
|
|
|
+ planTaskDetails.setStatus("1");//状态
|
|
|
+ planTaskDetails.setDemandDocument(ringScanInformation.getProductionOrderNumber());//生产订单
|
|
|
+ List<PlanTaskDetails> planTaskDetails1 = planTaskDetailsMapper.selectPlanTaskDetailsList(planTaskDetails);
|
|
|
+ if(planTaskDetails1.size()<=0){
|
|
|
+ //生产订单状态
|
|
|
+ RingScanInformationFirst ringScanInformationFirst1=new RingScanInformationFirst();
|
|
|
+ ringScanInformationFirst1.setProductionOrderNumber(ringScanInformation.getProductionOrderNumber());
|
|
|
+ ringScanInformationFirst1.setStatus("2");
|
|
|
+ ringScanInformationFirstMapper.updateRingScanInformationFirstByproductionOrderNumber(ringScanInformationFirst1);
|
|
|
+ }
|
|
|
+ ProductionPlanningManagement productionPlanningManagement=new ProductionPlanningManagement();
|
|
|
+ productionPlanningManagement.setOrderNumber(ringScanInformation.getOrderNumber());
|
|
|
+ List<ProductionPlanningManagement> productionPlanningManagements = productionPlanningManagementMapper
|
|
|
+ .selectProductionPlanningManagementList(productionPlanningManagement);
|
|
|
+ if(productionPlanningManagements.size()>0){
|
|
|
+ ProductionPlanningManagement productionPlanningManagement1 = productionPlanningManagements.get(0);
|
|
|
+ //订单号
|
|
|
+ PlanTaskDetails planTaskDetailsTwo=new PlanTaskDetails();
|
|
|
+ planTaskDetailsTwo.setPlanId(productionPlanningManagement1.getId());//生产订单
|
|
|
+ planTaskDetailsTwo.setStatus("1");
|
|
|
+ List<PlanTaskDetails> planTaskDetailsPlan = planTaskDetailsMapper.selectPlanTaskDetailsList(planTaskDetailsTwo);
|
|
|
+ if(planTaskDetailsPlan.size()<=0){
|
|
|
+ PlanTaskDetails planTaskDetails2=new PlanTaskDetails();
|
|
|
+ planTaskDetails2.setDemandDocument(ringScanInformation.getProductionOrderNumber());//生产订单
|
|
|
+ List<PlanTaskDetails> planTaskDetails2s = planTaskDetailsMapper.selectPlanTaskDetailsList(planTaskDetails2);
|
|
|
+ //改订单状态
|
|
|
+ ProductionPlanningManagement productionPlanningManagementUpdate=new ProductionPlanningManagement();
|
|
|
+ productionPlanningManagementUpdate.setOrderNumber(ringScanInformation.getOrderNumber());
|
|
|
+ productionPlanningManagementUpdate.setTaskStatus("3");
|
|
|
+ productionPlanningManagementUpdate.setId(planTaskDetails2s.get(0).getPlanId());
|
|
|
+ productionPlanningManagementMapper.updateProductionPlanningManagement(productionPlanningManagementUpdate);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(ringScanInformation.getProcessName().equals("焊接")){
|
|
|
+ String contentInformation = ringScanInformation.getContentInformation();
|
|
|
+ if(contentInformation.contains("D")){
|
|
|
+ RingScanInformation ringScanInformation1=new RingScanInformation();
|
|
|
+ ringScanInformation1.setProductionOrderNumber(ringScanInformation.getProductionOrderNumber());
|
|
|
+ ringScanInformation1.setProcessName("焊接D");
|
|
|
+ ringScanInformation1.setOrderNumber(ringScanInformation.getOrderNumber());
|
|
|
+ String s = ringScanInformationMapper.selectRingScanInformationListLike(ringScanInformation1);
|
|
|
+ int i = Integer.parseInt(s);
|
|
|
+ int ss=i+1;
|
|
|
+ ringScanInformation.setOverNumber(String.valueOf(ss));
|
|
|
+ }else if(contentInformation.contains("Z")){
|
|
|
+ RingScanInformation ringScanInformation1=new RingScanInformation();
|
|
|
+ ringScanInformation1.setProductionOrderNumber(ringScanInformation.getProductionOrderNumber());
|
|
|
+ ringScanInformation1.setProcessName("焊接Z");
|
|
|
+ ringScanInformation1.setOrderNumber(ringScanInformation.getOrderNumber());
|
|
|
+ String s = ringScanInformationMapper.selectRingScanInformationListLike(ringScanInformation1);
|
|
|
+ int i = Integer.parseInt(s);
|
|
|
+ int ss=i+1;
|
|
|
+ ringScanInformation.setOverNumber(String.valueOf(ss));
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ String s = ringScanInformationMapper.selectRingScanInformationListLike(ringScanInformation);
|
|
|
+ int i = Integer.parseInt(s);
|
|
|
+ int ss=i+1;
|
|
|
+ ringScanInformation.setOverNumber(String.valueOf(ss));
|
|
|
+ }
|
|
|
+ //插入扫描日志信息
|
|
|
+ ringScanInformation.setExecutionMark("1");
|
|
|
+ ringScanInformation.setExecutionMessage("扫描成功");
|
|
|
+ if(ringScanInformation.getProcessName().equals("白坯检验")){
|
|
|
+ RingScanInformation ringScanInformation1=new RingScanInformation();
|
|
|
+ BeanUtils.copyProperties(ringScanInformation,ringScanInformation1);
|
|
|
+ ringScanInformation1.setProcessName("浸漆");
|
|
|
+ ringScanInformation1.setProcess("32");
|
|
|
+ ringScanInformation1.setStationId("0");
|
|
|
+ ringScanInformation1.setStationName("浸漆");
|
|
|
+ int i2 = ringScanInformationMapper.insertRingScanInformation(ringScanInformation1);
|
|
|
+ }
|
|
|
+ if(ringScanInformation.getProcessName().equals("成品检验")){
|
|
|
+ RingScanInformation ringScanInformation1=new RingScanInformation();
|
|
|
+ BeanUtils.copyProperties(ringScanInformation,ringScanInformation1);
|
|
|
+ ringScanInformation1.setProcessName("包装");
|
|
|
+ ringScanInformation1.setProcess("28");
|
|
|
+ ringScanInformation1.setStationId("0");
|
|
|
+ ringScanInformation1.setStationName("包装工位");
|
|
|
+
|
|
|
+ int i2 = ringScanInformationMapper.insertRingScanInformation(ringScanInformation1);
|
|
|
+ }
|
|
|
+ int i2 = ringScanInformationMapper.insertRingScanInformation(ringScanInformation);
|
|
|
+
|
|
|
+
|
|
|
+ //查询当前工位信息
|
|
|
+ ScanStatistics scanStatistics = null;
|
|
|
+ RingScanInformation ringScanInformation1=new RingScanInformation();
|
|
|
+ ringScanInformation1.setProductionOrderNumber(ringScanInformation.getProductionOrderNumber());
|
|
|
+ ringScanInformation1.setProcessName(ringScanInformation.getProcessName());
|
|
|
+ if(ringScanInformation.getProcessName().equals("焊接")) {
|
|
|
+ if (ringScanInformation.getContentInformation().contains("D")) {
|
|
|
+ ringScanInformation1.setProcessName("焊接D");
|
|
|
+ } else {
|
|
|
+ ringScanInformation1.setProcessName("焊接Z");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ scanStatistics = ringScanInformationMapper.selectScanStatistics(ringScanInformation1);
|
|
|
+ //记录扫迈欧
|
|
|
+ return ringScanInformation.getStationName()+"-"+ringScanInformation.getPersonnelName()+"-"+"扫描成功"+"-"+
|
|
|
+ scanStatistics.getdOrder()+"-"+scanStatistics.getdCount()+"-"+scanStatistics.getDsCount()+"-"+scanStatistics.getDfCount();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 扣料
|
|
|
+ * @param orderNumber
|
|
|
+ * @param productNumber
|
|
|
+ * @param gxm
|
|
|
+ * @param lxkNumber
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String sweepingMaterial2(String orderNumber,String productNumber,String gxm,String lxkNumber){
|
|
|
+ if(gxm.equals("入库")){
|
|
|
+ return "入库不扣料";
|
|
|
+ }
|
|
|
+ ProcedureList procedureList=new ProcedureList();
|
|
|
+ procedureList.setProcedurName(gxm);
|
|
|
+ List<ProcedureList> procedureLists = procedureListMapper.selectProcedureListList(procedureList);
|
|
|
+ if(procedureLists.size()<=0){
|
|
|
+ return "此工序不存在";
|
|
|
+ }
|
|
|
+ //输入产品编号查询,
|
|
|
+ MaterialRetentionLog materialRetentionLog=new MaterialRetentionLog();
|
|
|
+ materialRetentionLog.setFlowSequenceNumber(productNumber);
|
|
|
+ materialRetentionLog.setProcess(gxm);
|
|
|
+ List<MaterialRetentionLog> materialRetentionLogs = materialRetentionLogMapper.selectMaterialRetentionLogList(materialRetentionLog);
|
|
|
+ if(materialRetentionLogs.size()>0){
|
|
|
+ return "此料已扣除";
|
|
|
+ }
|
|
|
+ //查询MES对应的ERP
|
|
|
+ ProcedureListErp procedureListErp=new ProcedureListErp();
|
|
|
+ procedureListErp.setErpJobName(procedureLists.get(0).getId().toString());
|
|
|
+ List<ProcedureListErp> procedureListErps = procedureListErpMapper.selectProcedureListErpList(procedureListErp);
|
|
|
+
|
|
|
+ if(gxm.equals("焊接")){
|
|
|
+ RingScanInformation ringScanInformation=new RingScanInformation();
|
|
|
+ ringScanInformation.setProcessName(gxm);//工序
|
|
|
+ ringScanInformation.setProductionOrderNumber(productNumber); //生产订单
|
|
|
+ ringScanInformation.setNativeNumbering(lxkNumber);//流转卡
|
|
|
+ List<RingScanInformation> ringScanInformations = ringScanInformationMapper.selectRingScanInformationList(ringScanInformation);
|
|
|
+ //当前流转卡在当前工序可以的话就进行扣料处理
|
|
|
+ // 人员id,产品id
|
|
|
+ if(ringScanInformations.size()==2){
|
|
|
+ //查询条件
|
|
|
+ String queryString ="{\n" +
|
|
|
+ " \"FormId\": \"PRD_MO\",\n" +
|
|
|
+ " \"FieldKeys\": \"FBillNo\",\n" +
|
|
|
+ " \"FilterString\": [{\"Left\":\"\",\"FieldName\":\"FSerialNo\",\"Compare\":\"67\",\"Value\":\""+lxkNumber+"\",\"Right\":\"\",\"Logic\":0}],\n" +
|
|
|
+ " \"OrderString\": \"\",\n" +
|
|
|
+ " \"TopRowCount\": 0,\n" +
|
|
|
+ " \"StartRow\": 0,\n" +
|
|
|
+ " \"Limit\": 2000,\n" +
|
|
|
+ " \"SubSystemId\": \"\"\n" +
|
|
|
+ "}";
|
|
|
+ //查询条件
|
|
|
+ Map<String, Object> map = JSON.parseObject(queryString, Map.class);
|
|
|
+
|
|
|
+ K3CloudApi api = new K3CloudApi();
|
|
|
+ List<JdProductionOrder> jdProductionOrders;
|
|
|
+ try {
|
|
|
+ String resultJson = api.billQuery(JSON.toJSONString(map));
|
|
|
+ //如果查询的数据为空
|
|
|
+ if(resultJson.equals("[]")){
|
|
|
+ return "此工序不存在扣料信息";
|
|
|
+ }else{
|
|
|
+ //转换实体类对象
|
|
|
+ jdProductionOrders = JSON.parseArray(resultJson, JdProductionOrder.class);
|
|
|
+ //按照流转卡把信息查询出来了
|
|
|
+ if(jdProductionOrders.size()>0) {
|
|
|
+ //单据编号
|
|
|
+ String documentNumber = jdProductionOrders.get(0).getDocumentNumber();
|
|
|
+ //根据生产订单号查询生产用料清单
|
|
|
+ String productionMaterialsListQuery="{\n" +
|
|
|
+ " \"FormId\": \"PRD_PPBOM\",\n" +
|
|
|
+ " \"FieldKeys\": \"FMaterialID.FNumber,FMaterialName,FMaterialModel,FMaterialModel2,FDescription,FMaterialID2.FNumber,FMaterialName1,FMaterialModel1,FUnitID2.FName,FMustQty,FMEMO1,FNumerator,FMaterialType,FProcessID.FName\",\n" +
|
|
|
+ " \"FilterString\": [],\n" +
|
|
|
+ " \"OrderString\": \"\",\n" +
|
|
|
+ " \"TopRowCount\": 0,\n" +
|
|
|
+ " \"StartRow\": 0,\n" +
|
|
|
+ " \"Limit\": 2000,\n" +
|
|
|
+ " \"SubSystemId\": \"\"\n" +
|
|
|
+ "}";
|
|
|
+ //查询生产用料清单
|
|
|
+ Map<String, Object> map2 = JSON.parseObject(productionMaterialsListQuery, Map.class);
|
|
|
+ String filterString = map2.get("FilterString").toString();
|
|
|
+ List<Map> mapList = JSON.parseArray(filterString, Map.class);
|
|
|
+ if(procedureListErps.size()>0){
|
|
|
+ //循环条件
|
|
|
+ procedureListErps.forEach(map1 -> {
|
|
|
+ String ddh="{\"Left\":\"\",\"FieldName\":\"FMOBillNO\",\"Compare\":\"67\",\"Value\":\"11\",\"Right\":\"\",\"Logic\":0}";
|
|
|
+ String mapTj="{\"Left\":\"\",\"FieldName\":\"FProcessID.FName\",\"Compare\":\"67\",\"Value\":\"111\",\"Right\":\"\",\"Logic\":1}";
|
|
|
+ Map mapObj = JSONObject.parseObject(mapTj, Map.class);
|
|
|
+ Map ddhObj = JSONObject.parseObject(ddh, Map.class);
|
|
|
+ ddhObj.put("Value", productNumber);
|
|
|
+ mapObj.put("Value", map1.getProcedurName());
|
|
|
+ mapList.add(ddhObj);
|
|
|
+ mapList.add(mapObj);
|
|
|
+ });
|
|
|
+
|
|
|
+ map2.put("FilterString", mapList);//从新绑定条件
|
|
|
+
|
|
|
+ //生产用料清单结果
|
|
|
+ String resultJsonJG = api.billQuery(JSON.toJSONString(map2));
|
|
|
+ //json转Java实体类对象
|
|
|
+ List<MaterialRetentionLogVo> materialRetentionLogVos = JSON.parseArray(resultJsonJG, MaterialRetentionLogVo.class);
|
|
|
+ //赋值一些默认值
|
|
|
+ List<MaterialRetentionLogVo> collect = materialRetentionLogVos.parallelStream().map(item -> {
|
|
|
+ item.setCkNumber("CK005");
|
|
|
+ item.setDeliveryWarehouse("车间仓");
|
|
|
+ item.setFlowSequenceNumber(lxkNumber);//流转序列号
|
|
|
+ item.setMesprocess(gxm);
|
|
|
+ item.setOrderNumber(orderNumber);
|
|
|
+ item.setProductionOrderNumber(productNumber);
|
|
|
+ item.setCreateTime(new Date());
|
|
|
+ return item;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ //分子数量基本的扣料单位
|
|
|
+ int i = materialRetentionLogMapper.insertMaterialRetentionLogBatch(collect);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.out.println(e);
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ }
|
|
|
+ return productNumber+gxm+"扣料成功";
|
|
|
+ }else {
|
|
|
+ return productNumber+gxm+"未完不扣料";
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ //查询条件
|
|
|
+ String queryString ="{\n" +
|
|
|
+ " \"FormId\": \"PRD_MO\",\n" +
|
|
|
+ " \"FieldKeys\": \"FBillNo\",\n" +
|
|
|
+ " \"FilterString\": [{\"Left\":\"\",\"FieldName\":\"FSerialNo\",\"Compare\":\"67\",\"Value\":\""+lxkNumber+"\",\"Right\":\"\",\"Logic\":0}],\n" +
|
|
|
+ " \"OrderString\": \"\",\n" +
|
|
|
+ " \"TopRowCount\": 0,\n" +
|
|
|
+ " \"StartRow\": 0,\n" +
|
|
|
+ " \"Limit\": 2000,\n" +
|
|
|
+ " \"SubSystemId\": \"\"\n" +
|
|
|
+ "}";
|
|
|
+ //查询条件
|
|
|
+ Map<String, Object> map = JSON.parseObject(queryString, Map.class);
|
|
|
+ K3CloudApi api = new K3CloudApi();
|
|
|
+ List<JdProductionOrder> jdProductionOrders;
|
|
|
+ try {
|
|
|
+ String resultJson = api.billQuery(JSON.toJSONString(map));
|
|
|
+ //如果查询的数据为空
|
|
|
+ if(resultJson==""||resultJson=="[]"){
|
|
|
+ return "不能添加这次扫描记录";
|
|
|
+ }else{
|
|
|
+ //转换实体类对象
|
|
|
+ jdProductionOrders = JSON.parseArray(resultJson, JdProductionOrder.class);
|
|
|
+ //按照流转卡把信息查询出来了
|
|
|
+ if(jdProductionOrders.size()>0) {
|
|
|
+ //单据编号
|
|
|
+ String documentNumber = jdProductionOrders.get(0).getDocumentNumber();
|
|
|
+ //这个生产订单生产的数量
|
|
|
+ //String quantity = jdProductionOrders.get(0).getQuantity();
|
|
|
+ //根据生产订单号查询生产用料清单
|
|
|
+ String productionMaterialsListQuery="{\n" +
|
|
|
+ " \"FormId\": \"PRD_PPBOM\",\n" +
|
|
|
+ " \"FieldKeys\": \"FMaterialID.FNumber,FMaterialName,FMaterialModel,FMaterialModel2,FDescription,FMaterialID2.FNumber,FMaterialName1,FMaterialModel1,FUnitID2.FName,FMustQty,FMEMO1,FNumerator,FMaterialType,FProcessID.FName\",\n" +
|
|
|
+ " \"FilterString\": [],\n" +
|
|
|
+ " \"OrderString\": \"\",\n" +
|
|
|
+ " \"TopRowCount\": 0,\n" +
|
|
|
+ " \"StartRow\": 0,\n" +
|
|
|
+ " \"Limit\": 2000,\n" +
|
|
|
+ " \"SubSystemId\": \"\"\n" +
|
|
|
+ "}";
|
|
|
+ //查询生产用料清单
|
|
|
+ Map<String, Object> map2 = JSON.parseObject(productionMaterialsListQuery, Map.class);
|
|
|
+
|
|
|
+ String filterString = map2.get("FilterString").toString();
|
|
|
+
|
|
|
+ List<Map> mapList = JSON.parseArray(filterString, Map.class);
|
|
|
+ if(procedureListErps.size()>0){
|
|
|
+ //循环条件
|
|
|
+ procedureListErps.forEach(map1 -> {
|
|
|
+ String ddh="{\"Left\":\"\",\"FieldName\":\"FMOBillNO\",\"Compare\":\"67\",\"Value\":\"11\",\"Right\":\"\",\"Logic\":0}";
|
|
|
+ String mapTj="{\"Left\":\"\",\"FieldName\":\"FProcessID.FName\",\"Compare\":\"67\",\"Value\":\"111\",\"Right\":\"\",\"Logic\":1}";
|
|
|
+ Map mapObj = JSONObject.parseObject(mapTj, Map.class);
|
|
|
+ Map ddhObj = JSONObject.parseObject(ddh, Map.class);
|
|
|
+ ddhObj.put("Value", productNumber);
|
|
|
+ mapObj.put("Value", map1.getProcedurName());
|
|
|
+ mapList.add(ddhObj);
|
|
|
+ mapList.add(mapObj);
|
|
|
+ });
|
|
|
+ map2.put("FilterString", mapList);//从新绑定条件
|
|
|
+
|
|
|
+
|
|
|
+ //生产用料清单结果
|
|
|
+ String resultJsonJG = api.billQuery(JSON.toJSONString(map2));
|
|
|
+ //json转Java实体类对象
|
|
|
+ List<MaterialRetentionLogVo> materialRetentionLogVos = JSON.parseArray(resultJsonJG, MaterialRetentionLogVo.class);
|
|
|
+ //赋值一些默认值
|
|
|
+ List<MaterialRetentionLogVo> collect = materialRetentionLogVos.parallelStream().map(item -> {
|
|
|
+ item.setCkNumber("CK005");
|
|
|
+ item.setDeliveryWarehouse("车间仓");
|
|
|
+ item.setFlowSequenceNumber(lxkNumber);//流转序列号
|
|
|
+ item.setMesprocess(gxm); //工序
|
|
|
+ item.setOrderNumber(orderNumber); //订单
|
|
|
+ item.setProductionOrderNumber(productNumber); //生产订单
|
|
|
+ item.setCreateTime(new DateTime());//创建时间
|
|
|
+ return item;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ //分子数量基本的扣料单位
|
|
|
+ int i = materialRetentionLogMapper.insertMaterialRetentionLogBatch(collect);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.out.println(e);
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ }
|
|
|
+ return productNumber+gxm+"扣料成功";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String sweepingMaterial(String orderNumber,String productNumber,String gxm,String lxkNumber) {
|
|
|
+ //查询条件
|
|
|
+ String queryString = "{\n" +
|
|
|
+ " \"FormId\": \"PRD_MO\",\n" +
|
|
|
+ " \"FieldKeys\": \"FBillNo\",\n" +
|
|
|
+ " \"FilterString\": [{\"Left\":\"\",\"FieldName\":\"FSerialNo\",\"Compare\":\"67\",\"Value\":\"" + lxkNumber + "\",\"Right\":\"\",\"Logic\":0}],\n" +
|
|
|
+ " \"OrderString\": \"\",\n" +
|
|
|
+ " \"TopRowCount\": 0,\n" +
|
|
|
+ " \"StartRow\": 0,\n" +
|
|
|
+ " \"Limit\": 2000,\n" +
|
|
|
+ " \"SubSystemId\": \"\"\n" +
|
|
|
+ "}";
|
|
|
+ //查询条件
|
|
|
+ Map<String, Object> map = JSON.parseObject(queryString, Map.class);
|
|
|
+ K3CloudApi api = new K3CloudApi();
|
|
|
+ List<JdProductionOrder> jdProductionOrders;
|
|
|
+ try {
|
|
|
+ String resultJson = api.billQuery(JSON.toJSONString(map));
|
|
|
+ //如果查询的数据为空
|
|
|
+ if (resultJson == "" || resultJson == "[]") {
|
|
|
+ return "不能添加这次扫描记录";
|
|
|
+ } else {
|
|
|
+ //转换实体类对象
|
|
|
+ jdProductionOrders = JSON.parseArray(resultJson, JdProductionOrder.class);
|
|
|
+ //按照流转卡把信息查询出来了
|
|
|
+ if (jdProductionOrders.size() > 0) {
|
|
|
+ //单据编号
|
|
|
+ String documentNumber = jdProductionOrders.get(0).getDocumentNumber();
|
|
|
+ //这个生产订单生产的数量
|
|
|
+ //String quantity = jdProductionOrders.get(0).getQuantity();
|
|
|
+ //根据生产订单号查询生产用料清单
|
|
|
+ String productionMaterialsListQuery = "{\n" +
|
|
|
+ " \"FormId\": \"PRD_PPBOM\",\n" +
|
|
|
+ " \"FieldKeys\": \"FMaterialID.FNumber,FMaterialName,FMaterialModel,FMaterialModel2,FDescription,FMaterialID2.FNumber,FMaterialName1,FMaterialModel1,FUnitID2.FName,FMustQty,FMEMO1,FNumerator,FMaterialType,FProcessID.FName\",\n" +
|
|
|
+ " \"FilterString\": [],\n" +
|
|
|
+ " \"OrderString\": \"\",\n" +
|
|
|
+ " \"TopRowCount\": 0,\n" +
|
|
|
+ " \"StartRow\": 0,\n" +
|
|
|
+ " \"Limit\": 2000,\n" +
|
|
|
+ " \"SubSystemId\": \"\"\n" +
|
|
|
+ "}";
|
|
|
+ //查询生产用料清单
|
|
|
+ Map<String, Object> map2 = JSON.parseObject(productionMaterialsListQuery, Map.class);
|
|
|
+
|
|
|
+ String filterString = map2.get("FilterString").toString();
|
|
|
+
|
|
|
+ List<Map> mapList = JSON.parseArray(filterString, Map.class);
|
|
|
+
|
|
|
+ //循环条件
|
|
|
+ String ddh = "{\"Left\":\"\",\"FieldName\":\"FMOBillNO\",\"Compare\":\"67\",\"Value\":\"11\",\"Right\":\"\",\"Logic\":0}";
|
|
|
+ Map ddhObj = JSONObject.parseObject(ddh, Map.class);
|
|
|
+ ddhObj.put("Value", productNumber);
|
|
|
+ mapList.add(ddhObj);
|
|
|
+ map2.put("FilterString", mapList);//从新绑定条件
|
|
|
+
|
|
|
+
|
|
|
+ //全部MES工序
|
|
|
+ List<ProcedureList> procedureLists = procedureListMapper.selectProcedureListMap();
|
|
|
+
|
|
|
+ Map<String, String> gxMap = procedureLists.stream()
|
|
|
+ .filter(procedureList ->
|
|
|
+ procedureList.getElpname() != null && !procedureList.getElpname().isEmpty()) // 过滤条件
|
|
|
+ .collect(Collectors.toMap(ProcedureList::getElpname, ProcedureList::getProcedurName));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //生产用料清单结果
|
|
|
+ String resultJsonJG = api.billQuery(JSON.toJSONString(map2));
|
|
|
+ //json转Java实体类对象
|
|
|
+ List<MaterialRetentionLogVo> materialRetentionLogVos = JSON.parseArray(resultJsonJG, MaterialRetentionLogVo.class);
|
|
|
+ //赋值一些默认值
|
|
|
+ List<MaterialRetentionLogVo> collect = materialRetentionLogVos.parallelStream().map(item -> {
|
|
|
+ item.setCkNumber("CK005");
|
|
|
+ item.setDeliveryWarehouse("车间仓");
|
|
|
+ item.setFlowSequenceNumber(lxkNumber);//流转序列号
|
|
|
+ boolean present = Optional.ofNullable(gxMap.get(item.getProcess())).filter(a->!a.isEmpty()).isPresent();
|
|
|
+ if(present){
|
|
|
+ item.setMesprocess(gxMap.get(item.getProcess())); //工序
|
|
|
+ }else {
|
|
|
+ item.setMesprocess("未知工序");
|
|
|
+ }
|
|
|
+ item.setOrderNumber(orderNumber); //订单
|
|
|
+ item.setProductionOrderNumber(productNumber); //生产订单
|
|
|
+ item.setCreateTime(new DateTime());//创建时间
|
|
|
+ return item;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ //分子数量基本的扣料单位
|
|
|
+ int i = materialRetentionLogMapper.insertMaterialRetentionLogBatch(collect);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception ex) {
|
|
|
+ System.out.println(ex);
|
|
|
+ throw new RuntimeException(ex);
|
|
|
+ }
|
|
|
+ return productNumber + gxm + "扣料成功";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新包装还是更新检验
|
|
|
+ * @param ringScanInformationFirstNumber
|
|
|
+ * @param ringScanInformation
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private static RingScanInformationFirst getRingScanInformationFirst(String ringScanInformationFirstNumber, RingScanInformation ringScanInformation,String type) {
|
|
|
+ if(type.equals("1")){ //成品检验
|
|
|
+ String inspectionQuantity = ringScanInformationFirstNumber;
|
|
|
+ Double newInspectionQuantity = Double.parseDouble(inspectionQuantity) + 1;
|
|
|
+ Integer i1 = newInspectionQuantity.intValue();
|
|
|
+ RingScanInformationFirst newRingScanInformationFirst = new RingScanInformationFirst();
|
|
|
+ newRingScanInformationFirst.setProductionOrderNumber(ringScanInformation.getProductionOrderNumber());
|
|
|
+ newRingScanInformationFirst.setPackingQuantity(i1.toString());
|
|
|
+ //入库数量跟随,成品检验同步更新
|
|
|
+ newRingScanInformationFirst.setRks(i1.toString());
|
|
|
+ return newRingScanInformationFirst;
|
|
|
+ }else if(type.equals("2")) { //试机检验
|
|
|
+ String inspectionQuantity = ringScanInformationFirstNumber;
|
|
|
+ Double newInspectionQuantity = Double.parseDouble(inspectionQuantity) + 1;
|
|
|
+ Integer i2 = newInspectionQuantity.intValue();
|
|
|
+ RingScanInformationFirst newRingScanInformationFirst = new RingScanInformationFirst();
|
|
|
+ newRingScanInformationFirst.setProductionOrderNumber(ringScanInformation.getProductionOrderNumber());
|
|
|
+ newRingScanInformationFirst.setInspectionQuantity(i2.toString());
|
|
|
+ //入库数量跟随,成品检验同步更新
|
|
|
+ newRingScanInformationFirst.setRks(i2.toString());
|
|
|
+
|
|
|
+ return newRingScanInformationFirst;
|
|
|
+ }else if(type.equals("3")) {//入库
|
|
|
+ String rKQuantity = ringScanInformationFirstNumber;
|
|
|
+ Double newRkQuantity = Double.parseDouble(rKQuantity) + 1;
|
|
|
+ Integer i2 = newRkQuantity.intValue();
|
|
|
+ RingScanInformationFirst newRingScanInformationFirst = new RingScanInformationFirst();
|
|
|
+ newRingScanInformationFirst.setProductionOrderNumber(ringScanInformation.getProductionOrderNumber());
|
|
|
+ newRingScanInformationFirst.setRks(i2.toString());
|
|
|
+ return newRingScanInformationFirst;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 判断走入库还是走生产汇报的逻辑
|
|
|
+ * 前置一直在更新,包装检验,或者试机的数量,如果满足就创建生产汇报单据
|
|
|
+ * 前置也在更新,可入库的数量,如果满足就下推生产入库单。
|
|
|
+ * @param productionOrderNumber
|
|
|
+ * type 1入成品 type 2 入利库 type 3走工序汇报逻辑,实际我并没有获取这个参数
|
|
|
+ */
|
|
|
+ public String generateWarehouseWarrant(String productionOrderNumber,String gxName,String type,RingScanInformation ringScanInformation){
|
|
|
+ if(gxName.equals("入库")){
|
|
|
+ RingScanInformationFirst newRingScanInformationFirst = new RingScanInformationFirst();
|
|
|
+ newRingScanInformationFirst.setProductionOrderNumber(productionOrderNumber);
|
|
|
+ //查询第一次新增时确定的是试机入库还是包装入库
|
|
|
+ List<RingScanInformationFirst> ringScanInformationFirsts1 = ringScanInformationFirstMapper.selectRingScanInformationFirstList(newRingScanInformationFirst);
|
|
|
+ if(ringScanInformationFirsts1.size()>0) {
|
|
|
+ RingScanInformationFirst ringScanInformationFirst = ringScanInformationFirsts1.get(0);
|
|
|
+ //包装或者检验
|
|
|
+ String packingOrInspection = ringScanInformationFirst.getPackingOrInspection();
|
|
|
+ if(packingOrInspection.equals("1")){//检查包装检验 --够了--下推入库单
|
|
|
+ PlanTaskDetails planTaskDetails=new PlanTaskDetails();
|
|
|
+ planTaskDetails.setDemandDocument(productionOrderNumber);
|
|
|
+ //查询即将入库的产品信息
|
|
|
+ List<PlanTaskDetails> planTaskDetails1 = planTaskDetailsMapper.selectPlanTaskDetailsList(planTaskDetails);
|
|
|
+ if(ringScanInformationFirst.getRks().equals(ringScanInformationFirst.getProductionOrderTotalQuantity())){
|
|
|
+ //加更正生产订单状态
|
|
|
+ planTaskDetails.setStatus("2");//生产完成
|
|
|
+ int i2 = planTaskDetailsMapper.updatePlanTaskDetailsByDemandDocument(planTaskDetails);
|
|
|
+ }
|
|
|
+ //入库 typ 1 入成品 type 入利库
|
|
|
+ Map<String,String> ac= erpWareHouSing(planTaskDetails1.get(0), type, ringScanInformation, "单量推送");
|
|
|
+ if(ac.get("msg").equals("未查询到生产汇报信息")){
|
|
|
+ return "未查询到生产汇报信息";
|
|
|
+ }
|
|
|
+ if(ac.get("msg").equals("入库单创建失败")){
|
|
|
+ return "入库单创建失败"+ac.get("error");
|
|
|
+ }
|
|
|
+ if(ac.get("msg").equals("入库单提交失败")){
|
|
|
+ return "入库单提交失败";
|
|
|
+ }
|
|
|
+ if(ac.get("msg").equals("入库单审核失败")){
|
|
|
+ return "入库单审核失败";
|
|
|
+ }
|
|
|
+ return "入库成功";
|
|
|
+ }else if(packingOrInspection.equals("2")){ //试机数量 --够了--下推入库单
|
|
|
+ //入库数量等于生产订单总数那么就发起入库申请
|
|
|
+ if(ringScanInformationFirst.getRks().equals(ringScanInformationFirst.getProductionOrderTotalQuantity())){
|
|
|
+ PlanTaskDetails planTaskDetails=new PlanTaskDetails();
|
|
|
+ planTaskDetails.setDemandDocument(productionOrderNumber);
|
|
|
+ int i = planTaskDetailsMapper.updatePlanTaskDetailsByDemandDocument(planTaskDetails);
|
|
|
+ //查询即将入库的产品信息
|
|
|
+ List<PlanTaskDetails> planTaskDetails1 = planTaskDetailsMapper.selectPlanTaskDetailsList(planTaskDetails);
|
|
|
+ //入库 typ 1 入成品 type 入利库
|
|
|
+ Map<String,String> ac= erpWareHouSing(planTaskDetails1.get(0), type, ringScanInformation, "全量推送");
|
|
|
+ if(ac.get("msg").equals("未查询到生产汇报信息")){
|
|
|
+ return "未查询到生产汇报信息";
|
|
|
+ }
|
|
|
+ if(ac.get("msg").equals("入库单创建失败")){
|
|
|
+ return "入库单创建失败"+ac.get("error");
|
|
|
+ }
|
|
|
+ if(ac.get("msg").equals("入库单提交失败")){
|
|
|
+ return "入库单创建失败";
|
|
|
+ }
|
|
|
+ if(ac.get("msg").equals("入库单审核失败")){
|
|
|
+ return "入库单审核失败";
|
|
|
+ }
|
|
|
+ //加更正生产订单状态
|
|
|
+ planTaskDetails.setStatus("2");//生产完成
|
|
|
+ int i2 = planTaskDetailsMapper.updatePlanTaskDetailsByDemandDocument(planTaskDetails);
|
|
|
+ return "入库成功";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return "正在入库";
|
|
|
+ }else if(type.equals("3")||type.equals("4")){//等于代表走工序汇报逻辑 1 和 2代表入的什么仓库(1:成品 2:利库) 3和4 代表走工序汇报逻辑(3:成品 4:利库)
|
|
|
+ RingScanInformationFirst newRingScanInformationFirst = new RingScanInformationFirst();
|
|
|
+ newRingScanInformationFirst.setProductionOrderNumber(productionOrderNumber);
|
|
|
+ //查询第一次新增时确定的是试机入库还是包装入库
|
|
|
+ List<RingScanInformationFirst> ringScanInformationFirsts1 = ringScanInformationFirstMapper.selectRingScanInformationFirstList(newRingScanInformationFirst);
|
|
|
+ if(ringScanInformationFirsts1.size()>0){
|
|
|
+ RingScanInformationFirst ringScanInformationFirst = ringScanInformationFirsts1.get(0);
|
|
|
+ String packingOrInspection = ringScanInformationFirst.getPackingOrInspection();
|
|
|
+ //改当前生产订单的状态
|
|
|
+ PlanTaskDetails planTaskDetails=new PlanTaskDetails();
|
|
|
+ planTaskDetails.setDemandDocument(productionOrderNumber);
|
|
|
+ //查询即将入库的产品信息
|
|
|
+ List<PlanTaskDetails> planTaskDetails1 = planTaskDetailsMapper.selectPlanTaskDetailsList(planTaskDetails);
|
|
|
+ //检查包装或者试机数量
|
|
|
+ if(packingOrInspection.equals("1")){//检查成品检验 --如果够了-下推生产汇报单
|
|
|
+ //看包装跟当前生产订单总数量是否相等
|
|
|
+ if(ringScanInformationFirst.getPackingQuantity().equals(ringScanInformationFirst.getProductionOrderTotalQuantity())){
|
|
|
+ //加更正生产订单状态
|
|
|
+ planTaskDetails.setStatus("2");//生产完成
|
|
|
+ int i2 = planTaskDetailsMapper.updatePlanTaskDetailsByDemandDocument(planTaskDetails);
|
|
|
+ //扣料操作
|
|
|
+ String s = sweepingMaterial(ringScanInformation.getOrderNumber(), ringScanInformation.getProductionOrderNumber(), //订单号 生产订单号
|
|
|
+ ringScanInformation.getProcessName(), ringScanInformation.getNativeNumbering());//工序 流转卡信息
|
|
|
+ }
|
|
|
+ //工序汇报 0 为单个推送
|
|
|
+ Map<String,String> aa = erpProcessReport(planTaskDetails1.get(0),type,"单量推送",ringScanInformation);
|
|
|
+ if(aa.get("msg").equals("工序汇报创建失败")){
|
|
|
+ return aa.get("msg")+aa.get("error");
|
|
|
+ }
|
|
|
+ if(aa.get("msg").equals("工序汇报提交失败")){
|
|
|
+ return aa.get("msg")+aa.get("error");
|
|
|
+ }
|
|
|
+ if(aa.get("msg").equals("工序汇报审核失败")){
|
|
|
+ return aa.get("msg")+aa.get("error");
|
|
|
+ }
|
|
|
+ System.out.println("工序汇报单量推送");
|
|
|
+ }else if(packingOrInspection.equals("2")){ //试机数量--下推生产汇报单
|
|
|
+ //看包装跟当前生产订单总数量是否相等
|
|
|
+ if(ringScanInformationFirst.getInspectionQuantity().equals(ringScanInformationFirst.getProductionOrderTotalQuantity())){
|
|
|
+ //生产汇报 1为批量推送
|
|
|
+ Map<String,String> aa = erpProcessReport(planTaskDetails1.get(0), type, "全量推送", ringScanInformation);
|
|
|
+ if(aa.get("msg").equals("工序汇报创建失败")){
|
|
|
+ return aa.get("msg")+aa.get("error");
|
|
|
+ }
|
|
|
+ if(aa.get("msg").equals("工序汇报提交失败")){
|
|
|
+ return aa.get("msg")+aa.get("error");
|
|
|
+ }
|
|
|
+ if(aa.get("msg").equals("工序汇报审核失败")){
|
|
|
+ return aa.get("msg")+aa.get("error");
|
|
|
+ }
|
|
|
+ //扣料操作
|
|
|
+ String s = sweepingMaterial(ringScanInformation.getOrderNumber(), ringScanInformation.getProductionOrderNumber(), //订单号 生产订单号
|
|
|
+ ringScanInformation.getProcessName(), ringScanInformation.getNativeNumbering());//工序 流转卡信息
|
|
|
+ //加更正生产订单状态
|
|
|
+ planTaskDetails.setStatus("2");//生产完成
|
|
|
+ int i2 = planTaskDetailsMapper.updatePlanTaskDetailsByDemandDocument(planTaskDetails);
|
|
|
+ System.out.println("工序汇报全量推送");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return "工序汇报成功";
|
|
|
+ }
|
|
|
+ return "有问题请联系管理员";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生产汇报单是否下推提交审核成功
|
|
|
+ * txfs:判断是成品检验还是试机检验
|
|
|
+ * @param planTaskDetails1
|
|
|
+ */
|
|
|
+ private Map<String,String> erpProcessReport(PlanTaskDetails planTaskDetails1,String type,String txfs,RingScanInformation ringScanInformation) {
|
|
|
+
|
|
|
+ //生产汇报
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ try {
|
|
|
+ Map<String, Object> jsonData = objectMapper.readValue(processReport.getInputStream(), Map.class);
|
|
|
+ //得到Model
|
|
|
+ String model1 = objectMapper.writeValueAsString(jsonData.get("Model"));
|
|
|
+ Map<String,Object> modelMap = objectMapper.readValue(model1, Map.class);
|
|
|
+ String localDateTimeStr = DateUtils.toLocalDateTimeStr(LocalDateTime.now());
|
|
|
+ modelMap.put("FDate",localDateTimeStr);
|
|
|
+ //得到FEntity
|
|
|
+ String fEntityString = objectMapper.writeValueAsString(modelMap.get("FEntity"));
|
|
|
+ List<Map> list = objectMapper.readValue(fEntityString, List.class);
|
|
|
+ Map map = list.get(0);
|
|
|
+ String fMaterialId = map.get("FMaterialId").toString();
|
|
|
+ map.put("FSrcEntryId",planTaskDetails1.getFtreeEntityFentryid());
|
|
|
+ String fMaterialIdString = objectMapper.writeValueAsString(map.get("FMaterialId"));
|
|
|
+ Map<String,String > map1 = objectMapper.readValue(fMaterialIdString, Map.class);
|
|
|
+ map1.put("FNumber",planTaskDetails1.getMaterialId());
|
|
|
+ map.put("FMaterialId",map1);
|
|
|
+
|
|
|
+ //生产车间信息
|
|
|
+ boolean present = Optional.ofNullable(planTaskDetails1.getShopCoding()).filter(a -> !a.isEmpty()).isPresent();
|
|
|
+ if(present){
|
|
|
+ HashMap<String, String> shopCoding = new HashMap<>();
|
|
|
+ shopCoding.put("FNumber",planTaskDetails1.getShopCoding());
|
|
|
+ map.put("FWorkshipId",shopCoding);
|
|
|
+ }
|
|
|
+
|
|
|
+ map.put("FMoBillNo",planTaskDetails1.getDemandDocument());
|
|
|
+ map.put("FSrcBillNo",planTaskDetails1.getDemandDocument()); //生产订单号
|
|
|
+ map.put("FReqBillNo",ringScanInformation.getOverNumber()); //订单号
|
|
|
+ map.put("FStartTime",localDateTimeStr);
|
|
|
+ map.put("FEndTime",localDateTimeStr);
|
|
|
+ HashMap fbomdIdMap=new HashMap();
|
|
|
+ fbomdIdMap.put("FNumber",planTaskDetails1.getFbomIdFnumber());
|
|
|
+ map.put("FBomId",fbomdIdMap);
|
|
|
+
|
|
|
+ //单位
|
|
|
+ HashMap<String,String> dw=new HashMap();
|
|
|
+ dw.put("FNumber",planTaskDetails1.getFunitidfNumber());
|
|
|
+ map.put("FUnitID",dw);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //基本单位
|
|
|
+ HashMap<String,String> baseUtil=new HashMap();
|
|
|
+ baseUtil.put("FNumber",planTaskDetails1.getfBaseUnitId());
|
|
|
+ map.put("FBaseUnitId",baseUtil);
|
|
|
+
|
|
|
+
|
|
|
+ HashMap FStockId=new HashMap();
|
|
|
+ if(type.equals("3")){
|
|
|
+ FStockId.put("FNumber","CK007"); //成品仓
|
|
|
+ }else if(type.equals("4")) {
|
|
|
+ FStockId.put("FNumber","CK006"); //利库仓
|
|
|
+ }
|
|
|
+
|
|
|
+ map.put("FStockId",FStockId);
|
|
|
+
|
|
|
+ //序列号单位
|
|
|
+ String FSNUnitIDJson = objectMapper.writeValueAsString( map.get("FSNUnitID"));
|
|
|
+ Map<String,String > FSNUnitIDMap = objectMapper.readValue(FSNUnitIDJson, Map.class);
|
|
|
+ FSNUnitIDMap.put("FNumber",planTaskDetails1.getFunitidfNumber());
|
|
|
+ map.put("FSNUnitID",FSNUnitIDMap);//序列号单位
|
|
|
+
|
|
|
+ map.put("FReqBillNo",planTaskDetails1.getFsrcbillno()); //源单编号
|
|
|
+ map.put("FSrcInterId",planTaskDetails1.getFid());
|
|
|
+ map.put("FMoId",planTaskDetails1.getFid());
|
|
|
+ map.put("FMoEntryId",planTaskDetails1.getFtreeEntityFentryid());
|
|
|
+ map.put("FMOMAINENTRYID",planTaskDetails1.getFtreeEntityFentryid());
|
|
|
+
|
|
|
+ if(txfs.equals("全量推送")){
|
|
|
+ //序列号单据体---循环
|
|
|
+ ProductionCardFlow productionCardFlow=new ProductionCardFlow();
|
|
|
+ productionCardFlow.setDemandDocumentNumber(planTaskDetails1.getDemandDocument());//流转卡序列号
|
|
|
+ List<ProductionCardFlow> productionCardFlows = productionCardFlowMapper.selectProductionCardFlowList(productionCardFlow);
|
|
|
+
|
|
|
+ map.put("FSNQty",productionCardFlows.size()); //序列号数量
|
|
|
+ map.put("FFinishQty",planTaskDetails1.getQuantity()); //完成数量
|
|
|
+ map.put("FFinishQty",planTaskDetails1.getQuantity()); //合格数量
|
|
|
+
|
|
|
+ List<Map> list1=new ArrayList<>();
|
|
|
+ //String FSerialSubEntity = map.get("FSerialSubEntity").toString();
|
|
|
+ String FSerialSubEntityJson = objectMapper.writeValueAsString( map.get("FSerialSubEntity"));
|
|
|
+ List<Map> fSerialSubEntitylist = objectMapper.readValue(FSerialSubEntityJson, List.class);
|
|
|
+ productionCardFlows.forEach(item->{
|
|
|
+ try {
|
|
|
+ // 将 fSerialSubEntitylist.get(0) 转换为 JSON 字符串,再反序列化为新的 Map
|
|
|
+ String map2Json = objectMapper.writeValueAsString(fSerialSubEntitylist.get(0));
|
|
|
+ Map<String, Object> map2 = objectMapper.readValue(map2Json, Map.class);
|
|
|
+
|
|
|
+ // 修改 map2 中的 FSerialNo
|
|
|
+ map2.put("FSerialNo", item.getSerialNumber());
|
|
|
+
|
|
|
+ // 处理 FSerialId
|
|
|
+ Map<String, String> fSerialIdMap = null;
|
|
|
+ if (map2.get("FSerialId") != null) {
|
|
|
+ String fSerialIdJson = objectMapper.writeValueAsString(map2.get("FSerialId"));
|
|
|
+ fSerialIdMap = objectMapper.readValue(fSerialIdJson, Map.class);
|
|
|
+ } else {
|
|
|
+ fSerialIdMap = new HashMap<>();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 修改 FSerialId 中的 FNUMBER
|
|
|
+ fSerialIdMap.put("FNUMBER", item.getSerialNumber());
|
|
|
+ map2.put("FSerialId", fSerialIdMap);
|
|
|
+
|
|
|
+ // 将修改后的 map2 添加到 list1
|
|
|
+ list1.add(map2);
|
|
|
+ } catch (JsonProcessingException e) {
|
|
|
+ System.out.println(e);
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ map.put("FSerialSubEntity",list1);
|
|
|
+ }else if(txfs.equals("单量推送")) { //==等于0的情况
|
|
|
+ //序列号单据体---循环
|
|
|
+ ProductionCardFlow productionCardFlow=new ProductionCardFlow();
|
|
|
+ productionCardFlow.setSerialNumber(ringScanInformation.getNativeNumbering());//流转卡序列号
|
|
|
+ List<ProductionCardFlow> productionCardFlows = productionCardFlowMapper.selectProductionCardFlowList(productionCardFlow);
|
|
|
+
|
|
|
+ map.put("FSNQty","1"); //序列号数量
|
|
|
+ map.put("FFinishQty","1"); //完成数量
|
|
|
+ map.put("FFinishQty","1"); //合格数量
|
|
|
+
|
|
|
+ List<Map> list1=new ArrayList<>();
|
|
|
+ String FSerialSubEntityJson = objectMapper.writeValueAsString( map.get("FSerialSubEntity"));
|
|
|
+ List<Map> fSerialSubEntitylist = objectMapper.readValue(FSerialSubEntityJson, List.class);
|
|
|
+ productionCardFlows.forEach(item->{
|
|
|
+ try {
|
|
|
+ // 将 fSerialSubEntitylist.get(0) 转换为 JSON 字符串,再反序列化为新的 Map
|
|
|
+ String map2Json = objectMapper.writeValueAsString(fSerialSubEntitylist.get(0));
|
|
|
+ Map<String, Object> map2 = objectMapper.readValue(map2Json, Map.class);
|
|
|
+
|
|
|
+ // 修改 map2 中的 FSerialNo
|
|
|
+ map2.put("FSerialNo", item.getSerialNumber());
|
|
|
+
|
|
|
+ // 处理 FSerialId
|
|
|
+ Map<String, String> fSerialIdMap = null;
|
|
|
+ if (map2.get("FSerialId") != null) {
|
|
|
+ String fSerialIdJson = objectMapper.writeValueAsString(map2.get("FSerialId"));
|
|
|
+ fSerialIdMap = objectMapper.readValue(fSerialIdJson, Map.class);
|
|
|
+ } else {
|
|
|
+ fSerialIdMap = new HashMap<>();
|
|
|
+ }
|
|
|
+ // 修改 FSerialId 中的 FNUMBER
|
|
|
+ fSerialIdMap.put("FNUMBER", item.getSerialNumber());
|
|
|
+ map2.put("FSerialId", fSerialIdMap);
|
|
|
+
|
|
|
+ // 将修改后的 map2 添加到 list1
|
|
|
+ list1.add(map2);
|
|
|
+ } catch (JsonProcessingException e) {
|
|
|
+ System.out.println(e);
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ map.put("FSerialSubEntity",list1);
|
|
|
+ }
|
|
|
+ //表连接关系
|
|
|
+ String FEntity_LinkJSON = objectMapper.writeValueAsString(map.get("FEntity_Link"));
|
|
|
+ List<Map> FEntity_LinkJSONList = objectMapper.readValue(FEntity_LinkJSON, List.class);
|
|
|
+ Map map3 = FEntity_LinkJSONList.get(0);
|
|
|
+ map3.put("FEntity_Link_FSBillId",planTaskDetails1.getFid());
|
|
|
+ map3.put("FEntity_Link_FSId",planTaskDetails1.getFtreeEntityFentryid());
|
|
|
+ List<Map> list2=new ArrayList<>();
|
|
|
+ list2.add(map3);
|
|
|
+ map.put("FEntity_Link",list2);
|
|
|
+ List<Map> FEntityList=new ArrayList<>();
|
|
|
+ FEntityList.add(map);
|
|
|
+ modelMap.put("FEntity",FEntityList);
|
|
|
+
|
|
|
+ //转成String 字符
|
|
|
+
|
|
|
+ jsonData.put("Model", modelMap);
|
|
|
+
|
|
|
+ String zxJson = objectMapper.writeValueAsString(jsonData);
|
|
|
+ //生产用料清单结果
|
|
|
+ K3CloudApi api = new K3CloudApi();
|
|
|
+ try {
|
|
|
+ //执行JSO结果
|
|
|
+ String resultJsonJG = api.save("PRD_MORPT", zxJson);
|
|
|
+ //分析结构
|
|
|
+ Map resultString = objectMapper.readValue(resultJsonJG, Map.class);
|
|
|
+
|
|
|
+ String result = objectMapper.writeValueAsString(resultString.get("Result"));
|
|
|
+ Map<String,Object> resultMap= objectMapper.readValue(result, Map.class);
|
|
|
+ String number = resultMap.get("Number").toString();//编号
|
|
|
+
|
|
|
+ Map<String,String> s4 = documentExecutionJudgment(objectMapper, resultJsonJG, "工序汇报创建成功", "工序汇报创建失败");
|
|
|
+ if(s4.get("msg").equals("工序汇报创建失败")){
|
|
|
+ return s4;
|
|
|
+ }
|
|
|
+ //执行提交
|
|
|
+ String tjQuery="{\n" +
|
|
|
+ " \"Numbers\": [],\n" +
|
|
|
+ " \"Ids\": \"\",\n" +
|
|
|
+ " \"SelectedPostId\": 0,\n" +
|
|
|
+ " \"NetworkCtrl\": \"\",\n" +
|
|
|
+ " \"IgnoreInterationFlag\": \"true\"\n" +
|
|
|
+ "}";
|
|
|
+ Map map4 = objectMapper.readValue(tjQuery, Map.class);
|
|
|
+
|
|
|
+ List<String> numberjson = new ArrayList<>();
|
|
|
+ numberjson.add(number);
|
|
|
+ map4.put("Numbers",numberjson);
|
|
|
+ String tjExeJSON = objectMapper.writeValueAsString(map4);
|
|
|
+ String s1 = api.submit("PRD_MORPT",tjExeJSON);
|
|
|
+ Map<String,String> s3 = documentExecutionJudgment(objectMapper, s1, "工序汇提交成功", "工序汇报提交失败");
|
|
|
+ if(s3.get("msg").equals("工序汇报提交失败")){
|
|
|
+ return s3;
|
|
|
+ }
|
|
|
+ //执行审核
|
|
|
+ String shQuery="{\n" +
|
|
|
+ " \"Numbers\": [],\n" +
|
|
|
+ " \"Ids\": \"\",\n" +
|
|
|
+ " \"InterationFlags\": \"\",\n" +
|
|
|
+ " \"NetworkCtrl\": \"\",\n" +
|
|
|
+ " \"IsVerifyProcInst\": \"\",\n" +
|
|
|
+ " \"IgnoreInterationFlag\": \"true\",\n" +
|
|
|
+ " \"UseBatControlTimes\": \"false\"\n" +
|
|
|
+ "}";
|
|
|
+
|
|
|
+ Map map5 = objectMapper.readValue(shQuery, Map.class);
|
|
|
+ List<String> number2json = new ArrayList<>();
|
|
|
+ number2json.add(number);
|
|
|
+ map5.put("Numbers",number2json);
|
|
|
+ String shExeJSON = objectMapper.writeValueAsString(map4);
|
|
|
+ String s2 = api.audit("PRD_MORPT",shExeJSON);
|
|
|
+ Map<String,String> s = documentExecutionJudgment(objectMapper, s2, "工序汇报审核成功", "工序汇报审核失败");
|
|
|
+ if(s.get("msg").equals("工序汇报审核失败")){
|
|
|
+ return s;
|
|
|
+ }
|
|
|
+ if(s.equals("工序汇报审核成功")){
|
|
|
+ //添加一张审核记录表,单据编号,序列号,数量
|
|
|
+ ProductionReportingRecord productionReportingRecord=new ProductionReportingRecord();
|
|
|
+ if(txfs.equals("全量推送")) {
|
|
|
+ //序列号单据体---循环
|
|
|
+ ProductionCardFlow productionCardFlow = new ProductionCardFlow();
|
|
|
+ productionCardFlow.setDemandDocumentNumber(planTaskDetails1.getDemandDocument());//流转卡序列号
|
|
|
+ List<ProductionCardFlow> productionCardFlows = productionCardFlowMapper.selectProductionCardFlowList(productionCardFlow);
|
|
|
+ if(productionCardFlows.size()>0){
|
|
|
+ //单据编号
|
|
|
+ productionReportingRecord.setNumber(number);
|
|
|
+ //整体的所有序列号
|
|
|
+ productionReportingRecord.setXlhArray(productionCardFlows.stream().map(ProductionCardFlow::getSerialNumber).collect(Collectors.joining(",")));
|
|
|
+ productionReportingRecord.setType("2");//试机检验
|
|
|
+ }
|
|
|
+ productionReportingRecordMapper.insertProductionReportingRecord(productionReportingRecord);
|
|
|
+ }else if(txfs.equals("单量推送")) {
|
|
|
+ //序列号单据体---循环
|
|
|
+ ProductionCardFlow productionCardFlow=new ProductionCardFlow();
|
|
|
+ productionCardFlow.setSerialNumber(ringScanInformation.getNativeNumbering());//流转卡序列号
|
|
|
+ List<ProductionCardFlow> productionCardFlows = productionCardFlowMapper.selectProductionCardFlowList(productionCardFlow);
|
|
|
+ if (productionCardFlows.size()>0){
|
|
|
+ //单据编号
|
|
|
+ productionReportingRecord.setNumber(number);
|
|
|
+ //只有一个序列号
|
|
|
+ productionReportingRecord.setXlh(productionCardFlows.get(0).getSerialNumber());
|
|
|
+ productionReportingRecord.setType("1");//成品检验
|
|
|
+ productionReportingRecordMapper.insertProductionReportingRecord(productionReportingRecord);
|
|
|
+ System.out.println("保存工序汇报单据数据成功");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.out.println(e);
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ System.out.println(e);
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ }
|
|
|
+ HashMap hashMap=new HashMap();
|
|
|
+ hashMap.put("msg","工序汇报成功");
|
|
|
+ return hashMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 操作ERP生产入库单
|
|
|
+ * @param planTaskDetails1
|
|
|
+ * planTaskDetails1 产品信息
|
|
|
+ * type 入那个库
|
|
|
+ * ringScanInformation 扫描信息
|
|
|
+ */
|
|
|
+ private Map<String,String> erpWareHouSing(PlanTaskDetails planTaskDetails1,String type,RingScanInformation ringScanInformation,String isDOrQ){
|
|
|
+ //生产汇报
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ //生产用料清单结果
|
|
|
+ K3CloudApi api = new K3CloudApi();
|
|
|
+ try {
|
|
|
+ String nr="";
|
|
|
+ if(isDOrQ.equals("单量推送")){
|
|
|
+ //当前扫描的序列号信息
|
|
|
+ String nativeNumbering = ringScanInformation.getNativeNumbering();
|
|
|
+ ProductionReportingRecord productionReportingRecord=new ProductionReportingRecord();
|
|
|
+ productionReportingRecord.setXlh(nativeNumbering);
|
|
|
+ List<ProductionReportingRecord> productionReportingRecords = productionReportingRecordMapper.selectProductionReportingRecordList(productionReportingRecord);
|
|
|
+ if(productionReportingRecords.size()>0){
|
|
|
+ //查询生产汇报工序的基本信息
|
|
|
+ nr="{\n" +
|
|
|
+ " \"FormId\": \"PRD_MORPT\",\n" +
|
|
|
+ " \"FieldKeys\": \"fbillno,fid,FSrcBillNo,FEntity_FEntryId,FDate,FUnitID.FNumber\",\n" +
|
|
|
+ " \"FilterString\": [{\"Left\":\"\",\"FieldName\":\"FBillNo\",\"Compare\":\"17\",\"Value\":\""+productionReportingRecords.get(0).getNumber()+"\",\"Right\":\"\",\"Logic\":0}],\n" +
|
|
|
+ " \"OrderString\": \"\",\n" +
|
|
|
+ " \"TopRowCount\": 0,\n" +
|
|
|
+ " \"StartRow\": 0,\n" +
|
|
|
+ " \"Limit\": 2000,\n" +
|
|
|
+ " \"SubSystemId\": \"\"\n" +
|
|
|
+ "}";
|
|
|
+ }else{
|
|
|
+ Map<String,String> abc= new HashMap<>();
|
|
|
+ abc.put("msg","未查询到生产汇报信息");
|
|
|
+ return abc;
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ //查询生产汇报工序的基本信息
|
|
|
+ nr="{\n" +
|
|
|
+ " \"FormId\": \"PRD_MORPT\",\n" +
|
|
|
+ " \"FieldKeys\": \"fbillno,fid,FSrcBillNo,FEntity_FEntryId,FDate,FUnitID.FNumber\",\n" +
|
|
|
+ " \"FilterString\": [{\"Left\":\"\",\"FieldName\":\"FSrcBillNo\",\"Compare\":\"17\",\"Value\":\""+planTaskDetails1.getDemandDocument()+"\",\"Right\":\"\",\"Logic\":0}],\n" +
|
|
|
+ " \"OrderString\": \"\",\n" +
|
|
|
+ " \"TopRowCount\": 0,\n" +
|
|
|
+ " \"StartRow\": 0,\n" +
|
|
|
+ " \"Limit\": 2000,\n" +
|
|
|
+ " \"SubSystemId\": \"\"\n" +
|
|
|
+ "}";
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询结果
|
|
|
+ String nrString = api.billQuery(nr);
|
|
|
+
|
|
|
+ List<Map> mapList1 = JSONArray.parseArray(nrString, Map.class);
|
|
|
+ Map map2 = mapList1.get(0);
|
|
|
+ String fbillno = map2.get("fbillno").toString();
|
|
|
+ String fid = map2.get("fid").toString();
|
|
|
+ String FEntityFEntryId = map2.get("FEntity.FEntryId").toString();
|
|
|
+ String FDate = map2.get("FDate").toString();
|
|
|
+ String FSrcBillNo = map2.get("FSrcBillNo").toString();
|
|
|
+ String FUnitIDFNumber = map2.get("FUnitID.FNumber").toString();//基本单位
|
|
|
+
|
|
|
+ //生成入库单
|
|
|
+ Map<String, Object> jsonData2 = objectMapper.readValue(storage.getInputStream(), LinkedHashMap.class);
|
|
|
+ //得到Model
|
|
|
+ String model2 = objectMapper.writeValueAsString(jsonData2.get("Model"));
|
|
|
+ LinkedHashMap map6 = JSONObject.parseObject(model2, LinkedHashMap.class);
|
|
|
+ map6.put("FDate",DateUtils.toLocalDateTimeStr(LocalDateTime.now()));
|
|
|
+ String fEntity1 = objectMapper.writeValueAsString(map6.get("FEntity"));
|
|
|
+ List<LinkedHashMap> mapList = JSONArray.parseArray(fEntity1, LinkedHashMap.class);
|
|
|
+ LinkedHashMap map7 = mapList.get(0);
|
|
|
+ map7.put("F_PONP_HBRQ",FDate);
|
|
|
+
|
|
|
+ map7.put("FSrcEntryId",FEntityFEntryId);
|
|
|
+ map7.put("FSrcInterId",fid);
|
|
|
+ map7.put("FSrcBillNo",fbillno);
|
|
|
+ map7.put("FMoBillNo",planTaskDetails1.getDemandDocument());
|
|
|
+ map7.put("FMoId",planTaskDetails1.getFid());
|
|
|
+ map7.put("FMoEntryId",planTaskDetails1.getFtreeEntityFentryid());
|
|
|
+ map7.put("FReqBillNo",planTaskDetails1.getFsrcbillno()); //订单号
|
|
|
+ map7.put("FMOMAINENTRYID",planTaskDetails1.getFtreeEntityFentryid());
|
|
|
+ HashMap<String, String> fStockId = new HashMap<>();
|
|
|
+ if(type.equals("1")){
|
|
|
+ fStockId.put("FNumber","CK007"); //成品仓
|
|
|
+ }else {
|
|
|
+ fStockId.put("FNumber","CK006"); //利库仓
|
|
|
+ }
|
|
|
+ map7.put("FStockId",fStockId);
|
|
|
+ HashMap<String, String> fNumber = new HashMap<>();
|
|
|
+ fNumber.put("FNumber",planTaskDetails1.getMaterialId());
|
|
|
+ map7.put("FMaterialId",fNumber);
|
|
|
+
|
|
|
+ //生产车间信息
|
|
|
+ boolean present = Optional.ofNullable(planTaskDetails1.getShopCoding()).filter(a -> !a.isEmpty()).isPresent();
|
|
|
+ if(present){
|
|
|
+ HashMap<String, String> shopCoding = new HashMap<>();
|
|
|
+ shopCoding.put("FNumber",planTaskDetails1.getShopCoding());
|
|
|
+ map7.put("FWorkshipId",shopCoding);
|
|
|
+ }
|
|
|
+
|
|
|
+ //单位
|
|
|
+ HashMap<String, String> fUnitIDfNumber = new HashMap<>();
|
|
|
+ fUnitIDfNumber.put("FNumber",FUnitIDFNumber);
|
|
|
+ map7.put("FUnitID",fUnitIDfNumber);
|
|
|
+
|
|
|
+ //基本单位
|
|
|
+ HashMap<String, String> fBaseUnitIdFNumber = new HashMap<>();
|
|
|
+ fBaseUnitIdFNumber.put("FNumber",planTaskDetails1.getfBaseUnitId());
|
|
|
+ map7.put("FBaseUnitId",fBaseUnitIdFNumber);
|
|
|
+
|
|
|
+ //库存单位
|
|
|
+ HashMap<String, String> kudw = new HashMap<>();
|
|
|
+ fBaseUnitIdFNumber.put("FNumber",FUnitIDFNumber);
|
|
|
+ map7.put("FStockUnitId",kudw);
|
|
|
+
|
|
|
+ if(isDOrQ.equals("全量推送")){
|
|
|
+ //序列号单据体---循环
|
|
|
+ ProductionCardFlow productionCardFlow=new ProductionCardFlow();
|
|
|
+ productionCardFlow.setDemandDocumentNumber(planTaskDetails1.getDemandDocument());//流转卡序列号
|
|
|
+ List<ProductionCardFlow> productionCardFlows = productionCardFlowMapper.selectProductionCardFlowList(productionCardFlow);
|
|
|
+ map7.put("FSNQty",productionCardFlows.size()); //序列号数量
|
|
|
+ map7.put("FMustQty",productionCardFlows.size()); //应收实收
|
|
|
+ map7.put("FRealQty",productionCardFlows.size()); //实收
|
|
|
+
|
|
|
+ map7.put("FBaseMustQty",productionCardFlows.size()); //基本单位实收数量
|
|
|
+ map7.put("FBaseRealQty",productionCardFlows.size()); //基本单位库存实收数量
|
|
|
+ List<Map> list1=new ArrayList<>();
|
|
|
+ String FSerialSubEntityJson = objectMapper.writeValueAsString( map7.get("FSerialSubEntity"));
|
|
|
+ List<Map> fSerialSubEntitylist = objectMapper.readValue(FSerialSubEntityJson, List.class);
|
|
|
+ productionCardFlows.forEach(item->{
|
|
|
+ try {
|
|
|
+ // 将 fSerialSubEntitylist.get(0) 转换为 JSON 字符串,再反序列化为新的 Map
|
|
|
+ String map2Json = objectMapper.writeValueAsString(fSerialSubEntitylist.get(0));
|
|
|
+ Map<String, Object> map2two = objectMapper.readValue(map2Json, Map.class);
|
|
|
+
|
|
|
+ // 修改 map2 中的 FSerialNo
|
|
|
+ map2two.put("FSerialNo", item.getSerialNumber());
|
|
|
+
|
|
|
+ // 处理 FSerialId
|
|
|
+ Map<String, String> fSerialIdMap = null;
|
|
|
+ if (map2two.get("FSerialId") != null) {
|
|
|
+ String fSerialIdJson = objectMapper.writeValueAsString(map2two.get("FSerialId"));
|
|
|
+ fSerialIdMap = objectMapper.readValue(fSerialIdJson, Map.class);
|
|
|
+ } else {
|
|
|
+ fSerialIdMap = new HashMap<>();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 修改 FSerialId 中的 FNUMBER
|
|
|
+ fSerialIdMap.put("FNumber", item.getSerialNumber());
|
|
|
+ map2two.put("FSerialId", fSerialIdMap);
|
|
|
+
|
|
|
+ // 将修改后的 map2 添加到 list1
|
|
|
+ list1.add(map2two);
|
|
|
+ } catch (JsonProcessingException e) {
|
|
|
+ System.out.println(e);
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }else if(isDOrQ.equals("单量推送")) {
|
|
|
+ //序列号单据体---循环
|
|
|
+ ProductionCardFlow productionCardFlow=new ProductionCardFlow();
|
|
|
+ productionCardFlow.setSerialNumber(ringScanInformation.getNativeNumbering());//流转卡序列号
|
|
|
+ List<ProductionCardFlow> productionCardFlows = productionCardFlowMapper.selectProductionCardFlowList(productionCardFlow);
|
|
|
+ map7.put("FSNQty","1"); //序列号数量
|
|
|
+ map7.put("FMustQty","1"); //应收实收
|
|
|
+ map7.put("FRealQty","1"); //实收
|
|
|
+
|
|
|
+ map7.put("FBaseMustQty","1"); //基本单位实收数量
|
|
|
+ map7.put("FBaseRealQty","1"); //基本单位库存实收数量
|
|
|
+ List<Map> list1=new ArrayList<>();
|
|
|
+ String FSerialSubEntityJson = objectMapper.writeValueAsString( map7.get("FSerialSubEntity"));
|
|
|
+ List<Map> fSerialSubEntitylist = objectMapper.readValue(FSerialSubEntityJson, List.class);
|
|
|
+ productionCardFlows.forEach(item->{
|
|
|
+ try {
|
|
|
+ // 将 fSerialSubEntitylist.get(0) 转换为 JSON 字符串,再反序列化为新的 Map
|
|
|
+ String map2Json = objectMapper.writeValueAsString(fSerialSubEntitylist.get(0));
|
|
|
+ Map<String, Object> map2two = objectMapper.readValue(map2Json, Map.class);
|
|
|
+
|
|
|
+ // 修改 map2 中的 FSerialNo
|
|
|
+ map2two.put("FSerialNo", item.getSerialNumber());
|
|
|
+
|
|
|
+ // 处理 FSerialId
|
|
|
+ Map<String, String> fSerialIdMap = null;
|
|
|
+ if (map2two.get("FSerialId") != null) {
|
|
|
+ String fSerialIdJson = objectMapper.writeValueAsString(map2two.get("FSerialId"));
|
|
|
+ fSerialIdMap = objectMapper.readValue(fSerialIdJson, Map.class);
|
|
|
+ } else {
|
|
|
+ fSerialIdMap = new HashMap<>();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 修改 FSerialId 中的 FNUMBER
|
|
|
+ fSerialIdMap.put("FNumber", item.getSerialNumber());
|
|
|
+ map2two.put("FSerialId", fSerialIdMap);
|
|
|
+
|
|
|
+ // 将修改后的 map2 添加到 list1
|
|
|
+ list1.add(map2two);
|
|
|
+ } catch (JsonProcessingException e) {
|
|
|
+ System.out.println(e);
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ map7.put("FSerialSubEntity",list1);
|
|
|
+ System.out.println("入库单量推送流转卡逻辑");
|
|
|
+ }
|
|
|
+ List<Map> fEntityLinkList=new ArrayList<>();
|
|
|
+ String FenJson="{\n" +
|
|
|
+ "\"FEntity_Link_FRuleId\": \"PRD_MO2INSTOCK\",\n" +
|
|
|
+ "\"FEntity_Link_FSTableName\": \"T_PRD_MORPTENTRY\",\n" +
|
|
|
+ "\"FEntity_Link_FSBillId\": \"168691\",\n" +
|
|
|
+ "\"FEntity_Link_FSId\": \"168691\"\n" +
|
|
|
+ "}";
|
|
|
+ Map<String,String> map8 = JSONObject.parseObject(FenJson, Map.class);
|
|
|
+ map8.put("FEntity_Link_FSBillId",fid);
|
|
|
+ map8.put("FEntity_Link_FSId",FEntityFEntryId);
|
|
|
+ fEntityLinkList.add(map8);
|
|
|
+ map7.put("FEntity_Link",fEntityLinkList);
|
|
|
+ List<LinkedHashMap> map7List = new ArrayList<>();
|
|
|
+ map7List.add(map7);
|
|
|
+ map6.put("FEntity",map7List);
|
|
|
+
|
|
|
+ jsonData2.put("Model",map6);
|
|
|
+
|
|
|
+ String rkdcrateJosn = api.save("PRD_INSTOCK",JSONObject.toJSONString(jsonData2));
|
|
|
+ Map<String, String> stringStringMap1 = documentExecutionJudgment(objectMapper, rkdcrateJosn, "生成入库单创建", "入库单创建失败");
|
|
|
+ if(stringStringMap1.get("msg").equals("入库单创建失败")){
|
|
|
+ return stringStringMap1;
|
|
|
+ }
|
|
|
+ //解析入库单创建结果
|
|
|
+ Map rkdCrateJsonResultString = objectMapper.readValue(rkdcrateJosn, Map.class);
|
|
|
+ String rkdCrateResultJson = objectMapper.writeValueAsString(rkdCrateJsonResultString.get("Result"));
|
|
|
+ Map<String,String> rkdResultMap= objectMapper.readValue(rkdCrateResultJson, Map.class);
|
|
|
+ String rkdNumber = rkdResultMap.get("Number");//编号
|
|
|
+
|
|
|
+ //提交
|
|
|
+ String rkdtj="{\n" +
|
|
|
+ " \"Numbers\": [],\n" +
|
|
|
+ " \"Ids\": \"\",\n" +
|
|
|
+ " \"SelectedPostId\": 0,\n" +
|
|
|
+ " \"NetworkCtrl\": \"\",\n" +
|
|
|
+ " \"IgnoreInterationFlag\": \"\"\n" +
|
|
|
+ "}";
|
|
|
+ Map<String, Object> jsonData3 = objectMapper.readValue(rkdtj, Map.class);
|
|
|
+ List<String> list5 =new ArrayList<>();
|
|
|
+ list5.add(rkdNumber);
|
|
|
+ jsonData3.put("Numbers",list5);
|
|
|
+ String tkdtjR = api.submit("PRD_INSTOCK",JSONObject.toJSONString(jsonData3));
|
|
|
+ Map<String, String> stringStringMap2 = documentExecutionJudgment(objectMapper, tkdtjR, "入库单提交成功", "入库单提交失败");
|
|
|
+ if(stringStringMap2.get("msg").equals("入库单提交失败")){
|
|
|
+ return stringStringMap2;
|
|
|
+ }
|
|
|
+
|
|
|
+ //审核
|
|
|
+ String rkdsh="{\n" +
|
|
|
+ " \"Numbers\": [],\n" +
|
|
|
+ " \"Ids\": \"\",\n" +
|
|
|
+ " \"InterationFlags\": \"\",\n" +
|
|
|
+ " \"NetworkCtrl\": \"\",\n" +
|
|
|
+ " \"IsVerifyProcInst\": \"\",\n" +
|
|
|
+ " \"IgnoreInterationFlag\": \"\",\n" +
|
|
|
+ " \"UseBatControlTimes\": \"false\"\n" +
|
|
|
+ "}";
|
|
|
+ Map<String, Object> jsonData4 = objectMapper.readValue(rkdsh, Map.class);
|
|
|
+ jsonData4.put("Number",list5);
|
|
|
+
|
|
|
+ String rkdshR = api.audit("PRD_INSTOCK",JSONObject.toJSONString(jsonData3));
|
|
|
+ Map<String, String> stringStringMap = documentExecutionJudgment(objectMapper, rkdshR, "入库单审核成功", "入库单审核失败");
|
|
|
+ if(stringStringMap.get("msg").equals("入库单审核失败")){
|
|
|
+ return stringStringMap;
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.out.println(e);
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ Map<String,String> abc=new HashMap<>();
|
|
|
+ abc.put("msg", "入库单创建失败");
|
|
|
+ abc.put("error","入库单创建失败");
|
|
|
+ return abc;
|
|
|
+ }
|
|
|
+ Map<String,String> abc=new HashMap<>();
|
|
|
+ abc.put("msg","入库成功");
|
|
|
+ return abc;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * erp创建单据是否成功
|
|
|
+ * @param objectMapper
|
|
|
+ * @param resultJson
|
|
|
+ * @param
|
|
|
+ * @param msg2
|
|
|
+ * @return
|
|
|
+ * @throws JsonProcessingException
|
|
|
+ */
|
|
|
+ private Map<String,String> documentExecutionJudgment(ObjectMapper objectMapper, String resultJson,String msg1,String msg2) throws JsonProcessingException {
|
|
|
+ Map s2Map = objectMapper.readValue(resultJson, Map.class);
|
|
|
+ String result = objectMapper.writeValueAsString(s2Map.get("Result"));
|
|
|
+ System.out.println(result+"执行结果");
|
|
|
+ Map<String,Object> s2MapResultJsonMap= objectMapper.readValue(result, Map.class);
|
|
|
+ //判断是否成功
|
|
|
+ String responseStatus3 = objectMapper.writeValueAsString(s2MapResultJsonMap.get("ResponseStatus"));
|
|
|
+ Map map11 = objectMapper.readValue(responseStatus3, Map.class);
|
|
|
+ String isSuccess3 = map11.get("IsSuccess").toString();
|
|
|
+ String isSuccess4= map11.get("Errors").toString();
|
|
|
+ if(isSuccess3.equals("true")){
|
|
|
+ HashMap hashMap=new HashMap();
|
|
|
+ hashMap.put("msg",msg1);
|
|
|
+ return hashMap;
|
|
|
+ }else {
|
|
|
+ System.out.println(isSuccess4);
|
|
|
+ HashMap hashMap=new HashMap();
|
|
|
+ hashMap.put("msg",msg2);
|
|
|
+ hashMap.put("error",isSuccess4);
|
|
|
+ return hashMap;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private String documentExecutionJudgment1(ObjectMapper objectMapper, String resultJson,String msg1,String msg2) throws JsonProcessingException {
|
|
|
+ Map s2Map = objectMapper.readValue(resultJson, Map.class);
|
|
|
+ String result = objectMapper.writeValueAsString(s2Map.get("Result"));
|
|
|
+ System.out.println(result+"执行结果");
|
|
|
+ Map<String,Object> s2MapResultJsonMap= objectMapper.readValue(result, Map.class);
|
|
|
+ //判断是否成功
|
|
|
+ String responseStatus3 = objectMapper.writeValueAsString(s2MapResultJsonMap.get("ResponseStatus"));
|
|
|
+ Map map11 = objectMapper.readValue(responseStatus3, Map.class);
|
|
|
+ String isSuccess3 = map11.get("IsSuccess").toString();
|
|
|
+ String isSuccess4= map11.get("Errors").toString();
|
|
|
+ if(isSuccess3.equals("true")){
|
|
|
+// HashMap hashMap=new HashMap();
|
|
|
+// hashMap.put("msg",);
|
|
|
+ return msg1;
|
|
|
+ }else {
|
|
|
+ System.out.println(isSuccess4);
|
|
|
+// HashMap hashMap=new HashMap();
|
|
|
+// hashMap.put("msg",msg1);
|
|
|
+// hashMap.put("error",isSuccess4);
|
|
|
+ return msg2;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 没有调用ERP入库单之前的入库逻辑
|
|
|
+ * @param productionOrderNumber
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String generateWarehouseWarrant2(String productionOrderNumber){
|
|
|
+ RingScanInformationFirst newRingScanInformationFirst = new RingScanInformationFirst();
|
|
|
+ newRingScanInformationFirst.setProductionOrderNumber(productionOrderNumber);;
|
|
|
+ List<RingScanInformationFirst> ringScanInformationFirsts1 = ringScanInformationFirstMapper.selectRingScanInformationFirstList(newRingScanInformationFirst);
|
|
|
+ if (ringScanInformationFirsts1.size()>0){
|
|
|
+ RingScanInformationFirst ringScanInformationFirst = ringScanInformationFirsts1.get(0);
|
|
|
+ String packingOrInspection = ringScanInformationFirst.getPackingOrInspection();
|
|
|
+ if(packingOrInspection.equals("1")){
|
|
|
+ //看包装跟当前生产订单总数量是否相等
|
|
|
+ if(ringScanInformationFirst.getPackingQuantity().equals(ringScanInformationFirst.getProductionOrderTotalQuantity())){
|
|
|
+ //生成入库单
|
|
|
+ System.out.println("包装生成入库单-入成品仓库");
|
|
|
+ //入库这个生产订单下的所有产品信息
|
|
|
+
|
|
|
+ //改当前生产订单的状态
|
|
|
+ PlanTaskDetails planTaskDetails=new PlanTaskDetails();
|
|
|
+ planTaskDetails.setDemandDocument(productionOrderNumber);
|
|
|
+ planTaskDetails.setStatus("2");//生产完成
|
|
|
+ int i = planTaskDetailsMapper.updatePlanTaskDetailsByDemandDocument(planTaskDetails);
|
|
|
+ }
|
|
|
+ }else if(packingOrInspection.equals("2")){
|
|
|
+ //看包装跟当前生产订单总数量是否相等
|
|
|
+ if(ringScanInformationFirst.getInspectionQuantity().equals(ringScanInformationFirst.getProductionOrderTotalQuantity())){
|
|
|
+ //生成入库单
|
|
|
+ System.out.println("包装生成入库单--入利庫");
|
|
|
+ //入库这个生产订单下的所有产品信息
|
|
|
+ PlanTaskDetails planTaskDetails=new PlanTaskDetails();
|
|
|
+ planTaskDetails.setDemandDocument(productionOrderNumber);
|
|
|
+ planTaskDetails.setStatus("2");//生产完成
|
|
|
+ int i = planTaskDetailsMapper.updatePlanTaskDetailsByDemandDocument(planTaskDetails);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return "数量够了入库";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 蓝牙扫描枪扫描(作废)
|
|
|
+ * @param stationProductScanningRingVo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public String bluetoothScannerGun(StationProductScanningRingVo stationProductScanningRingVo) {
|
|
|
+ String contentInformation = stationProductScanningRingVo.getContentInformation();
|
|
|
+ if(contentInformation.contains("addRing")){//添加二维扫描枪
|
|
|
+ //编号拆分 蓝牙名-mac地址
|
|
|
+ String[] split = stationProductScanningRingVo.getDeviceNumber().split("-");
|
|
|
+ //位置1是蓝牙名称-位置二实mac地址
|
|
|
+ String split1=split[0];
|
|
|
+ //位置2是mac地址
|
|
|
+ String split2=split[1];
|
|
|
+ RingTerminal ringTerminal=new RingTerminal();
|
|
|
+ ringTerminal.setBluetoothName(split1);
|
|
|
+ ringTerminal.setHandheldTerminalNumber(split2);
|
|
|
+ int i = ringTerminalMapper.updateRingTerminalByBluetoothName(ringTerminal);
|
|
|
+ if(i>0){
|
|
|
+ System.out.println("扫描枪添加成功");
|
|
|
+ }
|
|
|
+ }else if(contentInformation.contains("scan@")){//扫描的是员工码
|
|
|
+ //更改当前人员的扫码信息
|
|
|
+ String replace = contentInformation.replace("scan@", "");
|
|
|
+ String[] personeList = replace.split("#");
|
|
|
+ //把当前设备给切换到这个人身上
|
|
|
+ //先找到当前设备在那个人身上
|
|
|
+ //更改当前工位码的设备信息
|
|
|
+ StationInformation stationInformation = new StationInformation();
|
|
|
+ String[] split1 = stationProductScanningRingVo.getDeviceNumber().split("-");
|
|
|
+ stationInformation.setDeviceNumber(split1[1]);//设备编号
|
|
|
+ stationInformation.setBluetoothName(split1[0]);//蓝牙名称
|
|
|
+ List<StationInformation> stationInformations = stationInformationMapper.selectStationInformationListByDEviceNumber(stationInformation);
|
|
|
+ if (stationInformations.size()>0){
|
|
|
+ //重置以前的绑定(手持机在哪我就把那变成空)
|
|
|
+ stationInformationMapper.updateStationInformationDeviceNameAndBluetoothName(stationInformation);
|
|
|
+ }
|
|
|
+ stationInformation.setPersonnelId(personeList[0]);//员工id
|
|
|
+ stationInformation.setPersonnelName(personeList[1]);//员工姓名
|
|
|
+ int i = stationInformationMapper.updateStationInformationByUseIdAndUserName(stationInformation);
|
|
|
+ if(i>0){
|
|
|
+ System.out.println("扫枪绑定信息切换成功");
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+
|
|
|
+
|
|
|
+ String scanningTime = stationProductScanningRingVo.getScanningTime();
|
|
|
+ String[] split = stationProductScanningRingVo.getDeviceNumber().split("-");
|
|
|
+ //1、判断扫的是不是厂内流转卡
|
|
|
+ /*boolean fjqyD = stationProductScanningRingVo.getContentInformation().contains("D");
|
|
|
+ boolean fjqyZ = stationProductScanningRingVo.getContentInformation().contains("Z");
|
|
|
+ if(!fjqyD||!fjqyZ){return "请扫描相关二维码";}*/
|
|
|
+
|
|
|
+ //2、扫描间距判断
|
|
|
+ /* RingScanInformation ringScanInformationQuery=new RingScanInformation();
|
|
|
+ ringScanInformationQuery.setDeviceNumber(split[1]);//设备Mac地址
|
|
|
+ RingScanInformation ringScanInformations = ringScanInformationMapper.selectRingScanInformationListDateTimeMax(ringScanInformationQuery);
|
|
|
+ if(ringScanInformations!=null){
|
|
|
+ //拿到上次扫描的时间
|
|
|
+ LocalDateTime scanningTime1 = ringScanInformations.getScanningTime();
|
|
|
+ //拿到当前系统时间
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+ //计算两次时间的时间差
|
|
|
+ Duration duration = Duration.between(scanningTime1, now);
|
|
|
+ boolean isTwoMinutesPassed = duration.toMinutes() < 1;
|
|
|
+ //判断两次时间是否大于
|
|
|
+ if (isTwoMinutesPassed) {
|
|
|
+ return "同一设备,两分钟之内不能重复扫描";
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+
|
|
|
+ //3、扫描录入数据
|
|
|
+ RingScanInformation ringScanInformation=new RingScanInformation();
|
|
|
+ ringScanInformation.setContentInformation(contentInformation);
|
|
|
+ LocalDateTime localDateTime = DateUtils.toLocalDateTime(scanningTime, "yyyy-MM-dd HH:mm:ss");
|
|
|
+ ringScanInformation.setScanningTime(localDateTime);
|
|
|
+ ringScanInformation.setDeviceName(split[0]);//蓝牙名称
|
|
|
+ ringScanInformation.setDeviceNumber(split[1]);//mac地址
|
|
|
+ //4、查询当前机器绑定的工位信息和人信息
|
|
|
+ StationInformation terminalInformation=new StationInformation();
|
|
|
+ terminalInformation.setBluetoothName(split[0]); //蓝牙名称
|
|
|
+ terminalInformation.setDeviceNumber(split[1]);//mac地址
|
|
|
+ List<StationInformation> stationInformations = stationInformationMapper.selectStationInformationListByDEviceNumber(terminalInformation);
|
|
|
+ if(stationInformations.size()>0){
|
|
|
+ ringScanInformation.setPersonnelName(stationInformations.get(0).getPersonnelName());
|
|
|
+ ringScanInformation.setProcess(stationInformations.get(0).getProcessId());
|
|
|
+ ringScanInformation.setProcessName(stationInformations.get(0).getProcessName());
|
|
|
+ ringScanInformation.setStationId(stationInformations.get(0).getId().toString()); //工位名称
|
|
|
+ ringScanInformation.setStationName(stationInformations.get(0).getStationName());//工位名称
|
|
|
+ }
|
|
|
+ String nativeNumber="";
|
|
|
+ if(contentInformation.contains("Z")){
|
|
|
+ nativeNumber = contentInformation.replace("Z", "");
|
|
|
+ }
|
|
|
+ if(contentInformation.contains("D")){
|
|
|
+ nativeNumber=contentInformation.replace("D","");
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotNull(nativeNumber)&&nativeNumber!=""){
|
|
|
+ //取值真实的扫描内容
|
|
|
+ ringScanInformation.setNativeNumbering(nativeNumber);
|
|
|
+ }else {
|
|
|
+ //扫描内容
|
|
|
+ ringScanInformation.setNativeNumbering(contentInformation);
|
|
|
+ }
|
|
|
+ //根据扫描内容拿到生产订单号和订单号
|
|
|
+ String queryStringOrderNumberAndProductionOrderNumber="{\n" +
|
|
|
+ " \"FormId\": \"PRD_MO\",\n" +
|
|
|
+ " \"FieldKeys\": \"FSaleOrderNo,FBillNo\",\n" +
|
|
|
+ " \"FilterString\": [{\"Left\":\"\",\"FieldName\":\"FSerialNo\",\"Compare\":\"17\",\"Value\":\""+ringScanInformation.getNativeNumbering()+"\",\"Right\":\"\",\"Logic\":0}],\n" +
|
|
|
+ " \"OrderString\": \"\",\n" +
|
|
|
+ " \"TopRowCount\": 0,\n" +
|
|
|
+ " \"StartRow\": 0,\n" +
|
|
|
+ " \"Limit\": 2000,\n" +
|
|
|
+ " \"SubSystemId\": \"\"\n" +
|
|
|
+ "}";
|
|
|
+ Map<String, Object> map = JSON.parseObject(queryStringOrderNumberAndProductionOrderNumber, Map.class);
|
|
|
+ K3CloudApi api = new K3CloudApi();
|
|
|
+ String resultJson = null;
|
|
|
+ try {
|
|
|
+ resultJson = api.billQuery(JSON.toJSONString(map));
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.out.println(e);
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ //判断内不为空
|
|
|
+ if(resultJson!=""&resultJson!="[]"){
|
|
|
+ List<JdProductionOrder> jdProductionOrders = JSON.parseArray(resultJson, JdProductionOrder.class);
|
|
|
+ if(jdProductionOrders.size()>0){
|
|
|
+ //需求单据号
|
|
|
+ ringScanInformation.setOrderNumber(jdProductionOrders.get(0).getDemandDocument());
|
|
|
+ //生产订单号
|
|
|
+ ringScanInformation.setProductionOrderNumber(jdProductionOrders.get(0).getDocumentNumber());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotNull(ringScanInformation.getOrderNumber())){
|
|
|
+ //--记录第一扫描(将来第一扫描的单据记录)
|
|
|
+ RingScanInformationFirst ringScanInformationFirst=new RingScanInformationFirst();
|
|
|
+ ringScanInformationFirst.setOrderNumber(ringScanInformation.getOrderNumber());
|
|
|
+ List<RingScanInformationFirst> ringScanInformationFirsts = ringScanInformationFirstMapper.selectRingScanInformationFirstList(ringScanInformationFirst);
|
|
|
+ //订单扫描记录
|
|
|
+ if(ringScanInformationFirsts.size()<=0){
|
|
|
+ ringScanInformationFirst.setProductionOrderNumber(ringScanInformation.getProductionOrderNumber());
|
|
|
+ ringScanInformationFirst.setStatus("1");
|
|
|
+ ringScanInformationFirst.setStartTime(LocalDateTime.now());//开始时间
|
|
|
+ //查询这个订单的总数量是多少
|
|
|
+ String sa="{\n" +
|
|
|
+ " \"FormId\": \"SAL_SaleOrder\",\n" +
|
|
|
+ " \"FieldKeys\": \"FBillNo,FQty\",\n" +
|
|
|
+ " \"FilterString\": [{\"Left\":\"\",\"FieldName\":\"FBillNo\",\"Compare\":\"17\",\"Value\":\""+ringScanInformation.getOrderNumber()+"\",\"Right\":\"\",\"Logic\":0}],\n" +
|
|
|
+ " \"OrderString\": \"\",\n" +
|
|
|
+ " \"TopRowCount\": 0,\n" +
|
|
|
+ " \"StartRow\": 0,\n" +
|
|
|
+ " \"Limit\": 2000,\n" +
|
|
|
+ " \"SubSystemId\": \"\"\n" +
|
|
|
+ "}";
|
|
|
+ Map<String, Object> mapTotal = JSON.parseObject(sa, Map.class);
|
|
|
+ String resultJsonTotal = null;
|
|
|
+ try {
|
|
|
+ resultJsonTotal = api.billQuery(JSON.toJSONString(mapTotal));
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.out.println(e);
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ List<Map> mapListTotal = JSON.parseArray(resultJsonTotal, Map.class);
|
|
|
+ if(mapListTotal.size()<=0){
|
|
|
+ return "扫码失败订单已关闭";
|
|
|
+ }
|
|
|
+ Double totalAmount = mapListTotal.stream()
|
|
|
+ .filter(map1 -> map1.containsKey("FQty")) // 确保 map 中包含 "amount" 字段
|
|
|
+ .mapToDouble(map1 -> ((Number) map1.get("FQty")).doubleValue()) // 将 "amount" 字段转换为 double
|
|
|
+ .sum(); // 求和
|
|
|
+
|
|
|
+ ringScanInformationFirst.setTotalQuantity(String.valueOf(totalAmount.intValue()));
|
|
|
+ //第一次扫码记录订单扫描记录信息
|
|
|
+ int i = ringScanInformationFirstMapper.insertRingScanInformationFirst(ringScanInformationFirst);
|
|
|
+ }
|
|
|
+ //先查生产订单日志表没有在新增
|
|
|
+ RingScanInformationProdOrderScanning prodOrderScanning=new RingScanInformationProdOrderScanning();
|
|
|
+ prodOrderScanning.setOrderNumber(ringScanInformation.getOrderNumber());
|
|
|
+ prodOrderScanning.setProductionOrderNumber(ringScanInformation.getProductionOrderNumber());
|
|
|
+ List<RingScanInformationProdOrderScanning> ringScanInformationProdOrderScannings =
|
|
|
+ prodOrderScanningMapper.selectRingScanInformationProdOrderScanningList(prodOrderScanning);
|
|
|
+ if(ringScanInformationProdOrderScannings.size()<0){
|
|
|
+ //看看这个生产订单包装节点Or检验
|
|
|
+ String query="{\n" +
|
|
|
+ " \"FormId\": \"PRD_MO\",\n" +
|
|
|
+ " \"FieldKeys\": \"FMaterialId.FNumber\",\n" +
|
|
|
+ " \"FilterString\": [{\"Left\":\"\",\"FieldName\":\"FBillNo\",\"Compare\":\"67\",\"Value\":\""+ringScanInformation.getProductionOrderNumber()+"\",\"Right\":\"\",\"Logic\":0}],\n" +
|
|
|
+ " \"OrderString\": \"\",\n" +
|
|
|
+ " \"TopRowCount\": 0,\n" +
|
|
|
+ " \"StartRow\": 0,\n" +
|
|
|
+ " \"Limit\": 2000,\n" +
|
|
|
+ " \"SubSystemId\": \"\"\n" +
|
|
|
+ "}";
|
|
|
+ Map<String, Object> prodListQuery = JSON.parseObject(query, Map.class);
|
|
|
+ String prodListQueryJson = null;
|
|
|
+ try {
|
|
|
+ prodListQueryJson = api.billQuery(JSON.toJSONString(prodListQuery));
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.out.println(e);
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ List<Map> prodListQueryJsonList = JSON.parseArray(prodListQueryJson, Map.class);
|
|
|
+ //如果ERP存在这个生产订单
|
|
|
+ if(prodListQueryJsonList.size()>0){
|
|
|
+ //[{"FMaterialId.FNumber":"1010040050034","FQty":2.0000000000}]
|
|
|
+ //生产订单日志记录
|
|
|
+ prodOrderScanning.setTotalQuantity(prodListQueryJsonList.get(0).get("FQty").toString());//数量
|
|
|
+ if(prodListQueryJsonList.get(0).get("FMaterialId.FNumber").toString().startsWith("1")){
|
|
|
+ prodOrderScanning.setToPackagingorinspection("1");//到包装
|
|
|
+ }else if(prodListQueryJsonList.get(0).get("FMaterialId.FNumber").toString().startsWith("2")){
|
|
|
+ prodOrderScanning.setToPackagingorinspection("2");//到检验
|
|
|
+ }else {
|
|
|
+ prodOrderScanning.setToPackagingorinspection("0");//其他
|
|
|
+ }
|
|
|
+ int i = prodOrderScanningMapper.insertRingScanInformationProdOrderScanning(prodOrderScanning);
|
|
|
+ if(i>0){
|
|
|
+ System.out.println("新增生产订单日志信息成功");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //插入扫描日志信息
|
|
|
+ int i2 = ringScanInformationMapper.insertRingScanInformation(ringScanInformation);
|
|
|
+
|
|
|
+ if(i2>0){
|
|
|
+ //最后一个节点判定逻辑
|
|
|
+ RingScanInformationProdOrderScanning prodOrderScanning=new RingScanInformationProdOrderScanning();
|
|
|
+ prodOrderScanning.setOrderNumber(ringScanInformation.getOrderNumber());
|
|
|
+ prodOrderScanning.setProductionOrderNumber(ringScanInformation.getProductionOrderNumber());
|
|
|
+ List<RingScanInformationProdOrderScanning> ringScanInformationProdOrderScannings =
|
|
|
+ prodOrderScanningMapper.selectRingScanInformationProdOrderScanningList(prodOrderScanning);
|
|
|
+ if(ringScanInformationProdOrderScannings.size()>0){
|
|
|
+ String toPackagingorinspection = ringScanInformationProdOrderScannings.get(0).getToPackagingorinspection();
|
|
|
+ if(toPackagingorinspection.equals("1")){//更新包装数量
|
|
|
+ String toPackagingorinspection1 = ringScanInformationProdOrderScannings.get(0).getPackingQuantity();
|
|
|
+ Double d=Double.valueOf(toPackagingorinspection1)+1;
|
|
|
+ ringScanInformationProdOrderScannings.get(0).setPackingQuantity(d.toString());
|
|
|
+ int i = prodOrderScanningMapper.updateRingScanInformationProdOrderScanning(ringScanInformationProdOrderScannings.get(0));
|
|
|
+ System.out.println("包装节点更新成功");
|
|
|
+ String rk = this.rk(prodOrderScanning);
|
|
|
+ System.out.println(rk);
|
|
|
+ }else {//更新检验数量
|
|
|
+ String toPackagingorinspection1 = ringScanInformationProdOrderScannings.get(0).getInspectionQuantity();
|
|
|
+ Double d=Double.valueOf(toPackagingorinspection1)+1;
|
|
|
+ ringScanInformationProdOrderScannings.get(0).setInspectionQuantity(d.toString());
|
|
|
+ int i = prodOrderScanningMapper.updateRingScanInformationProdOrderScanning(ringScanInformationProdOrderScannings.get(0));
|
|
|
+ System.out.println("检验节点更新成功");
|
|
|
+ String rk = this.rk(prodOrderScanning);
|
|
|
+ System.out.println(rk);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return "扫描成功";
|
|
|
+ }else {
|
|
|
+ return "扫描失败";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return "扫描成功";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 产品扫描
|
|
|
+ * @param contentString
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public String stationProductScanning(String contentString) {
|
|
|
+ try {
|
|
|
+ if (contentString.contains("scan@")) {//这个是工位码扫描逻辑
|
|
|
+ String[] content = contentString.split("&");
|
|
|
+ //更改当前工位码的设备信息
|
|
|
+ StationInformation stationInformation = new StationInformation();
|
|
|
+ stationInformation.setDeviceName(content[2]);//设备信息
|
|
|
+ //查询当前设备是否已经绑定了工位信息
|
|
|
+ List<StationInformation> stationInformations = stationInformationMapper.selectStationInformationList(stationInformation);
|
|
|
+ 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 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();
|
|
|
+ reportInformationSheet.setCurrentStationStationPeople(stationInformation1.getPersonnelName());//工位人员姓名
|
|
|
+ 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){
|
|
|
+ //插入异常报工信息
|
|
|
+ extracted(reportInformationSheet,"未找到当前产品计划报工失败--信息不匹配");
|
|
|
+ return "未找到当前产品计划报工失败--信息不匹配";
|
|
|
+ }else {
|
|
|
+ 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 "扫码报工失败";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ return "当前设备未绑定工位信息";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.out.println(
|
|
|
+ e.getMessage()
|
|
|
+ );
|
|
|
+ return "扫描失败";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 有其他方法调用这个这个基础逻辑
|
|
|
+ * @param contentString
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String rk(RingScanInformationProdOrderScanning contentString){
|
|
|
+ return "rk";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 手持扫描实现(作废)
|
|
|
+ * @param contentString
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public String stationProductScanningTwo(String contentString) {
|
|
|
+ //扫描人员码信息
|
|
|
+ if(contentString.contains("scan@")){
|
|
|
+ //扫描标记替换为空
|
|
|
+ String replace = contentString.replace("scan@", "");
|
|
|
+ //首先把内容拆分下
|
|
|
+ String[] content = replace.split("&");
|
|
|
+ //人员信息
|
|
|
+ String personneString = content[0];
|
|
|
+ //更改当前人员的扫码信息
|
|
|
+ String[] personneList = personneString.split("#");
|
|
|
+ //设备编码信息
|
|
|
+ String sbMacAddress= content[1];
|
|
|
+ //更改当前工位码的设备信息
|
|
|
+ StationInformation stationInformation = new StationInformation();
|
|
|
+ stationInformation.setDeviceNumber(sbMacAddress);//设备编号
|
|
|
+ List<StationInformation> stationInformations = stationInformationMapper.selectStationInformationListByDEviceNumber(stationInformation);
|
|
|
+ if (stationInformations.size()>0){
|
|
|
+ //重置以前的绑定(手持机在哪我就把那变成空)
|
|
|
+ stationInformationMapper.updateStationInformationDeviceNameAndBluetoothName(stationInformation);
|
|
|
+ }
|
|
|
+ stationInformation.setPersonnelId(personneList[0]);//员工id
|
|
|
+ stationInformation.setPersonnelName(personneList[1]);//员工姓名
|
|
|
+ int i = stationInformationMapper.updateStationInformationByUseIdAndUserName(stationInformation);
|
|
|
+ if(i>0){
|
|
|
+ System.out.println("工位:"+stationInformations.get(0).getStationName()+"人员:"+stationInformations.get(0).getPersonnelName());
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ //产品编码&mac地址
|
|
|
+ String[] content = contentString.split("&");
|
|
|
+ //产品编码
|
|
|
+ String s1 = content[0];
|
|
|
+ //mac地址
|
|
|
+ String s2 = content[1];
|
|
|
+
|
|
|
+ //1、判断扫的是不是厂内流转卡
|
|
|
+ /*boolean fjqyD = stationProductScanningRingVo.getContentInformation().contains("D");
|
|
|
+ boolean fjqyZ = stationProductScanningRingVo.getContentInformation().contains("Z");
|
|
|
+ if(!fjqyD||!fjqyZ){return "请扫描相关二维码";}*/
|
|
|
+
|
|
|
+ //2、扫描间距判断
|
|
|
+ /* RingScanInformation ringScanInformationQuery=new RingScanInformation();
|
|
|
+ ringScanInformationQuery.setDeviceNumber(split[1]);//设备Mac地址
|
|
|
+ RingScanInformation ringScanInformations = ringScanInformationMapper.selectRingScanInformationListDateTimeMax(ringScanInformationQuery);
|
|
|
+ if(ringScanInformations!=null){
|
|
|
+ //拿到上次扫描的时间
|
|
|
+ LocalDateTime scanningTime1 = ringScanInformations.getScanningTime();
|
|
|
+ //拿到当前系统时间
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+ //计算两次时间的时间差
|
|
|
+ Duration duration = Duration.between(scanningTime1, now);
|
|
|
+ boolean isTwoMinutesPassed = duration.toMinutes() < 1;
|
|
|
+ //判断两次时间是否大于
|
|
|
+ if (isTwoMinutesPassed) {
|
|
|
+ return "同一设备,两分钟之内不能重复扫描";
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+
|
|
|
+ //扫码内容
|
|
|
+ RingScanInformation ringScanInformation=new RingScanInformation();
|
|
|
+ //扫描内容
|
|
|
+ ringScanInformation.setContentInformation(s1);
|
|
|
+ //当前时间
|
|
|
+ ringScanInformation.setScanningTime(LocalDateTime.now());
|
|
|
+ //mac地址
|
|
|
+ ringScanInformation.setDeviceNumber(s2);//mac地址
|
|
|
+
|
|
|
+ //4、查询当前机器绑定的工位信息和人信息
|
|
|
+ StationInformation terminalInformation=new StationInformation();
|
|
|
+ terminalInformation.setDeviceNumber(s2);//mac地址
|
|
|
+ List<StationInformation> stationInformations =
|
|
|
+ stationInformationMapper.selectStationInformationListByDEviceNumber(terminalInformation);
|
|
|
+ if(stationInformations.size()>0){
|
|
|
+ ringScanInformation.setPersonnelName(stationInformations.get(0).getPersonnelName());
|
|
|
+ ringScanInformation.setProcess(stationInformations.get(0).getProcessId()); //人员id
|
|
|
+ ringScanInformation.setProcessName(stationInformations.get(0).getProcessName()); //人员姓名
|
|
|
+ ringScanInformation.setStationId(stationInformations.get(0).getId().toString()); //工位id
|
|
|
+ ringScanInformation.setStationName(stationInformations.get(0).getStationName());//工位名称
|
|
|
+ }
|
|
|
+ String nativeNumber="";
|
|
|
+ if(s1.contains("Z")){nativeNumber = s1.replace("Z", "");}
|
|
|
+ if(s1.contains("D")){nativeNumber=s1.replace("D","");}
|
|
|
+ if(StringUtils.isNotNull(nativeNumber)&&nativeNumber!=""){
|
|
|
+ //取值真实的扫描内容
|
|
|
+ ringScanInformation.setNativeNumbering(nativeNumber);
|
|
|
+ }else {
|
|
|
+ //扫描内容---直接就是产品码
|
|
|
+ ringScanInformation.setNativeNumbering(s1);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //根据扫描内容拿到生产订单号和订单号
|
|
|
+ String queryStringOrderNumberAndProductionOrderNumber="{\n" +
|
|
|
+ " \"FormId\": \"PRD_MO\",\n" +
|
|
|
+ " \"FieldKeys\": \"FSaleOrderNo,FBillNo\",\n" +
|
|
|
+ " \"FilterString\": [{\"Left\":\"\",\"FieldName\":\"FSerialNo\",\"Compare\":\"17\",\"Value\":\""+ringScanInformation.getNativeNumbering()+"\",\"Right\":\"\",\"Logic\":0}],\n" +
|
|
|
+ " \"OrderString\": \"\",\n" +
|
|
|
+ " \"TopRowCount\": 0,\n" +
|
|
|
+ " \"StartRow\": 0,\n" +
|
|
|
+ " \"Limit\": 2000,\n" +
|
|
|
+ " \"SubSystemId\": \"\"\n" +
|
|
|
+ "}";
|
|
|
+ Map<String, Object> map = JSON.parseObject(queryStringOrderNumberAndProductionOrderNumber, Map.class);
|
|
|
+ K3CloudApi api = new K3CloudApi();
|
|
|
+ String resultJson = null;
|
|
|
+ try {
|
|
|
+ resultJson = api.billQuery(JSON.toJSONString(map));
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+
|
|
|
+ //判断内不为空
|
|
|
+ if(resultJson!=""&resultJson!="[]"){
|
|
|
+ List<JdProductionOrder> jdProductionOrders = JSON.parseArray(resultJson, JdProductionOrder.class);
|
|
|
+ if(jdProductionOrders.size()>0){
|
|
|
+ //需求单据号
|
|
|
+ ringScanInformation.setOrderNumber(jdProductionOrders.get(0).getDemandDocument());
|
|
|
+ //生产订单号
|
|
|
+ ringScanInformation.setProductionOrderNumber(jdProductionOrders.get(0).getDocumentNumber());
|
|
|
+ //唯一标识id
|
|
|
+// ringScanInformation.setId(UUID.randomUUID().toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(StringUtils.isNotNull(ringScanInformation.getOrderNumber())){
|
|
|
+ //--记录第一扫描(将来第一扫描的单据记录)
|
|
|
+ RingScanInformationFirst ringScanInformationFirst=new RingScanInformationFirst();
|
|
|
+ ringScanInformationFirst.setOrderNumber(ringScanInformation.getOrderNumber());
|
|
|
+ List<RingScanInformationFirst> ringScanInformationFirsts = ringScanInformationFirstMapper.selectRingScanInformationFirstList(ringScanInformationFirst);
|
|
|
+ //订单扫描记录
|
|
|
+ if(ringScanInformationFirsts.size()<=0){
|
|
|
+ ringScanInformationFirst.setProductionOrderNumber(ringScanInformation.getProductionOrderNumber());
|
|
|
+ ringScanInformationFirst.setStatus("1");
|
|
|
+ ringScanInformationFirst.setStartTime(LocalDateTime.now());//开始时间
|
|
|
+ //查询这个订单的总数量是多少
|
|
|
+ String sa="{\n" +
|
|
|
+ " \"FormId\": \"SAL_SaleOrder\",\n" +
|
|
|
+ " \"FieldKeys\": \"FBillNo,FQty\",\n" +
|
|
|
+ " \"FilterString\": [{\"Left\":\"\",\"FieldName\":\"FBillNo\",\"Compare\":\"17\",\"Value\":\""+ringScanInformation.getOrderNumber()+"\",\"Right\":\"\",\"Logic\":0}],\n" +
|
|
|
+ " \"OrderString\": \"\",\n" +
|
|
|
+ " \"TopRowCount\": 0,\n" +
|
|
|
+ " \"StartRow\": 0,\n" +
|
|
|
+ " \"Limit\": 2000,\n" +
|
|
|
+ " \"SubSystemId\": \"\"\n" +
|
|
|
+ "}";
|
|
|
+ Map<String, Object> mapTotal = JSON.parseObject(sa, Map.class);
|
|
|
+ String resultJsonTotal = null;
|
|
|
+ try {
|
|
|
+ resultJsonTotal = api.billQuery(JSON.toJSONString(mapTotal));
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.out.println(e);
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ List<Map> mapListTotal = JSON.parseArray(resultJsonTotal, Map.class);
|
|
|
+ if(mapListTotal.size()<=0){
|
|
|
+ ringScanInformation.setExecutionMark("2");//成功
|
|
|
+ ringScanInformation.setExecutionMessage("扫描失败");
|
|
|
+ int i2 = ringScanInformationMapper.insertRingScanInformation(ringScanInformation);
|
|
|
+ return "订单已关闭-扫描失败";
|
|
|
+ }
|
|
|
+ Double totalAmount = mapListTotal.stream()
|
|
|
+ .filter(map1 -> map1.containsKey("FQty")) // 确保 map 中包含 "amount" 字段
|
|
|
+ .mapToDouble(map1 -> ((Number) map1.get("FQty")).doubleValue()) // 将 "amount" 字段转换为 double
|
|
|
+ .sum(); // 求和
|
|
|
+
|
|
|
+ ringScanInformationFirst.setTotalQuantity(String.valueOf(totalAmount.intValue()));
|
|
|
+ //第一次扫码记录订单扫描记录信息
|
|
|
+ int i = ringScanInformationFirstMapper.insertRingScanInformationFirst(ringScanInformationFirst);
|
|
|
+ }
|
|
|
+ //先查生产订单日志表没有在新增
|
|
|
+ RingScanInformationProdOrderScanning prodOrderScanning=new RingScanInformationProdOrderScanning();
|
|
|
+ prodOrderScanning.setOrderNumber(ringScanInformation.getOrderNumber());
|
|
|
+ prodOrderScanning.setProductionOrderNumber(ringScanInformation.getProductionOrderNumber());
|
|
|
+ List<RingScanInformationProdOrderScanning> ringScanInformationProdOrderScannings =
|
|
|
+ prodOrderScanningMapper.selectRingScanInformationProdOrderScanningList(prodOrderScanning);
|
|
|
+ if(ringScanInformationProdOrderScannings.size()<0){
|
|
|
+ //看看这个生产订单包装节点Or检验
|
|
|
+ String query="{\n" +
|
|
|
+ " \"FormId\": \"PRD_MO\",\n" +
|
|
|
+ " \"FieldKeys\": \"FMaterialId.FNumber\",\n" +
|
|
|
+ " \"FilterString\": [{\"Left\":\"\",\"FieldName\":\"FBillNo\",\"Compare\":\"67\",\"Value\":\""+ringScanInformation.getProductionOrderNumber()+"\",\"Right\":\"\",\"Logic\":0}],\n" +
|
|
|
+ " \"OrderString\": \"\",\n" +
|
|
|
+ " \"TopRowCount\": 0,\n" +
|
|
|
+ " \"StartRow\": 0,\n" +
|
|
|
+ " \"Limit\": 2000,\n" +
|
|
|
+ " \"SubSystemId\": \"\"\n" +
|
|
|
+ "}";
|
|
|
+ Map<String, Object> prodListQuery = JSON.parseObject(query, Map.class);
|
|
|
+ String prodListQueryJson = null;
|
|
|
+ try {
|
|
|
+ prodListQueryJson = api.billQuery(JSON.toJSONString(prodListQuery));
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.out.println(e);
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ List<Map> prodListQueryJsonList = JSON.parseArray(prodListQueryJson, Map.class);
|
|
|
+ //如果ERP存在这个生产订单
|
|
|
+ if(prodListQueryJsonList.size()>0){
|
|
|
+ //[{"FMaterialId.FNumber":"1010040050034","FQty":2.0000000000}]
|
|
|
+ //生产订单日志记录
|
|
|
+ prodOrderScanning.setTotalQuantity(prodListQueryJsonList.get(0).get("FQty").toString());//数量
|
|
|
+ if(prodListQueryJsonList.get(0).get("FMaterialId.FNumber").toString().startsWith("1")){
|
|
|
+ prodOrderScanning.setToPackagingorinspection("1");//到包装
|
|
|
+ }else if(prodListQueryJsonList.get(0).get("FMaterialId.FNumber").toString().startsWith("2")){
|
|
|
+ prodOrderScanning.setToPackagingorinspection("2");//到检验
|
|
|
+ }else {
|
|
|
+ prodOrderScanning.setToPackagingorinspection("0");//其他
|
|
|
+ }
|
|
|
+ int i = prodOrderScanningMapper.insertRingScanInformationProdOrderScanning(prodOrderScanning);
|
|
|
+ if(i>0){
|
|
|
+ System.out.println("新增生产订单日志信息成功");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //插入扫描日志信息
|
|
|
+ int i2 = ringScanInformationMapper.insertRingScanInformation(ringScanInformation);
|
|
|
+
|
|
|
+ if(i2>0){
|
|
|
+ //最后一个节点判定逻辑
|
|
|
+ RingScanInformationProdOrderScanning prodOrderScanning=new RingScanInformationProdOrderScanning();
|
|
|
+ prodOrderScanning.setOrderNumber(ringScanInformation.getOrderNumber());
|
|
|
+ prodOrderScanning.setProductionOrderNumber(ringScanInformation.getProductionOrderNumber());
|
|
|
+ List<RingScanInformationProdOrderScanning> ringScanInformationProdOrderScannings =
|
|
|
+ prodOrderScanningMapper.selectRingScanInformationProdOrderScanningList(prodOrderScanning);
|
|
|
+ if(ringScanInformationProdOrderScannings.size()>0){
|
|
|
+ String toPackagingorinspection = ringScanInformationProdOrderScannings.get(0).getToPackagingorinspection();
|
|
|
+ if(toPackagingorinspection.equals("1")){//更新包装数量
|
|
|
+ String toPackagingorinspection1 = ringScanInformationProdOrderScannings.get(0).getPackingQuantity();
|
|
|
+ Double d=Double.valueOf(toPackagingorinspection1)+1;
|
|
|
+ ringScanInformationProdOrderScannings.get(0).setPackingQuantity(d.toString());
|
|
|
+ int i = prodOrderScanningMapper.updateRingScanInformationProdOrderScanning(ringScanInformationProdOrderScannings.get(0));
|
|
|
+ System.out.println("包装节点更新成功");
|
|
|
+ String rk = this.rk(prodOrderScanning);
|
|
|
+ System.out.println(rk);
|
|
|
+ }else {//更新检验数量
|
|
|
+ String toPackagingorinspection1 = ringScanInformationProdOrderScannings.get(0).getInspectionQuantity();
|
|
|
+ Double d=Double.valueOf(toPackagingorinspection1)+1;
|
|
|
+ ringScanInformationProdOrderScannings.get(0).setInspectionQuantity(d.toString());
|
|
|
+ int i = prodOrderScanningMapper.updateRingScanInformationProdOrderScanning(ringScanInformationProdOrderScannings.get(0));
|
|
|
+ System.out.println("检验节点更新成功");
|
|
|
+ String rk = this.rk(prodOrderScanning);
|
|
|
+ System.out.println(rk);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return "扫描成功";
|
|
|
+ }else {
|
|
|
+ return "扫描失败";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return "扫描成功";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 指环王扫描信息hmc
|
|
|
+ * @param stationProductScanningRingVo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public String stationProductScanningRing(StationProductScanningRingVo stationProductScanningRingVo) {
|
|
|
+ //判断扫的是不是厂内流转卡
|
|
|
+// boolean fjqy = stationProductScanningRingVo.getContentInformation().contains("FJQY");
|
|
|
+// if(!fjqy){
|
|
|
+// return "请扫描相关二维码";
|
|
|
+// };
|
|
|
+ try {
|
|
|
+// String string = Base64.getDecoder().decode(stationProductScanningRingVo.getDeviceNumber()).toString();
|
|
|
+ String deviceNumberAndName = stationProductScanningRingVo.getDeviceNumber();//设备号
|
|
|
+ String[] split = deviceNumberAndName.split("-");
|
|
|
+ String deviceNumber=split[0];
|
|
|
+ String deviceName=split[1];
|
|
|
+ String scanningTime = stationProductScanningRingVo.getScanningTime();//扫描时间
|
|
|
+ //先获取到当前设备上次的扫描时间
|
|
|
+// RingScanInformation ringScanInformationQuery=new RingScanInformation();
|
|
|
+// ringScanInformationQuery.setDeviceName(deviceName);
|
|
|
+// RingScanInformation ringScanInformations = ringScanInformationMapper.selectRingScanInformationListDateTimeMax(ringScanInformationQuery);
|
|
|
+//// if(ringScanInformations!=null){
|
|
|
+// //拿到上次扫描的时间
|
|
|
+// LocalDateTime scanningTime1 = ringScanInformations.getScanningTime();
|
|
|
+// //拿到当前系统时间
|
|
|
+// LocalDateTime now = LocalDateTime.now();
|
|
|
+// //计算两次时间的时间差
|
|
|
+// Duration duration = Duration.between(scanningTime1, now);
|
|
|
+// boolean isTwoMinutesPassed = duration.toMinutes() < 1;
|
|
|
+// //判断两次时间是否大于
|
|
|
+// if (isTwoMinutesPassed) {
|
|
|
+// return "同一设备,两分钟之内不能重复扫描";
|
|
|
+// }
|
|
|
+// }
|
|
|
+ String contentInformation = stationProductScanningRingVo.getContentInformation();//扫描内容
|
|
|
+ RingScanInformation ringScanInformation=new RingScanInformation();
|
|
|
+ ringScanInformation.setContentInformation(contentInformation);
|
|
|
+ LocalDateTime localDateTime = DateUtils.toLocalDateTime(scanningTime, "yyyy-MM-dd HH:mm:ss");
|
|
|
+ ringScanInformation.setScanningTime(localDateTime);
|
|
|
+ ringScanInformation.setDeviceName(deviceName);
|
|
|
+ ringScanInformation.setDeviceNumber(deviceNumber);
|
|
|
+ //赋值当前扫描人
|
|
|
+ TerminalInformation terminalInformation=new TerminalInformation();
|
|
|
+ terminalInformation.setStationName(deviceNumber);
|
|
|
+ List<TerminalInformation> terminalInformations = terminalInformationMapper.selectTerminalInformationList(terminalInformation);
|
|
|
+ if(terminalInformations.size()>0){
|
|
|
+ ringScanInformation.setPersonnelName(terminalInformations.get(0).getPersonnelName());
|
|
|
+ ringScanInformation.setProcess(terminalInformations.get(0).getProcess());
|
|
|
+ ringScanInformation.setProcessName(terminalInformations.get(0).getProcessName());
|
|
|
+ }
|
|
|
+
|
|
|
+ String nativeNumber="";
|
|
|
+ if(contentInformation.contains("Z")){
|
|
|
+ nativeNumber = contentInformation.replace("Z", "");
|
|
|
+ }
|
|
|
+ if(contentInformation.contains("D")){
|
|
|
+ nativeNumber=contentInformation.replace("D","");
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotNull(nativeNumber)&&nativeNumber!=""){
|
|
|
+ //取值真实的扫描内容
|
|
|
+ ringScanInformation.setNativeNumbering(nativeNumber);
|
|
|
+ }else {
|
|
|
+ //扫描内容
|
|
|
+ ringScanInformation.setNativeNumbering(contentInformation);
|
|
|
+ }
|
|
|
+ //根据扫描内容拿到生产订单号和订单号
|
|
|
+ String queryStringOrderNumberAndProductionOrderNumber="{\n" +
|
|
|
+ " \"FormId\": \"PRD_MO\",\n" +
|
|
|
+ " \"FieldKeys\": \"FSaleOrderNo,FBillNo\",\n" +
|
|
|
+ " \"FilterString\": [{\"Left\":\"\",\"FieldName\":\"FSerialNo\",\"Compare\":\"17\",\"Value\":\""+ringScanInformation.getNativeNumbering()+"\",\"Right\":\"\",\"Logic\":0}],\n" +
|
|
|
+ " \"OrderString\": \"\",\n" +
|
|
|
+ " \"TopRowCount\": 0,\n" +
|
|
|
+ " \"StartRow\": 0,\n" +
|
|
|
+ " \"Limit\": 2000,\n" +
|
|
|
+ " \"SubSystemId\": \"\"\n" +
|
|
|
+ "}";
|
|
|
+ Map<String, Object> map = JSON.parseObject(queryStringOrderNumberAndProductionOrderNumber, Map.class);
|
|
|
+ K3CloudApi api = new K3CloudApi();
|
|
|
+ String resultJson = api.billQuery(JSON.toJSONString(map));
|
|
|
+ //判断内不为空
|
|
|
+ if(resultJson!=""&resultJson!="[]"){
|
|
|
+ List<JdProductionOrder> jdProductionOrders = JSON.parseArray(resultJson, JdProductionOrder.class);
|
|
|
+ if(jdProductionOrders.size()>0){
|
|
|
+ //需求单据号
|
|
|
+ ringScanInformation.setOrderNumber(jdProductionOrders.get(0).getDemandDocument());
|
|
|
+ //生产订单号
|
|
|
+ ringScanInformation.setProductionOrderNumber(jdProductionOrders.get(0).getDocumentNumber());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotNull(ringScanInformation.getOrderNumber())){
|
|
|
+ //--记录第一扫描(将来第一扫描的单据记录)
|
|
|
+ RingScanInformationFirst ringScanInformationFirst=new RingScanInformationFirst();
|
|
|
+ ringScanInformationFirst.setOrderNumber(ringScanInformation.getOrderNumber());
|
|
|
+ List<RingScanInformationFirst> ringScanInformationFirsts = ringScanInformationFirstMapper.selectRingScanInformationFirstList(ringScanInformationFirst);
|
|
|
+ if(ringScanInformationFirsts.size()<=0){
|
|
|
+ ringScanInformationFirst.setProductionOrderNumber(ringScanInformation.getProductionOrderNumber());
|
|
|
+ ringScanInformationFirst.setStatus("1");
|
|
|
+ ringScanInformationFirst.setStartTime(LocalDateTime.now());//开始时间
|
|
|
+ //查询这个订单的总数量是多少
|
|
|
+ String sa="{\n" +
|
|
|
+ " \"FormId\": \"SAL_SaleOrder\",\n" +
|
|
|
+ " \"FieldKeys\": \"FBillNo,FQty\",\n" +
|
|
|
+ " \"FilterString\": [{\"Left\":\"\",\"FieldName\":\"FBillNo\",\"Compare\":\"17\",\"Value\":\""+ringScanInformation.getOrderNumber()+"+\",\"Right\":\"\",\"Logic\":0}],\n" +
|
|
|
+ " \"OrderString\": \"\",\n" +
|
|
|
+ " \"TopRowCount\": 0,\n" +
|
|
|
+ " \"StartRow\": 0,\n" +
|
|
|
+ " \"Limit\": 2000,\n" +
|
|
|
+ " \"SubSystemId\": \"\"\n" +
|
|
|
+ "}";
|
|
|
+ Map<String, Object> mapTotal = JSON.parseObject(sa, Map.class);
|
|
|
+ String resultJsonTotal = api.billQuery(JSON.toJSONString(mapTotal));
|
|
|
+ List<Map> mapListTotal = JSON.parseArray(resultJsonTotal, Map.class);
|
|
|
+ Double totalAmount = mapListTotal.stream()
|
|
|
+ .filter(map1 -> map1.containsKey("FQty")) // 确保 map 中包含 "amount" 字段
|
|
|
+ .mapToDouble(map1 -> ((Number) map1.get("FQty")).doubleValue()) // 将 "amount" 字段转换为 double
|
|
|
+ .sum(); // 求和
|
|
|
+ ringScanInformationFirst.setTotalQuantity(String.valueOf(totalAmount.intValue()));
|
|
|
+ int i = ringScanInformationFirstMapper.insertRingScanInformationFirst(ringScanInformationFirst);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ int i2 = ringScanInformationMapper.insertRingScanInformation(ringScanInformation);
|
|
|
+ if(i2>0){
|
|
|
+ return "扫描成功";
|
|
|
+ }else {
|
|
|
+ return "扫描失败";
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+
|
|
|
+// //产品扫描逻辑
|
|
|
+// String[] content = stationProductScanningRingVo.getContentInformation().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();
|
|
|
+// reportInformationSheet.setCurrentStationStationPeople(stationInformation1.getPersonnelName());//工位人员姓名
|
|
|
+// 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){
|
|
|
+// //插入异常报工信息
|
|
|
+// extracted(reportInformationSheet,"未找到当前产品计划报工失败--信息不匹配");
|
|
|
+// return "未找到当前产品计划报工失败--信息不匹配";
|
|
|
+// }else {
|
|
|
+// 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 "扫码报工失败";
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }else{
|
|
|
+// 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);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|