| | |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.example.erp.common.Constants; |
| | | import com.example.erp.common.Result; |
| | | import com.example.erp.entity.pp.FlowCard; |
| | | import com.example.erp.entity.sd.*; |
| | | import com.example.erp.entity.userInfo.Log; |
| | | import com.example.erp.entity.userInfo.SysError; |
| | | import com.example.erp.exception.ServiceException; |
| | | import com.example.erp.mapper.pp.FlowCardMapper; |
| | | import com.example.erp.mapper.pp.ReportingWorkMapper; |
| | | import com.example.erp.mapper.sd.*; |
| | | import com.example.erp.service.userInfo.LogService; |
| | | import com.example.erp.service.userInfo.SysErrorService; |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.time.LocalDate; |
| | |
| | | import java.util.Map; |
| | | |
| | | import com.fasterxml.jackson.core.type.TypeReference; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | | |
| | | import java.io.IOException; |
| | | |
| | | |
| | | import java.sql.Date; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.IntStream; |
| | |
| | | private final OrderDetailMapper orderDetailMapper; |
| | | private final OrderMapper orderMapper; |
| | | private final ReportingWorkMapper reportingWorkMapper; |
| | | @Autowired |
| | | SysErrorService sysErrorService; |
| | | |
| | | public FlowCardService(FlowCardMapper flowCardMapper, OrderGlassDetailMapper orderGlassDetailMapper, |
| | | OrderProcessDetailMapper orderProcessDetailMapper, LogService logService, |
| | |
| | | this.reportingWorkMapper = reportingWorkMapper; |
| | | } |
| | | |
| | | //将层数字符串用逗号隔开 |
| | | public static String splitTechNumbers(String input) { |
| | | if (input == null || input.isEmpty()) { |
| | | return ""; |
| | | } |
| | | |
| | | List<String> result = new ArrayList<>(); |
| | | for (int i = 0; i < input.length(); i++) { |
| | | // 特殊处理 "10" |
| | | if (input.charAt(i) == '1' && i + 1 < input.length() && input.charAt(i + 1) == '0') { |
| | | result.add("10"); |
| | | i++; // 跳过下一个字符 |
| | | } else { |
| | | result.add(String.valueOf(input.charAt(i))); |
| | | } |
| | | } |
| | | |
| | | return String.join(",", result); |
| | | } |
| | | //流程卡管理查询 |
| | | public Map<String, Object> selectProcessCard(Integer pageNum, Integer pageSize,List<String> selectDate, FlowCard flowCard) { |
| | | Integer offset = (pageNum - 1) * pageSize; |
| | |
| | | } |
| | | |
| | | //保存流程卡数据 |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Boolean addFlowCardSv(String orderId, Map<String, Object> object) { |
| | | String userName = ""; |
| | | if (object.get("userName") != null) { |
| | | userName = object.get("userName").toString(); |
| | | } |
| | | String productionId = ""; |
| | | if (object.get("productionId") != null) { |
| | | productionId = object.get("productionId").toString(); |
| | | } |
| | | |
| | | List<FlowCard> FlowCardList = JSONArray.parseArray(JSONObject.toJSONString(object.get("flowCard")), FlowCard.class); |
| | | if (!FlowCardList.isEmpty()) { |
| | | for (FlowCard flowCard : FlowCardList) { |
| | | //查询每个序号的层数 |
| | | Integer layer = flowCardMapper.selectLayer(productionId, flowCard.getOrderNumber()); |
| | | //添加流程卡数据 |
| | | flowCardMapper.addFlowCardMp(flowCard.getProcessId(), flowCard.getOrderNumber(), flowCard.getLandingSequence(), flowCard.getQuantity(), productionId, userName, layer); |
| | | //修改分架状态,将状态改为1 |
| | | flowCardMapper.updateFlowState(productionId, flowCard.getOrderNumber()); |
| | | //查询该订单未分架数量 |
| | | Integer FlowCount = flowCardMapper.selectFlowCount(orderId); |
| | | if (FlowCount == 0) { |
| | | //修改订单表分架状态为2 |
| | | flowCardMapper.updateProcessingCard(orderId, 2); |
| | | } else { |
| | | //修改订单表分架状态为1,未全部分架完成 |
| | | flowCardMapper.updateProcessingCard(orderId, 1); |
| | | } |
| | | //查询订单小片表获取工艺传入小片工艺表 |
| | | List<OrderGlassDetail> orderGlassDetailList = |
| | | orderGlassDetailMapper.selectList( |
| | | new QueryWrapper<OrderGlassDetail>() |
| | | .eq("order_id", orderId) |
| | | .eq("order_number", flowCard.getOrderNumber()) |
| | | ); |
| | | List<OrderProcessDetail> orderProcessDetailList = getOrderProcessDetails(orderGlassDetailList); |
| | | orderProcessDetailList.forEach( |
| | | orderGlassDetail -> orderGlassDetail.setProcessId(flowCard.getProcessId())); |
| | | |
| | | //赋值订单工艺表 |
| | | orderProcessDetailMapper.insertOrderProcessDetail(orderProcessDetailList); |
| | | boolean saveState = true; |
| | | //设置回滚点 |
| | | Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint(); |
| | | try { |
| | | String userName = ""; |
| | | if (object.get("userName") != null) { |
| | | userName = object.get("userName").toString(); |
| | | } |
| | | //保存日志 |
| | | Log log = new Log(); |
| | | log.setContent(object.toString()); |
| | | log.setFunction("addFlowCardSv流程卡新增"); |
| | | log.setOperatorId((String) object.get("userId")); |
| | | log.setOperator((String) object.get("userName")); |
| | | logService.saveLog(log); |
| | | return true; |
| | | } else { |
| | | return false; |
| | | String productionId = ""; |
| | | if (object.get("productionId") != null) { |
| | | productionId = object.get("productionId").toString(); |
| | | } |
| | | |
| | | List<FlowCard> FlowCardList = JSONArray.parseArray(JSONObject.toJSONString(object.get("flowCard")), FlowCard.class); |
| | | if (!FlowCardList.isEmpty()) { |
| | | for (FlowCard flowCard : FlowCardList) { |
| | | //查询每个序号的层数 |
| | | Integer layer = flowCardMapper.selectLayer(productionId, flowCard.getOrderNumber()); |
| | | //添加流程卡数据 |
| | | flowCardMapper.addFlowCardMp(flowCard.getProcessId(), flowCard.getOrderNumber(), flowCard.getLandingSequence(), flowCard.getQuantity(), productionId, userName, layer); |
| | | //修改分架状态,将状态改为1 |
| | | flowCardMapper.updateFlowState(productionId, flowCard.getOrderNumber()); |
| | | //查询该订单未分架数量 |
| | | Integer FlowCount = flowCardMapper.selectFlowCount(orderId); |
| | | if (FlowCount == 0) { |
| | | //修改订单表分架状态为2 |
| | | flowCardMapper.updateProcessingCard(orderId, 2); |
| | | } else { |
| | | //修改订单表分架状态为1,未全部分架完成 |
| | | flowCardMapper.updateProcessingCard(orderId, 1); |
| | | } |
| | | //查询订单小片表获取工艺传入小片工艺表 |
| | | List<OrderGlassDetail> orderGlassDetailList = |
| | | orderGlassDetailMapper.selectList( |
| | | new QueryWrapper<OrderGlassDetail>() |
| | | .eq("order_id", orderId) |
| | | .eq("order_number", flowCard.getOrderNumber()) |
| | | ); |
| | | List<OrderProcessDetail> orderProcessDetailList = getOrderProcessDetails(orderGlassDetailList); |
| | | orderProcessDetailList.forEach( |
| | | orderGlassDetail -> orderGlassDetail.setProcessId(flowCard.getProcessId())); |
| | | |
| | | //赋值订单工艺表 |
| | | orderProcessDetailMapper.insertOrderProcessDetail(orderProcessDetailList); |
| | | } |
| | | //保存日志 |
| | | Log log = new Log(); |
| | | log.setContent(object.toString()); |
| | | log.setFunction("addFlowCardSv流程卡新增"); |
| | | log.setOperatorId((String) object.get("userId")); |
| | | log.setOperator((String) object.get("userName")); |
| | | logService.saveLog(log); |
| | | } else { |
| | | saveState = false; |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint); |
| | | //将异常传入数据库 |
| | | SysError sysError = new SysError(); |
| | | sysError.setError(e+Arrays.toString(e.getStackTrace())); |
| | | sysError.setFunc("updateFinishedGoodsInventoryAllocate"); |
| | | sysErrorService.insert(sysError); |
| | | saveState = false; |
| | | |
| | | } |
| | | return saveState; |
| | | |
| | | } |
| | | |
| | | public Map<String, Object> selectSchedulingSv(String selectTime1, String selectTime2, String orderId, String processes, Integer state, FlowCard flowCard) { |
| | |
| | | //获取工序对应的别称 |
| | | String processName = flowCardMapper.getProcessName(processSub); |
| | | //processName.equals("stepC") || processName.equals("stepD") |
| | | if (processName.equals("stepC") || processName.equals("stepD")) {//工艺是否包含夹胶中空 |
| | | if (processName.equals("stepC") || processName.equals("stepD")) {//工艺是否包含夹胶中空,流程卡查询合并 |
| | | itemmap.put("detail", flowCardMapper.getPrimaryListLimt(flowCard.getProcessId(), |
| | | String.valueOf("null".equals(compound) |
| | | ? flowCard.getTechnologyNumber()//正常层 |
| | |
| | | if (compound == null |
| | | || "null".equals(compound) |
| | | || compound.trim().isEmpty()){ |
| | | List<Map<String, Object>> detailList = flowCardMapper.getDetailList(flowCard.getProcessId(), flowCard.getTechnologyNumber(), flowCard.getProcess(),flashback,landingSequence); |
| | | List<Map<String, Object>> detailList = flowCardMapper.getDetailList(flowCard.getProcessId(), splitTechNumbers(flowCard.getTechnologyNumber()), flowCard.getProcess(),flashback,landingSequence); |
| | | itemmap.put("detailList", detailList); |
| | | }else {//有需要同架的层 |
| | | List<Map<String, Object>> detailList = flowCardMapper.getDetailCompoundList(flowCard.getProcessId(), flowCard.getTechnologyNumber(), flowCard.getProcess(),flashback,compound,landingSequence); |
| | | List<Map<String, Object>> detailList = flowCardMapper.getDetailCompoundList(flowCard.getProcessId(), splitTechNumbers(flowCard.getTechnologyNumber()), flowCard.getProcess(),flashback,splitTechNumbers(compound),landingSequence); |
| | | itemmap.put("detailList", detailList); |
| | | } |
| | | } else { |
| | | if (merge.equals("1") && flowCard.getMerge().equals(1)) {//否 |
| | | if (merge.equals("1") && flowCard.getMerge().equals(1)) {//未启用,配置文件flowCardMerge值为1 |
| | | // 检查是否已经处理过该 processId,如果处理过则跳过 |
| | | if (processedKeys.contains(uniqueKey)) { |
| | | continue; |
| | |
| | | if (compound == null |
| | | || "null".equals(compound) |
| | | || compound.trim().isEmpty()){ |
| | | List<Map<String, Object>> detailList = flowCardMapper.getDetailListLike(flowCard.getProcessId(), String.valueOf(flowCard.getTechnologyNumber()), flowCard.getProcess(),flashback,landingSequence); |
| | | |
| | | List<Map<String, Object>> detailList = flowCardMapper.getDetailListLike(flowCard.getProcessId(), splitTechNumbers(flowCard.getTechnologyNumber()), flowCard.getProcess(),flashback,landingSequence); |
| | | itemmap.put("detailList", detailList); |
| | | }else {//有需要同架的层 |
| | | List<Map<String, Object>> detailList = flowCardMapper.getDetailListLikeCompound(flowCard.getProcessId(), String.valueOf(flowCard.getTechnologyNumber()), flowCard.getProcess(),flashback,compound,landingSequence); |
| | | List<Map<String, Object>> detailList = flowCardMapper.getDetailListLikeCompound(flowCard.getProcessId(), splitTechNumbers(flowCard.getTechnologyNumber()), flowCard.getProcess(),flashback,splitTechNumbers(compound),landingSequence); |
| | | itemmap.put("detailList", detailList); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | } else {//否 |
| | | //流程卡明细数据 |
| | | if (printLike.equals("") || printLike.equals("null")) { |
| | | itemmap.put("detail", flowCardMapper.getPrimaryListMerge(flowCard.getProcessId(), printMerge, flowCard.getOrderId())); |
| | | |
| | | List<Map<String, Object>> detailList = flowCardMapper.getDetailList(flowCard.getProcessId(), flowCard.getTechnologyNumber(), flowCard.getProcess(), flashback, landingSequence); |
| | | itemmap.put("detailList", detailList); |
| | | } else { |
| | | itemmap.put("detail", flowCardMapper.getPrimaryList(flowCard.getProcessId(), String.valueOf(flowCard.getTechnologyNumber()), flowCard.getGlassChild(), flowCard.getProcess(), flowCard.getOrderId())); |
| | | |
| | | List<Map<String, Object>> detailList = flowCardMapper.getDetailListLike(flowCard.getProcessId(), printMerge, flowCard.getProcess(), flashback, landingSequence); |
| | | itemmap.put("detailList", detailList); |
| | | } |
| | | } |
| | | |
| | | //工艺流程 |
| | |
| | | // 判断是否为非空字符串 |
| | | if (orderNumber != null && !orderNumber.trim().isEmpty()) { |
| | | |
| | | itemmap.put("data", flowCardMapper.getPrintCustomDataSemi( |
| | | List<Map<String, Object>> customDataSemi =flowCardMapper.getPrintCustomDataSemi( |
| | | flowCard.getProcessId(), |
| | | flowCard.getTechnologyNumber(), |
| | | flowCard.getProcess(), |
| | | flowCard.getOrderNumber(), flowCard.getPrintQuantity() |
| | | )); |
| | | flowCard.getOrderNumber(), flowCard.getPrintQuantity()); |
| | | for (Map<String, Object> dataMap : customDataSemi) { |
| | | dataMap.put("newList", flowCardMapper.getgetPrintCustomDataSemiSp( |
| | | flowCard.getProcessId(), |
| | | dataMap.get("technologyNumber").toString(), |
| | | flowCard.getOrderNumber() |
| | | )); |
| | | } |
| | | itemmap.put("data", customDataSemi); |
| | | } else { |
| | | //用于天津现场流程卡打印界面的小片标签打印 |
| | | itemmap.put("data", flowCardMapper.getPrintCustomDataSemiTj( |
| | |
| | | return map; |
| | | } |
| | | |
| | | public Map<String, Object> selectPrintProjectDetailSmallPiece(Map<String, Object> object) throws JsonProcessingException { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | String projectNo=object.get("projectNo").toString(); |
| | | String stockIdsStr=object.get("stockId").toString(); |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | if (stockIdsStr != null && !stockIdsStr.isEmpty()) { |
| | | List<Integer> list = objectMapper.readValue(stockIdsStr, new TypeReference<List<Integer>>() {}); |
| | | map.put("data", flowCardMapper.getPrintProjectDetailsMpSp(projectNo,list)); |
| | | } |
| | | |
| | | return map; |
| | | } |
| | | |
| | | public Map<String, Object> getPrintCustomDataProjectNoDetailSv(String type, Integer detailType, Map<String, Object> object) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();//最终结果 |
| | |
| | | Map<String, Object> itemmap = new HashMap<>(); |
| | | //是否是工程明细打印 |
| | | if (detailType == 0) {//工程打印明细 |
| | | itemmap.put("data", flowCardMapper.getPrintCustomDataProjectDetail(flowCard.getProjectNo(), flowCard.getStockId(),flowCard.getPolysId())); |
| | | |
| | | itemmap.put("data", flowCardMapper.getPrintCustomDataProjectDetail(flowCard.getProjectNo(), flowCard.getStockId())); |
| | | |
| | | } |
| | | //非工程打印 |
| | |
| | | } |
| | | //将原来已报工的数据更新 |
| | | if (resultList != null && !resultList.isEmpty()) { |
| | | for (OrderProcessDetail d : resultList) { |
| | | flowCardMapper.updateOrderProcessDetail(d.getProcessId(),d.getOrderNumber(),d.getTechnologyNumber(), |
| | | d.getReportingWorkNumCount(),d.getReportingWorkNum(),d.getBrokenNum(),d.getProcess()); |
| | | |
| | | for (String number : numberList) { |
| | | for (OrderProcessDetail d : resultList) { |
| | | flowCardMapper.updateOrderProcessDetail(d.getProcessId(),number,d.getTechnologyNumber(), |
| | | d.getReportingWorkNumCount(),d.getReportingWorkNum(),d.getBrokenNum(),d.getProcess()); |
| | | } |
| | | } |
| | | |
| | | } |
| | | return true; |
| | | |
| | |
| | | |
| | | if (orderDetail.getQuantity() > shelfQuantity) { |
| | | newOrderDetail.setProcessId(processId); |
| | | newOrderDetail.setLongSide(orderDetail.getLongSide()); |
| | | newOrderDetail.setShortSide(orderDetail.getShortSide()); |
| | | newOrderDetail.setBuildingNumber(orderDetail.getBuildingNumber()); |
| | | newOrderDetail.setQuantity(Long.valueOf(shelfQuantity)); |
| | | newOrderDetail.setHeight(orderDetail.getHeight()); |
| | | newOrderDetail.setWidth(orderDetail.getWidth()); |
| | |
| | | shelfQuantity = shelfQuantity - shelfQuantity; |
| | | } else { |
| | | newOrderDetail.setProcessId(processId); |
| | | newOrderDetail.setLongSide(orderDetail.getLongSide()); |
| | | newOrderDetail.setShortSide(orderDetail.getShortSide()); |
| | | newOrderDetail.setBuildingNumber(orderDetail.getBuildingNumber()); |
| | | |
| | | newOrderDetail.setQuantity(orderDetail.getQuantity()); |
| | | newOrderDetail.setHeight(orderDetail.getHeight()); |
| | | newOrderDetail.setWidth(orderDetail.getWidth()); |
| | |
| | | |
| | | public Boolean updateTerminationSv(String processId, Integer orderNumber, Integer value) { |
| | | if (processId!=""){ |
| | | |
| | | flowCardMapper.updateTerminationMp(processId,orderNumber,value); |
| | | //获取终止数量与流程卡数量比较 |
| | | Map<String, Object> data = flowCardMapper.getTerminationQuantity(processId,orderNumber); |
| | | Integer terminationNum = (Integer) data.get("termination_quantity"); |
| | | Integer totalNum = (Integer) data.get("quantity"); |
| | | if (terminationNum==totalNum){ |
| | | flowCardMapper.updateTerminationStatus(processId,orderNumber); |
| | | } |
| | | return true; |
| | | }else { |
| | | return false; |
| | | } |
| | | |
| | | } |
| | | |
| | | public Boolean updateTerminationNoSv(String processId, Integer orderNumber) { |
| | | if (processId!=""){ |
| | | flowCardMapper.updateTerminationNoMp(processId,orderNumber); |
| | | |
| | | return true; |
| | | }else { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | public Map<String, Object> selectCompletedSv(String processId, Integer orderNumber, String process) { |
| | |
| | | } |
| | | |
| | | |
| | | public Result selectProcessCardProgressSv(Map<String, String> object) { |
| | | String orderId = object.get("orderId"); |
| | | String processId = object.get("processId"); |
| | | String orderNumber = object.get("orderNumber"); |
| | | String technologyNumber = object.get("technologyNumber"); |
| | | String process = object.get("process"); |
| | | Result result = new Result(); |
| | | //当流程卡和订单号都为空时,返回提示信息 |
| | | if (orderId == null &&processId == null){ |
| | | result.setCode(Constants.Code_600); |
| | | result.setMsg("Please enter at least one parameter for the order number and the process card."); |
| | | return result; |
| | | } |
| | | return result.success( |
| | | orderProcessDetailMapper |
| | | .selectProcessCardProgressSv( orderId, processId, orderNumber, technologyNumber, process) |
| | | ); |
| | | |
| | | } |
| | | |
| | | public boolean getNewProcessSv(String processId, String orderNumber, String technologyNumber, List<String> orderProcess) { |
| | | |
| | | // 获取最新报工工序 |
| | | List<Map<String, Object>> newProcess = flowCardMapper.getNewProcessMp(processId, orderNumber, technologyNumber); |
| | | |
| | | if (newProcess == null || newProcess.isEmpty()) { |
| | | return false; // 找不到标准值 |
| | | } |
| | | |
| | | // 最新工序排序号 |
| | | int standardSort = Integer.parseInt(newProcess.get(0).get("sort").toString()); |
| | | |
| | | // 循环 orderProcess 的每一个工序,查询它们的 sort |
| | | for (String processName : orderProcess) { |
| | | Map<String, Object> data = flowCardMapper.getProcessInfo(processName); |
| | | |
| | | if (data == null) { |
| | | return false; // 工序查不到 |
| | | } |
| | | int orderSort = Integer.parseInt(data.get("sort").toString()); |
| | | // orderSort 必须 > standardSort |
| | | if (orderSort <= standardSort) { |
| | | return false; |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | |