| | |
| | | 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.OrderDetail; |
| | | import com.example.erp.entity.sd.OrderGlassDetail; |
| | | import com.example.erp.entity.sd.OrderProcessDetail; |
| | | 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.sd.OrderGlassDetailMapper; |
| | | import com.example.erp.mapper.sd.OrderProcessDetailMapper; |
| | | 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.List; |
| | | 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; |
| | | |
| | | import static com.example.erp.service.sd.OrderService.getOrderProcessDetails; |
| | | |
| | |
| | | OrderProcessDetailMapper orderProcessDetailMapper; |
| | | final |
| | | LogService logService; |
| | | private final ProductMapper productMapper; |
| | | private final ProductDetailMapper productDetailMapper; |
| | | |
| | | public FlowCardService(FlowCardMapper flowCardMapper, OrderGlassDetailMapper orderGlassDetailMapper, OrderProcessDetailMapper orderProcessDetailMapper, LogService logService) { |
| | | 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, |
| | | ProductMapper productMapper, ProductDetailMapper productDetailMapper, |
| | | OrderDetailMapper orderDetailMapper, OrderMapper orderMapper,ReportingWorkMapper reportingWorkMapper) { |
| | | this.flowCardMapper = flowCardMapper; |
| | | this.orderGlassDetailMapper = orderGlassDetailMapper; |
| | | this.orderProcessDetailMapper = orderProcessDetailMapper; |
| | | this.logService = logService; |
| | | this.productMapper = productMapper; |
| | | this.productDetailMapper = productDetailMapper; |
| | | this.orderDetailMapper = orderDetailMapper; |
| | | this.orderMapper = orderMapper; |
| | | 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, Date selectTime1, Date selectTime2, FlowCard flowCard) { |
| | | public Map<String, Object> selectProcessCard(Integer pageNum, Integer pageSize,List<String> selectDate, FlowCard flowCard) { |
| | | Integer offset = (pageNum - 1) * pageSize; |
| | | String endDate = LocalDate.now().toString(); |
| | | String startDate = LocalDate.now().minusDays(15).toString(); |
| | | if(selectDate !=null && selectDate.size()==2){ |
| | | if(!selectDate.get(0).isEmpty()){ |
| | | startDate = selectDate.get(0); |
| | | } |
| | | if(!selectDate.get(1).isEmpty()){ |
| | | endDate = selectDate.get(1); |
| | | } |
| | | } |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("data", flowCardMapper.selectFlowCard(offset, pageSize, selectTime1, selectTime2, flowCard)); |
| | | map.put("total", flowCardMapper.getPageTotal(offset, pageSize, selectTime1, selectTime2, flowCard)); |
| | | map.put("data", flowCardMapper.selectFlowCard(offset, pageSize, startDate, endDate, flowCard)); |
| | | map.put("total", flowCardMapper.getPageTotal(offset, pageSize, startDate, endDate, flowCard)); |
| | | List<String> list = new ArrayList<>(); |
| | | list.add(startDate); |
| | | list.add(endDate); |
| | | map.put("selectDate",list); |
| | | return map; |
| | | } |
| | | |
| | | //分架查询 |
| | | public Map<String, Object> selectAddProcess(Date selectTime1, Date selectTime2, FlowCard flowCard) { |
| | | public Map<String, Object> selectAddProcess(List<String> selectDate, FlowCard flowCard) { |
| | | String endDate = LocalDate.now().toString(); |
| | | String startDate = LocalDate.now().minusDays(15).toString(); |
| | | if(selectDate !=null && selectDate.size()==2){ |
| | | if(!selectDate.get(0).isEmpty()){ |
| | | startDate = selectDate.get(0); |
| | | } |
| | | if(!selectDate.get(1).isEmpty()){ |
| | | endDate = selectDate.get(1); |
| | | } |
| | | } |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("data", flowCardMapper.selectFlowCardMp(selectTime1, selectTime2, flowCard)); |
| | | map.put("data", flowCardMapper.selectFlowCardMp( startDate, endDate, flowCard)); |
| | | List<String> list = new ArrayList<>(); |
| | | list.add(startDate); |
| | | list.add(endDate); |
| | | map.put("selectDate",list); |
| | | return map; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | //保存流程卡数据 |
| | | @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) { |
| | |
| | | public Object flowCardDetailSv(String processId, FlowCard flowCard) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("data", flowCardMapper.flowCardDetailMp(processId, flowCard)); |
| | | map.put("merge", flowCardMapper.flowCardDetailMergeMp(processId)); |
| | | return map; |
| | | } |
| | | |
| | | public Object selectPrintFlowCardSv(Date selectTime1, Date selectTime2, String orderId, String project, String userId, Integer state, FlowCard flowCard) { |
| | | public Object selectPrintFlowCardSv(List<String> selectDate, String orderId, String project, String userId, Integer state, FlowCard flowCard) { |
| | | if ("null".equals(orderId)) { |
| | | orderId = ""; |
| | | } |
| | | if ("null".equals(project)) { |
| | | project = ""; |
| | | } |
| | | String endDate = LocalDate.now().toString(); |
| | | String startDate = LocalDate.now().minusDays(15).toString(); |
| | | if(selectDate !=null && selectDate.size()==2){ |
| | | if(!selectDate.get(0).isEmpty()){ |
| | | startDate = selectDate.get(0); |
| | | } |
| | | if(!selectDate.get(1).isEmpty()){ |
| | | endDate = selectDate.get(1); |
| | | } |
| | | } |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("data", flowCardMapper.selectPrintFlowCardMp(selectTime1, selectTime2, orderId, project,state, flowCard)); |
| | | map.put("data", flowCardMapper.selectPrintFlowCardMp(startDate, endDate, orderId, project,state, flowCard)); |
| | | String roleId = flowCardMapper.selectUserMp(userId); |
| | | map.put("user", roleId); |
| | | List<String> list = new ArrayList<>(); |
| | | list.add(startDate); |
| | | list.add(endDate); |
| | | map.put("selectDate",list); |
| | | return map; |
| | | } |
| | | |
| | | public Object selectPrintFlowCard(Date selectTime1, Date selectTime2) { |
| | | public Object selectPrintFlowCard(List<String> selectDate) { |
| | | String endDate = LocalDate.now().toString(); |
| | | String startDate = LocalDate.now().minusDays(15).toString(); |
| | | if(selectDate !=null && selectDate.size()==2){ |
| | | if(!selectDate.get(0).isEmpty()){ |
| | | startDate = selectDate.get(0); |
| | | } |
| | | if(!selectDate.get(1).isEmpty()){ |
| | | endDate = selectDate.get(1); |
| | | } |
| | | } |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("data", flowCardMapper.selectPrintFlowCard(selectTime1, selectTime2)); |
| | | map.put("data", flowCardMapper.selectPrintFlowCard(startDate, endDate)); |
| | | List<String> list = new ArrayList<>(); |
| | | list.add(startDate); |
| | | list.add(endDate); |
| | | map.put("selectDate",list); |
| | | return map; |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | public Map<String, Object> getSelectPrintingSv(Map<String, Object> object, String printMerge, String printLike, String merge) { |
| | | public Map<String, Object> getSelectPrintingSv(Map<String, Object> object, String printMerge, String printLike, String merge, String flashback, String compound, String landingSequence) { |
| | | if (printMerge == null) { |
| | | printMerge = ""; |
| | | } |
| | |
| | | List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();//最终结果 |
| | | List<FlowCard> flowCardList = JSONArray.parseArray(JSONObject.toJSONString(object.get("printList")), FlowCard.class); |
| | | if (!flowCardList.isEmpty()) { |
| | | Set<String> processedProcessIds = new HashSet<>(); // 用来存放已处理过的 processId |
| | | Set<String> processedKeys = new HashSet<>(); |
| | | for (FlowCard flowCard : flowCardList) { |
| | | String processId = flowCard.getProcessId(); |
| | | Integer orderNumber = flowCard.getOrderNumber(); |
| | | String uniqueKey = processId + "|" + orderNumber; // 用特殊字符连接防止冲突 |
| | | Map<String, Object> itemmap = new HashMap<>(); |
| | | //流程卡表头表尾数据 |
| | | //是否传入合并层数 |
| | | if (printMerge.equals("") || printMerge.equals("null")) { |
| | | //是否包含切割 |
| | | //boolean containsCutting = flowCard.getProcess().contains("切割"); |
| | | String processSub = flowCard.getProcess().substring(0, 2); |
| | | if (processSub.equals("夹胶") || processSub.equals("中空")) {//工艺是否包含夹胶中空 |
| | | itemmap.put("detail", flowCardMapper.getPrimaryListLimt(flowCard.getProcessId(), String.valueOf(flowCard.getTechnologyNumber()), flowCard.getGlassChild(), flowCard.getProcess(), flowCard.getOrderId())); |
| | | String processSub = flowCard.getProcess().split("->")[0]; |
| | | //获取工序对应的别称 |
| | | String processName = flowCardMapper.getProcessName(processSub); |
| | | //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()//正常层 |
| | | : compound ),//同架层 |
| | | flowCard.getGlassChild(), flowCard.getProcess(), flowCard.getOrderId())); |
| | | |
| | | List<Map<String, Object>> detailList = flowCardMapper.getDetailList(flowCard.getProcessId(), flowCard.getTechnologyNumber(), flowCard.getProcess()); |
| | | itemmap.put("detailList", detailList); |
| | | if (compound == null |
| | | || "null".equals(compound) |
| | | || compound.trim().isEmpty()){ |
| | | 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(), 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 (processedProcessIds.contains(flowCard.getProcessId())) { |
| | | if (processedKeys.contains(uniqueKey)) { |
| | | continue; |
| | | } |
| | | // 将该 processId 加入已处理集合 |
| | | processedProcessIds.add(flowCard.getProcessId()); |
| | | processedKeys.add(uniqueKey); |
| | | itemmap.put("detail", flowCardMapper.getPrimaryList(flowCard.getProcessId(), String.valueOf(flowCard.getTechnologyNumber()), flowCard.getGlassChild(), flowCard.getProcess(), flowCard.getOrderId())); |
| | | |
| | | List<Map<String, Object>> detailList = flowCardMapper.getDetailListMerge(flowCard.getProcessId(), flowCard.getProcess()); |
| | | List<Map<String, Object>> detailList = flowCardMapper.getDetailListMerge(flowCard.getProcessId(), 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())); |
| | | itemmap.put("detail", flowCardMapper.getPrimaryListLimt(flowCard.getProcessId(), |
| | | String.valueOf("null".equals(compound) |
| | | ? flowCard.getTechnologyNumber()//正常层 |
| | | : compound ),//同架层 |
| | | flowCard.getGlassChild(), flowCard.getProcess(), flowCard.getOrderId())); |
| | | if (compound == null |
| | | || "null".equals(compound) |
| | | || compound.trim().isEmpty()){ |
| | | |
| | | List<Map<String, Object>> detailList = flowCardMapper.getDetailListLike(flowCard.getProcessId(), String.valueOf(flowCard.getTechnologyNumber()), flowCard.getProcess()); |
| | | itemmap.put("detailList", detailList); |
| | | 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(), 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()); |
| | | 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()); |
| | | itemmap.put("detailList", detailList); |
| | | } |
| | | } |
| | | |
| | | //工艺流程 |
| | |
| | | return map; |
| | | } |
| | | |
| | | public Map<String, Object> getSelectPrintProject(String printProject, String merge) { |
| | | public Map<String, Object> getSelectPrintProject(String printProject, String merge, String flashback, String landingSequence) { |
| | | |
| | | Map<String, Object> map = new HashMap<>(); |
| | | List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();//最终结果 |
| | |
| | | } |
| | | List<FlowCard> flowCardList = flowCardMapper.getFlowCardListPrintProject(printProject); |
| | | if (!flowCardList.isEmpty()) { |
| | | Set<String> processedProcessIds = new HashSet<>(); // 用来存放已处理过的 processId |
| | | Set<String> processedKeys = new HashSet<>(); |
| | | |
| | | for (FlowCard flowCard : flowCardList) { |
| | | Map<String, Object> itemmap = new HashMap<>(); |
| | | |
| | | |
| | | String processId = flowCard.getProcessId(); |
| | | Integer orderNumber = flowCard.getOrderNumber(); |
| | | String uniqueKey = processId + "|" + orderNumber; // 用特殊字符连接防止冲突 |
| | | //是否包含切割 |
| | | //boolean containsCutting = flowCard.getProcess().contains("切割"); |
| | | String processSub = flowCard.getProcess().substring(0, 2); |
| | | if (processSub.equals("夹胶") || processSub.equals("中空")) { |
| | | //获取工序对应的别称 |
| | | String processName = flowCardMapper.getProcessName(processSub); |
| | | if (processName.equals("stepC") || processName.equals("stepD")) {//工艺是否包含夹胶中空 |
| | | itemmap.put("detail", flowCardMapper.getPrimaryListLimt(flowCard.getProcessId(), String.valueOf(flowCard.getTechnologyNumber()), flowCard.getGlassChild(), flowCard.getProcess(), flowCard.getOrderId())); |
| | | if (flowCard.getPatchState().equals(0)) { |
| | | List<Map<String, Object>> detailList = flowCardMapper.getDetailList(flowCard.getProcessId(), flowCard.getTechnologyNumber(), flowCard.getProcess()); |
| | | List<Map<String, Object>> detailList = flowCardMapper.getDetailList(flowCard.getProcessId(), flowCard.getTechnologyNumber(), flowCard.getProcess(), flashback, landingSequence); |
| | | itemmap.put("detailList", detailList); |
| | | } else { |
| | | List<Map<String, Object>> detailList = flowCardMapper.getDetailLists(flowCard.getProcessId(), flowCard.getTechnologyNumber(), flowCard.getProcess(), flowCard.getOrderNumber()); |
| | |
| | | if (flowCard.getPatchState().equals(0)) { |
| | | if (merge.equals("1") && flowCard.getMerge().equals(1)) { |
| | | // 检查是否已经处理过该 processId,如果处理过则跳过 |
| | | if (processedProcessIds.contains(flowCard.getProcessId())) { |
| | | if (processedKeys.contains(uniqueKey)) { |
| | | continue; |
| | | } |
| | | // 将该 processId 加入已处理集合 |
| | | processedProcessIds.add(flowCard.getProcessId()); |
| | | processedKeys.add(uniqueKey); |
| | | itemmap.put("detail", flowCardMapper.getPrimaryList(flowCard.getProcessId(), String.valueOf(flowCard.getTechnologyNumber()), flowCard.getGlassChild(), flowCard.getProcess(), flowCard.getOrderId())); |
| | | |
| | | List<Map<String, Object>> detailList = flowCardMapper.getDetailListMerge(flowCard.getProcessId(), flowCard.getProcess()); |
| | | List<Map<String, Object>> detailList = flowCardMapper.getDetailListMerge(flowCard.getProcessId(), 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(), String.valueOf(flowCard.getTechnologyNumber()), flowCard.getProcess()); |
| | | List<Map<String, Object>> detailList = flowCardMapper.getDetailListLike(flowCard.getProcessId(), String.valueOf(flowCard.getTechnologyNumber()), flowCard.getProcess(), flashback, landingSequence); |
| | | itemmap.put("detailList", detailList); |
| | | } |
| | | |
| | |
| | | List<FlowCard> flowCardList = JSONArray.parseArray(JSONObject.toJSONString(object.get("composing")), FlowCard.class); |
| | | if (!flowCardList.isEmpty()) { |
| | | for (FlowCard flowCard : flowCardList) { |
| | | flowCardMapper.updateComposing(flowCard.getProcessId()); |
| | | //先获取排版状态 |
| | | Integer layoutStatus = flowCardMapper.getLayoutStatus(flowCard.getProcessId()); |
| | | //2优化占用 |
| | | if (layoutStatus!=2){ |
| | | flowCardMapper.updateComposing(flowCard.getProcessId()); |
| | | } |
| | | else { |
| | | return false; |
| | | } |
| | | |
| | | } |
| | | //保存日志 |
| | | Log log = new Log(); |
| | | log.setContent(object.toString()); |
| | | log.setFunction("FlowCardSv流程卡排版状态"); |
| | | log.setOperatorId((String) object.get("userId")); |
| | | log.setOperator((String) object.get("userName")); |
| | | logService.saveLog(log); |
| | | return true; |
| | | } else { |
| | | return false; |
| | |
| | | |
| | | |
| | | public Map<String, Object> getSelectPrintCustomLabelSv(String type, Integer lableType, Map<String, Object> object) { |
| | | //根据mse传过来的值,如果不存在 赋值false |
| | | String isRepeat = Optional.ofNullable(object.get("isRepeat")) |
| | | .map(Object::toString) |
| | | .orElse("false"); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();//最终结果 |
| | | List<FlowCard> flowCardList = JSONArray.parseArray(JSONObject.toJSONString(object.get("printList")), FlowCard.class); |
| | | if (!flowCardList.isEmpty()) { |
| | | Set<String> processedProcessIds = new HashSet<>(); // 用来存放已处理过的 processId |
| | | |
| | | Set<String> processedKeys = new HashSet<>(); |
| | | if (lableType != 2) {//成品标签 |
| | | for (FlowCard flowCard : flowCardList) { |
| | | String processId = flowCard.getProcessId(); |
| | | |
| | | // 检查是否已经处理过该 processId,如果处理过则跳过 |
| | | if (processedProcessIds.contains(processId)) { |
| | | continue; |
| | | Integer orderNumber = flowCard.getOrderNumber(); |
| | | String uniqueKey = processId + "|" + orderNumber; // 用特殊字符连接防止冲突 |
| | | if (isRepeat=="false"){//根据mse传过来的值判断是否去除重复 |
| | | // 检查是否已经处理过该 processId,如果处理过则跳过 |
| | | if (processedKeys.contains(uniqueKey)) { |
| | | continue; |
| | | } |
| | | } |
| | | Map<String, Object> itemmap = new HashMap<>(); |
| | | itemmap.put("data", flowCardMapper.getPrintCustomData(flowCard.getProcessId(), flowCard.getOrderNumber())); |
| | | list.add(itemmap); |
| | | |
| | | Map<String, Object> itemmap = new HashMap<>(); |
| | | |
| | | Integer sumQuantity = flowCardMapper.getSumQuantity(flowCard.getOrderId()); |
| | | List<Map<String, Object>> details = flowCardMapper.getPrintCustomData(flowCard.getProcessId(), flowCard.getOrderNumber(), flowCard.getPrintQuantity()); |
| | | |
| | | for (Map<String, Object> detail : details) { |
| | | detail.put("sumQuantity", sumQuantity); |
| | | } |
| | | |
| | | itemmap.put("data", details); |
| | | list.add(itemmap); |
| | | // 将该 processId 加入已处理集合 |
| | | processedProcessIds.add(processId); |
| | | processedKeys.add(uniqueKey); |
| | | } |
| | | } else {//小片标签 |
| | | for (FlowCard flowCard : flowCardList) { |
| | | Map<String, Object> itemmap = new HashMap<>(); |
| | | itemmap.put("data", flowCardMapper.getPrintCustomDataSemi(flowCard.getProcessId(), flowCard.getTechnologyNumber(), flowCard.getProcess())); |
| | | String orderNumber = ""; |
| | | if (flowCard.getOrderNumber() != null) { |
| | | orderNumber = String.valueOf(flowCard.getOrderNumber()); |
| | | } |
| | | // 判断是否为非空字符串 |
| | | if (orderNumber != null && !orderNumber.trim().isEmpty()) { |
| | | |
| | | List<Map<String, Object>> customDataSemi =flowCardMapper.getPrintCustomDataSemi( |
| | | flowCard.getProcessId(), |
| | | flowCard.getTechnologyNumber(), |
| | | flowCard.getProcess(), |
| | | 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( |
| | | flowCard.getProcessId(), |
| | | flowCard.getTechnologyNumber(), |
| | | flowCard.getProcess(), flowCard.getPrintQuantity() |
| | | )); |
| | | } |
| | | list.add(itemmap); |
| | | } |
| | | } |
| | |
| | | List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();//最终结果 |
| | | List<FlowCard> flowCardList = JSONArray.parseArray(JSONObject.toJSONString(object.get("printList")), FlowCard.class); |
| | | if (!flowCardList.isEmpty()) { |
| | | Set<String> processedProcessIds = new HashSet<>(); // 用来存放已处理过的 processId |
| | | |
| | | Set<String> processedKeys = new HashSet<>(); |
| | | if (lableType != 2) {//成品标签 |
| | | for (FlowCard flowCard : flowCardList) { |
| | | String processId = flowCard.getProcessId(); |
| | | Integer orderNumber = flowCard.getOrderNumber(); |
| | | String uniqueKey = processId + "|" + orderNumber; // 用特殊字符连接防止冲突 |
| | | |
| | | // 检查是否已经处理过该 processId,如果处理过则跳过 |
| | | if (processedProcessIds.contains(processId)) { |
| | | if (processedKeys.contains(uniqueKey)) { |
| | | continue; |
| | | } |
| | | Map<String, Object> itemmap = new HashMap<>(); |
| | |
| | | list.add(itemmap); |
| | | |
| | | // 将该 processId 加入已处理集合 |
| | | processedProcessIds.add(processId); |
| | | processedKeys.add(uniqueKey); |
| | | } |
| | | } else {//小片标签 |
| | | for (FlowCard flowCard : flowCardList) { |
| | | Map<String, Object> itemmap = new HashMap<>(); |
| | | itemmap.put("data", flowCardMapper.getPrintCustomDataSemi(flowCard.getProcessId(), flowCard.getTechnologyNumber(), flowCard.getProcess())); |
| | | itemmap.put("data", flowCardMapper.getPrintCustomDataSemi(flowCard.getProcessId(), flowCard.getTechnologyNumber(), flowCard.getProcess(), flowCard.getOrderNumber(), flowCard.getPrintQuantity())); |
| | | list.add(itemmap); |
| | | } |
| | | } |
| | |
| | | |
| | | //工艺流程 |
| | | List<Map<String, Object>> processList = flowCardMapper.getProcessList(flowCard.getProcessId(), flowCard.getTechnologyNumber()); |
| | | |
| | | //工序列表 |
| | | List<Map<String, Object>> processNameList = flowCardMapper.getProcessNameList(); |
| | | itemmap.put("processList", processList); |
| | | itemmap.put("processNameList", processNameList); |
| | | // itemmap.put("numberList", numberList); |
| | | list.add(itemmap); |
| | | |
| | |
| | | } |
| | | } |
| | | map.put("data", list); |
| | | map.put("orderOtherMoney", flowCardMapper.selectorderOtherMoney()); |
| | | map.put("type", flowCardMapper.selectType()); |
| | | return map; |
| | | } |
| | | |
| | | public Map<String, Object> getSelectPrintCustomLabelDetailsSv(String type, Integer lableType, Map<String, Object> object) { |
| | | String landingSequence = ""; |
| | | if (object.get("landingSequence") != null) { |
| | | landingSequence = object.get("landingSequence").toString(); |
| | | } |
| | | Map<String, Object> map = new HashMap<>(); |
| | | List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();//最终结果 |
| | | List<FlowCard> flowCardList = JSONArray.parseArray(JSONObject.toJSONString(object.get("printList")), FlowCard.class); |
| | | if (!flowCardList.isEmpty()) { |
| | | Set<String> processedProcessIds = new HashSet<>(); // 用来存放已处理过的 processId |
| | | Set<String> processedKeys = new HashSet<>(); |
| | | |
| | | if (lableType != 2) {//成品标签 |
| | | for (FlowCard flowCard : flowCardList) { |
| | | String orderId = flowCard.getOrderId(); |
| | | String processId = flowCard.getProcessId(); |
| | | String orderNumber = flowCard.getOrderNumber().toString(); |
| | | String uniqueKey = processId + "|" + orderNumber; // 用特殊字符连接防止冲突 |
| | | if (processId!=null){ |
| | | // 检查是否已经处理过该 processId,如果处理过则跳过 |
| | | if (processedProcessIds.contains(processId) && processedProcessIds.contains(orderNumber)) { |
| | | if (processedKeys.contains(uniqueKey)) { |
| | | continue; |
| | | } |
| | | Map<String, Object> itemmap = new HashMap<>(); |
| | | itemmap.put("data", flowCardMapper.getPrintCustomDataDetails(flowCard.getProcessId(), flowCard.getOrderNumber(), flowCard.getPrintQuantity())); |
| | | Integer sumQuantity = flowCardMapper.getSumQuantity(flowCard.getOrderId()); |
| | | List<Map<String, Object>> details = flowCardMapper.getPrintCustomDataDetails(flowCard.getProcessId(), flowCard.getOrderNumber(), flowCard.getPrintQuantity()); |
| | | |
| | | for (Map<String, Object> detail : details) { |
| | | detail.put("sumQuantity", sumQuantity); |
| | | } |
| | | itemmap.put("data", details); |
| | | list.add(itemmap); |
| | | |
| | | // 将该 processId 加入已处理集合 |
| | | processedProcessIds.add(processId); |
| | | processedProcessIds.add(orderNumber); |
| | | processedKeys.add(uniqueKey); |
| | | } else{ |
| | | |
| | | Map<String, Object> itemmap = new HashMap<>(); |
| | |
| | | } else {//小片标签 |
| | | for (FlowCard flowCard : flowCardList) { |
| | | Map<String, Object> itemmap = new HashMap<>(); |
| | | itemmap.put("data", flowCardMapper.getPrintCustomDataSemi(flowCard.getProcessId(), flowCard.getTechnologyNumber(), flowCard.getProcess())); |
| | | itemmap.put("data", flowCardMapper.getPrintCustomDataSemi(flowCard.getProcessId(), flowCard.getTechnologyNumber(), flowCard.getProcess(), flowCard.getOrderNumber(), flowCard.getPrintQuantity())); |
| | | list.add(itemmap); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (!"1".equals(landingSequence)) { |
| | | // 构造一个先按短边、再按长边的比较器 |
| | | Comparator<Map<String,Object>> comparator = Comparator |
| | | .comparingDouble((Map<String,Object> m) -> { |
| | | Map<String,Object> first = ((List<Map<String,Object>>)m.get("data")).get(0); |
| | | double w = ((Number) first.get("width")).doubleValue(); |
| | | double h = ((Number) first.get("height")).doubleValue(); |
| | | return Math.min(w, h); |
| | | }) |
| | | .thenComparingDouble(m -> { |
| | | Map<String,Object> first = ((List<Map<String,Object>>)m.get("data")).get(0); |
| | | double w = ((Number) first.get("width")).doubleValue(); |
| | | double h = ((Number) first.get("height")).doubleValue(); |
| | | return Math.max(w, h); |
| | | }); |
| | | |
| | | // 对整个 list 排序,并整体反转,短边大→前,短边相同时长边大→前 |
| | | list.sort(comparator.reversed()); |
| | | } |
| | | map.put("data", list); |
| | | map.put("title", flowCardMapper.getPrintTitle(type)); |
| | |
| | | |
| | | } |
| | | |
| | | public String mergeFlowCard(Map<String, Object> object) { |
| | | public String mergeFlowCard(Map<String, Object> object, Integer merge) { |
| | | String returns = "false"; |
| | | List<FlowCard> flowCardList = JSONArray.parseArray(JSONObject.toJSONString(object.get("flowCard")), FlowCard.class); |
| | | if (!flowCardList.isEmpty()) { |
| | | List<Map<String, Object>> flowCardList1 = flowCardMapper.selectFlowCardMerge(flowCardList.get(0).getProcessId()); |
| | | int index = 1; |
| | | for (int i = 0; i < flowCardList1.size(); i++) { |
| | | if (Integer.valueOf(flowCardList1.get(i).get("count2").toString()) > 1) { |
| | | List<Integer> technologyNumber = Arrays.stream(flowCardList1.get(i).get("count1").toString().split(",")) |
| | | .map(Integer::parseInt) |
| | | .collect(Collectors.toList()); |
| | | flowCardMapper.updateFlowCardMerge(flowCardList.get(0).getProcessId(), technologyNumber, index); |
| | | index += 1; |
| | | returns = "true"; |
| | | if (merge == 0){ |
| | | int index = 1; |
| | | for (int i = 0; i < flowCardList1.size(); i++) { |
| | | if (Integer.valueOf(flowCardList1.get(i).get("count2").toString()) > 1) { |
| | | List<Integer> technologyNumber = Arrays.stream(flowCardList1.get(i).get("count1").toString().split(",")) |
| | | .map(Integer::parseInt) |
| | | .collect(Collectors.toList()); |
| | | flowCardMapper.updateFlowCardMerge(flowCardList.get(0).getProcessId(), technologyNumber, index); |
| | | index += 1; |
| | | returns = "true"; |
| | | } |
| | | } |
| | | }else {//取消合并 |
| | | flowCardMapper.updateFlowCardIsMerge(flowCardList.get(0).getProcessId()); |
| | | returns = "true"; |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | String[] processCardList = processCard.split("/"); |
| | | List<String> result = IntStream.range(0, processCardList[1].length()) |
| | | .mapToObj(i -> String.valueOf(processCardList[1].charAt(i))) |
| | | .collect(Collectors.toList()); |
| | | |
| | | List<FlowCard> flowCardList = flowCardMapper.selectList( |
| | | new QueryWrapper<FlowCard>() |
| | | .eq("process_id", processCardList[0]) |
| | | .eq("technology_number", processCardList[1]) |
| | | .in("technology_number", result) |
| | | ); |
| | | for (FlowCard flowCard : flowCardList) { |
| | | flowCard.setOrderGlassDetail( |
| | |
| | | } |
| | | return flowCardList; |
| | | } |
| | | |
| | | public Map<String,Object> getProcessCardAll(Map<String, String> processCards) { |
| | | String processCard = processCards.get("processCard"); |
| | | if (!processCard.contains("/")) { |
| | | throw new ServiceException(Constants.Code_600, "错误的流程卡号,请检查!"); |
| | | } |
| | | |
| | | String[] processCardList = processCard.split("/"); |
| | | List<String> result = IntStream.range(0, processCardList[1].length()) |
| | | .mapToObj(i -> String.valueOf(processCardList[1].charAt(i))) |
| | | .collect(Collectors.toList()); |
| | | |
| | | List<FlowCard> flowCardList = flowCardMapper.selectList( |
| | | new QueryWrapper<FlowCard>() |
| | | .eq("process_id", processCardList[0]) |
| | | .in("technology_number", result) |
| | | ); |
| | | for (FlowCard flowCard : flowCardList) { |
| | | flowCard.setOrderGlassDetail( |
| | | orderGlassDetailMapper.selectOne( |
| | | new QueryWrapper<OrderGlassDetail>() |
| | | .eq("order_id", flowCard.getOrderId()) |
| | | .eq("order_number", flowCard.getOrderNumber()) |
| | | .eq("technology_number", flowCard.getTechnologyNumber()) |
| | | ) |
| | | ); |
| | | String str = flowCard.getOrderGlassDetail().getGlassChild(); |
| | | String delimiter = "mm"; |
| | | int index = str.indexOf(delimiter); |
| | | Integer subString = Integer.valueOf(str.substring(0, index).trim()); |
| | | flowCard.getOrderGlassDetail().setThickness(subString); |
| | | } |
| | | OrderDetail orderDetail = orderDetailMapper |
| | | .selectOne(new QueryWrapper<OrderDetail>() |
| | | .eq("order_id", flowCardList.get(0).getOrderId()) |
| | | .eq("order_number", flowCardList.get(0).getOrderNumber()) |
| | | ); |
| | | Product product = productMapper |
| | | .selectOne(new QueryWrapper<Product>() |
| | | .eq("id",orderDetail.getProductId())); |
| | | product.setProductDetails(productDetailMapper |
| | | .selectList(new QueryWrapper<ProductDetail>() |
| | | .eq("prod_id",orderDetail.getProductId()) |
| | | ) |
| | | ); |
| | | |
| | | Order order = orderMapper. |
| | | selectOne(new QueryWrapper<Order>() |
| | | .eq("order_id", flowCardList.get(0).getOrderId())); |
| | | order.setMoney(null); |
| | | |
| | | Map<String,Object> map = new HashMap<>(); |
| | | map.put("product",product); |
| | | map.put("flowCard",flowCardList); |
| | | map.put("order",order); |
| | | |
| | | |
| | | return map; |
| | | } |
| | | |
| | | |
| | | public Boolean checkboxDeleteSv(Map<String, Object> object) { |
| | | String userName = ""; |
| | |
| | | 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>>();//最终结果 |
| | | List<FlowCard> flowCardList = JSONArray.parseArray(JSONObject.toJSONString(object.get("printList")), FlowCard.class); |
| | | if (!flowCardList.isEmpty()) { |
| | | Set<String> processedProcessIds = new HashSet<>(); // 用来存放已处理过的 processId |
| | | for (FlowCard flowCard : flowCardList) { |
| | | Map<String, Object> itemmap = new HashMap<>(); |
| | | //是否是工程明细打印 |
| | | if (detailType == 0) {//工程打印明细 |
| | | itemmap.put("data", flowCardMapper.getPrintCustomDataProjectDetail(flowCard.getProjectNo(), flowCard.getStockId())); |
| | | itemmap.put("data", flowCardMapper.getPrintCustomDataProjectDetail(flowCard.getProjectNo(), flowCard.getStockId(),flowCard.getPolysId())); |
| | | |
| | | |
| | | } |
| | | //非工程打印 |
| | |
| | | return map; |
| | | } |
| | | |
| | | public Boolean updateProcessSv(String processId, String technologyNumber, String orderId, String Orderprocess, Map<String, Object> object) { |
| | | public Boolean updateProcessSv(String processId,String orderNumber, String technologyNumber, String orderId, String Orderprocess, Map<String, Object> object) { |
| | | List<OrderProcessDetail> resultList = new ArrayList<>(); |
| | | //获取已报工工艺流程 |
| | | String processOk = flowCardMapper.getProcessOk(processId,orderNumber,technologyNumber); |
| | | if (processOk != null && !processOk.isEmpty()){ |
| | | List<String> okList = Arrays.asList(processOk.split("->")); |
| | | List<String> orderList = Arrays.asList(Orderprocess.split("->")); |
| | | |
| | | //判断该流程卡是否报工 |
| | | Integer count = flowCardMapper.reportingWorkCount(processId); |
| | | if (count == 0) { |
| | | // 判断 processOk 的每个工序是否都包含在 orderProcess 中 |
| | | for (String p : okList) { |
| | | if (!orderList.contains(p)) { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | for (String process : okList) { |
| | | List<OrderProcessDetail> details = |
| | | flowCardMapper.getProcessDetail(processId,orderNumber, technologyNumber, process); |
| | | |
| | | if (details != null && !details.isEmpty()) { |
| | | resultList.addAll(details); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //删除小片工艺表对应的数据 |
| | | flowCardMapper.deleteProcessMp(processId, technologyNumber); |
| | | //重新插入修改好工艺流程卡的数据 |
| | |
| | | } |
| | | } |
| | | } |
| | | //将原来已报工的数据更新 |
| | | if (resultList != null && !resultList.isEmpty()) { |
| | | 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; |
| | | } else { |
| | | return false; |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | |
| | | Float glassThickness = Float.parseFloat(thickness.get("thickness").toString()); |
| | | |
| | | //获取此工程号订单明细信息 |
| | | List<OrderDetail> orderDetails = flowCardMapper.getOrderDetailByProductionId(orderId, productionId,"scope",inLenMax,inLenMin,inShortMax,inShortMin); |
| | | List<OrderDetail> orderDetailsNotScope = flowCardMapper.getOrderDetailByProductionId(orderId, productionId,"notScope",inLenMax,inLenMin,inShortMax,inShortMin); |
| | | List<OrderDetail> orderDetails = flowCardMapper.getOrderDetailByProductionId(orderId, productionId,"scope",inLenMax,inLenMin,inShortMax,inShortMin,glassThickness); |
| | | List<OrderDetail> orderDetailsNotScope = flowCardMapper.getOrderDetailByProductionId(orderId, productionId,"notScope",inLenMax,inLenMin,inShortMax,inShortMin,glassThickness); |
| | | |
| | | //根据玻璃厚度和垫片厚度当前架子最大可放数量 |
| | | Integer shelfMaxQuantityByThickness = (int) (shelfThickness / (glassTotalThickness + spacerThickness)); |
| | |
| | | shelfQuantity = Math.min(shelfQuantityByWeight, Math.min(inMaxQuantity, shelfMaxQuantityByThickness)); |
| | | flowCardNo += 1; |
| | | } |
| | | System.out.println(orderDetail.getOrderNumber()+":"+shelfQuantity); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | 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()); |
| | |
| | | newOrderDetail.setLandingSequence(flowCardNo); |
| | | orderDetailList.add(newOrderDetail); |
| | | orderDetail.setQuantity(orderDetail.getQuantity() - shelfQuantity); |
| | | orderDetail.setBaiscQuantity(String.valueOf(Integer.valueOf(orderDetail.getBaiscQuantity())-shelfQuantity)); |
| | | flowCardNo += 1; |
| | | 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()); |
| | | newOrderDetail.setOrderNumber(orderDetail.getOrderNumber()); |
| | | newOrderDetail.setShape(orderDetail.getShape()); |
| | | newOrderDetail.setLandingSequence(flowCardNo); |
| | | newOrderDetail.setBaiscQuantity(String.valueOf(orderDetail.getBaiscQuantity())); |
| | | orderDetailList.add(newOrderDetail); |
| | | //当前架子剩余数量 |
| | | shelfQuantity = shelfQuantity - Math.toIntExact(orderDetail.getQuantity()); |
| | |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | public List exportDateProcessSv(Map<String, Object> dates) { |
| | | List<LocalDate> date= (List<LocalDate>) dates.get("date"); |
| | | return flowCardMapper.exportDateProcessMp(date); |
| | | } |
| | | |
| | | public Map<String, Object> selectSortingCardSv(String orderId, String productionId, String flashback, String optionVal, FlowCard flowCard) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("data", flowCardMapper.selectSortingCardMp(orderId, productionId,flashback,optionVal, flowCard)); |
| | | map.put("maxFlowCard", flowCardMapper.selectMaxFlowCard(orderId, productionId)); |
| | | map.put("orderOtherMoney", flowCardMapper.selectorderOtherMoney()); |
| | | return map; |
| | | } |
| | | |
| | | 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) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | String[] processList = process.split("->"); |
| | | //获取工艺流程第一个工序 |
| | | String interceptProcess = processList[0]; |
| | | map.put("data", flowCardMapper.selectCompletedMp(processId, orderNumber,interceptProcess)); |
| | | |
| | | return map; |
| | | } |
| | | |
| | | // public Map<String, Object> getSelectPrintingConsolidatedSv(Map<String, Object> object, String printMerge, String printLike, String mergeTechnologyNumber) { |
| | | // if (printMerge == null) { |
| | | // printMerge = ""; |
| | | // } |
| | | // if (printLike == null) { |
| | | // printLike = ""; |
| | | // } |
| | | // Map<String, Object> map = new HashMap<>(); |
| | | // List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();//最终结果 |
| | | // List<FlowCard> flowCardList = JSONArray.parseArray(JSONObject.toJSONString(object.get("printList")), FlowCard.class); |
| | | // if (!flowCardList.isEmpty()) { |
| | | // Set<String> processedKeys = new HashSet<>(); |
| | | // for (FlowCard flowCard : flowCardList) { |
| | | // String batch = flowCard.getOrder().getBatch(); |
| | | // String glassChild = flowCard.getGlassChild(); |
| | | // Map<String, Object> itemmap = new HashMap<>(); |
| | | // //流程卡表头表尾数据 |
| | | // itemmap.put("detail", flowCardMapper.getPrimaryListRefund(flowCard.getProcessId(), String.valueOf(flowCard.getTechnologyNumber()), flowCard.getOrderNumber(), flowCard.getReportingWorkId(), mergeTechnologyNumber, flowCard.getPatchReason(), flowCard.getOrderId())); |
| | | // |
| | | // List<Map<String, Object>> detailList = flowCardMapper.getDetailListRefund(flowCard.getProcessId(), flowCard.getTechnologyNumber(), flowCard.getOrderNumber(), flowCard.getReportingWorkId(), flowCard.getPatchReason()); |
| | | // itemmap.put("detailList", detailList); |
| | | // //工艺流程 |
| | | // List<Map<String, Object>> processList = flowCardMapper.getProcessList(flowCard.getProcessId(), flowCard.getTechnologyNumber()); |
| | | // //工序列表 |
| | | // List<Map<String, Object>> processNameList = flowCardMapper.getProcessNameList(); |
| | | // itemmap.put("processList", processList); |
| | | // itemmap.put("processNameList", processNameList); |
| | | // // itemmap.put("numberList", numberList); |
| | | // list.add(itemmap); |
| | | // |
| | | // } |
| | | // } |
| | | // map.put("data", list); |
| | | // //初始化值 |
| | | // printLike = null; |
| | | // return map; |
| | | // } |
| | | |
| | | public Map<String, Object> getSelectPrintingConsolidatedSv(Map<String, Object> object, |
| | | String printMerge, |
| | | String printLike, |
| | | String mergeTechnologyNumber) { |
| | | if (printMerge == null) printMerge = ""; |
| | | if (printLike == null) printLike = ""; |
| | | |
| | | Map<String, Object> map = new HashMap<>(); |
| | | List<Map<String, Object>> list = new ArrayList<>(); |
| | | |
| | | List<FlowCard> flowCardList = JSONArray.parseArray( |
| | | JSONObject.toJSONString(object.get("printList")), FlowCard.class); |
| | | |
| | | if (!flowCardList.isEmpty()) { |
| | | // 用 Map 保存每个 key 对应的合并 detailList |
| | | Map<String, List<Map<String, Object>>> keyToDetails = new LinkedHashMap<>(); |
| | | |
| | | // 用 Map 保存每个 key 对应的第一个 flowCard,用于生成 itemmap 表头等信息 |
| | | Map<String, FlowCard> keyToFirstFlowCard = new HashMap<>(); |
| | | |
| | | for (FlowCard flowCard : flowCardList) { |
| | | String batch = flowCard.getBatch(); |
| | | String glassChild = flowCard.getProductName(); |
| | | String key = batch + "_" + glassChild; |
| | | |
| | | List<Map<String, Object>> currentDetailList = flowCardMapper.getDetailListRefund( |
| | | flowCard.getProcessId(), |
| | | flowCard.getTechnologyNumber(), |
| | | flowCard.getOrderNumber(), |
| | | flowCard.getReportingWorkId(), |
| | | flowCard.getPatchReason() |
| | | ); |
| | | |
| | | for (Map<String, Object> detail : currentDetailList) { |
| | | detail.put("processId", flowCard.getProcessId()); |
| | | detail.put("technologyNumber", flowCard.getTechnologyNumber()); |
| | | } |
| | | |
| | | // 合并 detailList 到对应 key |
| | | keyToDetails.computeIfAbsent(key, k -> new ArrayList<>()).addAll(currentDetailList); |
| | | |
| | | // 保存第一次出现的 flowCard,用于生成 itemmap |
| | | keyToFirstFlowCard.putIfAbsent(key, flowCard); |
| | | } |
| | | |
| | | // 遍历合并后的 key,生成 itemmap |
| | | for (Map.Entry<String, List<Map<String, Object>>> entry : keyToDetails.entrySet()) { |
| | | String key = entry.getKey(); |
| | | List<Map<String, Object>> mergedDetailList = entry.getValue(); |
| | | |
| | | FlowCard firstFlowCard = keyToFirstFlowCard.get(key); |
| | | |
| | | Map<String, Object> itemmap = new HashMap<>(); |
| | | itemmap.put("detailList", mergedDetailList); |
| | | |
| | | // 表头表尾 |
| | | itemmap.put("detail", flowCardMapper.getPrimaryListRefundHB( |
| | | firstFlowCard.getProcessId(), |
| | | String.valueOf(firstFlowCard.getTechnologyNumber()), |
| | | firstFlowCard.getOrderNumber(), |
| | | firstFlowCard.getReportingWorkId(), |
| | | mergeTechnologyNumber, |
| | | firstFlowCard.getPatchReason(), |
| | | firstFlowCard.getOrderId() |
| | | )); |
| | | |
| | | // 工艺流程 |
| | | List<Map<String, Object>> processList = flowCardMapper.getProcessList( |
| | | firstFlowCard.getProcessId(), |
| | | firstFlowCard.getTechnologyNumber() |
| | | ); |
| | | |
| | | // 工序列表 |
| | | List<Map<String, Object>> processNameList = flowCardMapper.getProcessNameList(); |
| | | |
| | | itemmap.put("processList", processList); |
| | | itemmap.put("processNameList", processNameList); |
| | | |
| | | list.add(itemmap); |
| | | } |
| | | } |
| | | |
| | | map.put("data", list); |
| | | return map; |
| | | } |
| | | |
| | | |
| | | 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; |
| | | } |
| | | } |
| | | |
| | | |