| | |
| | | |
| | | package com.example.erp.service.pp; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.TypeReference; |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.example.erp.dto.pp.*; |
| | | import com.example.erp.entity.pp.DamageDetails; |
| | | import com.example.erp.entity.pp.Report; |
| | | import com.example.erp.entity.sd.BasicData; |
| | | import com.example.erp.entity.sd.OrderDetail; |
| | |
| | | import com.example.erp.mapper.pp.FlowCardMapper; |
| | | import com.example.erp.mapper.pp.ProductionSchedulingMapper; |
| | | import com.example.erp.mapper.pp.ReportMapper; |
| | | import com.example.erp.mapper.pp.ReportingWorkMapper; |
| | | import com.example.erp.mapper.sd.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.sql.Date; |
| | | import java.time.LocalDate; |
| | | import java.util.*; |
| | | import java.util.concurrent.Executor; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static cn.hutool.core.convert.Convert.toDouble; |
| | | |
| | | @Service |
| | | @DS("pp") |
| | |
| | | private final OrderDetailMapper orderDetailMapper; |
| | | |
| | | FlowCardMapper flowCardMapper; |
| | | private ReportingWorkMapper reportingWorkMapper; |
| | | |
| | | |
| | | //上工序报工班组 |
| | |
| | | .eq("order_number", dto1.getOrderNumber()) |
| | | .eq("technology_number",dto1.getTechnologyNumber()) |
| | | ); |
| | | System.out.println(orderGlassDetailGroup.getGroup()); |
| | | |
| | | String glassName = productDetailMapper.getGlassNameByGroup( |
| | | orderDetail.getProductId(), |
| | |
| | | } |
| | | |
| | | |
| | | public ReportService(ReportMapper reportMapper, OrderProcessDetailMapper orderProcessDetailMapper, ProductionSchedulingMapper productionSchedulingMapper, FlowCardMapper flowCardMapper, OrderGlassDetailMapper orderGlassDetailMapper, BasicDataMapper basicDataMapper, ProductDetailMapper productDetailMapper, OrderDetailMapper orderDetailMapper) { |
| | | public ReportService(ReportMapper reportMapper, OrderProcessDetailMapper orderProcessDetailMapper, |
| | | ProductionSchedulingMapper productionSchedulingMapper, FlowCardMapper flowCardMapper, |
| | | OrderGlassDetailMapper orderGlassDetailMapper, BasicDataMapper basicDataMapper, |
| | | ProductDetailMapper productDetailMapper, OrderDetailMapper orderDetailMapper, |
| | | ReportingWorkMapper reportingWorkMapper) { |
| | | this.reportMapper = reportMapper; |
| | | this.orderProcessDetailMapper = orderProcessDetailMapper; |
| | | this.productionSchedulingMapper = productionSchedulingMapper; |
| | |
| | | this.basicDataMapper = basicDataMapper; |
| | | this.productDetailMapper = productDetailMapper; |
| | | this.orderDetailMapper = orderDetailMapper; |
| | | this.reportingWorkMapper = reportingWorkMapper; |
| | | } |
| | | |
| | | //流程卡进度方法 |
| | | public Map<String, Object> processCardProgressSv(String orderId, List<Integer> columns) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | //获取表格内容数据 |
| | | map.put("data", reportMapper.processCardProgressMp(orderId)); |
| | | List<Map<String, String>> dataList = reportMapper.processCardProgressMp(orderId); |
| | | |
| | | |
| | | //获取表头工序筛选数据 |
| | | List<Map<String, String>> processFilterList = orderProcessDetailMapper.filterOrderProcess(orderId); |
| | |
| | | } |
| | | } |
| | | map.put("title", uniqueList); |
| | | Map<String,Integer> clos = new HashMap<>(); |
| | | for (int i=0;i<uniqueList.size();i++){ |
| | | //根据流程查询基础数据 |
| | | BasicData basicData = basicDataMapper.selectOne( |
| | | new QueryWrapper<BasicData>() |
| | | .eq("basic_category","process") |
| | | .eq("basic_name",uniqueList.get(i).get("process")) |
| | | .last("limit 1") |
| | | ); |
| | | //判断磨边和磨边后工序 |
| | | if(Objects.equals(basicData.getNickname(), "stepA") || Objects.equals(basicData.getNickname(), "stepC")){ |
| | | clos.put(uniqueList.get(i).get("process"), 15+i); |
| | | } |
| | | //判断中空和中空后工序 |
| | | if(Objects.equals(basicData.getNickname(), "stepB") || Objects.equals(basicData.getNickname(), "stepD")){ |
| | | columns.add(15+i); |
| | | } |
| | | } |
| | | |
| | | |
| | | List<Map<String, Integer>> getRowCount = orderProcessDetailMapper.getGlassLRow(orderId); |
| | |
| | | getRowCount.forEach(row -> { |
| | | Map<String, Integer> getRow = new HashMap<>(); |
| | | // { row: 0, col: 1, rowspan: 3, colspan: 0}, |
| | | Object rowNumObj = row.get("RowNum"); |
| | | if (rowNumObj instanceof Double) { |
| | | getRow.put("row", ((Double) rowNumObj).intValue()); |
| | | } else if (rowNumObj instanceof Integer) { |
| | | getRow.put("row", (Integer) rowNumObj); |
| | | } |
| | | getRow.put("row", row.get("RowNum")); |
| | | getRow.put("col", col); |
| | | getRow.put("rowspan", row.get("rowCount")); |
| | | getRow.put("colspan", 0); |
| | | rowCount.add(getRow); |
| | | }); |
| | | }); |
| | | if(!clos.isEmpty()){ |
| | | //循环结果 |
| | | for (int i=0;i<dataList.size();i++ ) { |
| | | Map<String, String> data = JSON.parseObject(dataList.get(i).get("reportWorkQuantity"), |
| | | new TypeReference<Map<String, String>>() { |
| | | }); |
| | | |
| | | for (String key : clos.keySet()) { |
| | | if(data.get(key) != null){ |
| | | Integer max = orderGlassDetailMapper |
| | | .getMaxTechnologyNumberByGroup(dataList.get(i).get("order_id"), |
| | | String.valueOf(dataList.get(i).get("order_number")), |
| | | String.valueOf(dataList.get(i).get("group")) |
| | | ); |
| | | Integer min = orderGlassDetailMapper |
| | | .getMinTechnologyNumberByGroup(dataList.get(i).get("order_id"), |
| | | String.valueOf(dataList.get(i).get("order_number")), |
| | | String.valueOf(dataList.get(i).get("group")) |
| | | ); |
| | | if(min == Integer.parseInt(String.valueOf(dataList.get(i).get("technology_number"))) ){ |
| | | Map<String, Integer> getRow = new HashMap<>(); |
| | | // { row: 0, col: 1, rowspan: 3, colspan: 0}, |
| | | getRow.put("row", i ); |
| | | getRow.put("col", clos.get(key)); |
| | | getRow.put("rowspan", max-min+1); |
| | | getRow.put("colspan", 0); |
| | | rowCount.add(getRow); |
| | | }else{ |
| | | data.put(key,"0"); |
| | | } |
| | | |
| | | } |
| | | } |
| | | dataList.get(i).put("reportWorkQuantity",JSON.toJSONString(data)); |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | map.put("data",dataList ); |
| | | map.put("mergeCells", rowCount); |
| | | |
| | | return map; |
| | |
| | | if (selectProcesses.equals("全部")){ |
| | | selectProcesses=""; |
| | | } |
| | | String laminating = reportMapper.getLaminating(selectProcesses); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | List<WorkInProgressDTO> dataList2 =reportMapper.workInProgressMpdataList2(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO); |
| | | if (optionVal.equals("1")){ |
| | | System.out.println(1); |
| | | /* 根据销售单号汇总*/ |
| | | //map.put("data", reportMapper.workInProgressOrderMp(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO)); |
| | | List<WorkInProgressDTO> dataList1 =reportMapper.workInProgressOrderMpList1(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO); |
| | |
| | | // map.put("total", reportMapper.workInProgressOrderTotal(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO)); |
| | | map.put("total" ,reportMapper.workInProgressOrderFootSum(offset, pageSize,orderId, inputProject, selectProcesses, workInProgressDTO)); |
| | | }else if(optionVal.equals("2")){ |
| | | System.out.println(2); |
| | | /* 根据流程卡号汇总*/ |
| | | //map.put("data", reportMapper.workInProgressProcessMp(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO)); |
| | | List<WorkInProgressDTO> dataList1 =reportMapper.workInProgressProcessMpList1(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO); |
| | |
| | | } else { |
| | | //没有选择分组 |
| | | //map.put("data", reportMapper.workInProgressMp(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO)); |
| | | List<WorkInProgressDTO> dataList1 =reportMapper.workInProgressMpdataList1(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO); |
| | | List<WorkInProgressDTO> dataList1 =reportMapper.workInProgressMpdataList1(offset, pageSize, orderId, inputProject, selectProcesses,laminating, workInProgressDTO); |
| | | mergeTeamsGroupsName(dataList1, dataList2); |
| | | map.put("data",dataList1); |
| | | //map.put("total", reportMapper.workInProgressTotal(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO)); |
| | |
| | | return map; |
| | | } |
| | | |
| | | public Map<String, Object> selectDamageReportSv(Integer pageNum, Integer pageSize, Date selectTime1, Date selectTime2, DamageReportDTO damageReportDTO) { |
| | | public Map<String, Object> selectDamageReportSv(Integer pageNum, Integer pageSize, String selectTime1, String selectTime2, DamageReportDTO damageReportDTO) { |
| | | Integer offset = (pageNum - 1) * pageSize; |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("data", reportMapper.selectDamageReportMp(offset, pageSize, selectTime1, selectTime2, damageReportDTO)); |
| | |
| | | return map; |
| | | } |
| | | |
| | | public Map<String, Object> taskCompletionStatusSv(Date selectTime1, Date selectTime2, List<Integer> columns) { |
| | | public Map<String, Object> taskCompletionStatusSv(Date selectTime1, Date selectTime2, String orderId, List<Integer> columns) { |
| | | if ("null".equals(orderId)) { |
| | | orderId = ""; |
| | | } |
| | | Map<String, Object> map = new HashMap<>(); |
| | | //获取表格内容数据 |
| | | map.put("data", reportMapper.taskCompletionStatusMp(selectTime1, selectTime2)); |
| | | map.put("data", reportMapper.taskCompletionStatusMp(selectTime1, selectTime2,orderId)); |
| | | |
| | | //获取表头工序筛选数据 |
| | | List<Map<String, String>> processFilterList = orderProcessDetailMapper.filterOrderProcessCollect(selectTime1, selectTime2); |
| | | List<Map<String, String>> processFilterList = orderProcessDetailMapper.filterOrderProcessCollect(selectTime1, selectTime2,orderId); |
| | | List<Map<String, String>> processList = processFilterList; |
| | | |
| | | List<String> filterList = new ArrayList<>(); |
| | |
| | | } |
| | | map.put("title", uniqueList); |
| | | |
| | | |
| | | List<Map<String, Integer>> getRowCount = orderProcessDetailMapper.getGlassLRowCollect(selectTime1, selectTime2); |
| | | List<Map<String, Integer>> getRowCount = orderProcessDetailMapper.getGlassLRowCollect(selectTime1, selectTime2,orderId); |
| | | List<Map<String, Integer>> rowCount = new ArrayList<>(); |
| | | columns.forEach(col -> { |
| | | getRowCount.forEach(row -> { |
| | | Map<String, Integer> getRow = new HashMap<>(); |
| | | // { row: 0, col: 1, rowspan: 3, colspan: 0}, |
| | | getRow.put("row", row.get("RowNum")); |
| | | Object rowNumObj = row.get("RowNum"); |
| | | if (rowNumObj instanceof Double) { |
| | | getRow.put("row", ((Double) rowNumObj).intValue()); |
| | | } else if (rowNumObj instanceof Integer) { |
| | | getRow.put("row", (Integer) rowNumObj); |
| | | } |
| | | getRow.put("col", col); |
| | | getRow.put("rowspan", row.get("rowCount")); |
| | | getRow.put("colspan", 0); |
| | | rowCount.add(getRow); |
| | | }); |
| | | }); |
| | | |
| | | |
| | | map.put("mergeCells", rowCount); |
| | | |
| | | return map; |
| | |
| | | return reportMapper.exportCrossProcessBreakingMp(dates); |
| | | } |
| | | |
| | | public List exportDamageReportSv(List<LocalDate> dates) { |
| | | if (dates != null && dates.size() > 1) { |
| | | dates.set(1, dates.get(1).plusDays(1)); // 将第二个日期加一天 |
| | | } |
| | | return reportMapper.exportDamageReportMp(dates); |
| | | // public List exportTeamOutputSv(Map<String, Object> dates) { |
| | | // List<LocalDate> date= (List<LocalDate>) dates.get("date"); |
| | | // String process= (String) dates.get("processes"); |
| | | // if (process.equals("全部")){ |
| | | // process=""; |
| | | // } |
| | | // String laminating = reportMapper.getLaminating(process); |
| | | // return reportMapper.exportTeamOutputMp(date,process,laminating); |
| | | // } |
| | | public List exportDamageReportSv(Map<String, Object> dates) { |
| | | List<LocalDate> date= (List<LocalDate>) dates.get("date"); |
| | | return reportMapper.exportDamageReportMp(date); |
| | | } |
| | | |
| | | public List exportOrderPlanDecompositionSv(List<LocalDate> dates) { |
| | |
| | | return reportMapper.exportYieldMp(date,process); |
| | | } |
| | | |
| | | public Map<String, Object> teamOutputSv(Integer pageNum, Integer pageSize, Date selectTime1, Date selectTime2, String selectProcesses, TeamOutputDTO teamOutputDTO) { |
| | | public Map<String, Object> teamOutputSv(Integer pageNum, Integer pageSize, String selectTime1, String selectTime2, String selectProcesses, TeamOutputDTO teamOutputDTO) { |
| | | if (selectProcesses.equals("全部")){ |
| | | selectProcesses=""; |
| | | } |
| | |
| | | String laminating = reportMapper.getLaminating(process); |
| | | return reportMapper.exportTeamOutputMp(date,process,laminating); |
| | | } |
| | | |
| | | public Map<String, Object> workInProgressCombinationSv( |
| | | Integer pageNum, Integer pageSize, |
| | | String orderId, String inputProject, String selectProcesses, |
| | | String optionVal, WorkInProgressDTO workInProgressDTO) { |
| | | |
| | | Integer offset = (pageNum - 1) * pageSize; |
| | | |
| | | if ("null".equals(orderId)) { |
| | | orderId = ""; |
| | | } |
| | | if ("null".equals(inputProject)) { |
| | | inputProject = ""; |
| | | } |
| | | if ("null".equals(optionVal)) { |
| | | optionVal = ""; |
| | | } |
| | | if ("全部".equals(selectProcesses)) { |
| | | selectProcesses = ""; |
| | | } |
| | | |
| | | String laminating = ""; |
| | | Map<String, Object> map = new HashMap<>(); |
| | | Map<String, Double> totalSumMap = new HashMap<>(); |
| | | |
| | | double totalStockNum = 0; |
| | | double totalStockArea = 0; |
| | | |
| | | // 获取所有工序 |
| | | List<String> processList = reportMapper.selectProcess(); |
| | | |
| | | // 最终数据集合 |
| | | List<Map<String, Object>> resultList = new ArrayList<>(); |
| | | |
| | | if (!"".equals(selectProcesses)) { |
| | | laminating = reportingWorkMapper.getProcessLaminating(selectProcesses); |
| | | List<Map<String, Object>> singleResult = |
| | | reportMapper.getWorkInProgressCombination(selectProcesses, laminating, optionVal); |
| | | if (singleResult != null && !singleResult.isEmpty()) { |
| | | resultList.addAll(singleResult); |
| | | } |
| | | |
| | | Map<String, Object> total = |
| | | reportMapper.getWorkInProgressCombinationFootSum(selectProcesses, laminating, optionVal); |
| | | if (total != null) { |
| | | BigDecimal stockNum = (BigDecimal) total.get("stockNum"); |
| | | BigDecimal stockArea = (BigDecimal) total.get("stockArea"); |
| | | |
| | | if (stockNum != null) { |
| | | totalStockNum += stockNum.doubleValue(); |
| | | } |
| | | if (stockArea != null) { |
| | | totalStockArea += stockArea.doubleValue(); |
| | | } |
| | | } |
| | | |
| | | } else { |
| | | for (String process : processList) { |
| | | laminating = reportingWorkMapper.getProcessLaminating(process); |
| | | |
| | | List<Map<String, Object>> singleResult = |
| | | reportMapper.getWorkInProgressCombination(process, laminating, optionVal); |
| | | |
| | | if (singleResult != null && !singleResult.isEmpty()) { |
| | | resultList.addAll(singleResult); |
| | | } |
| | | |
| | | Map<String, Object> total = |
| | | reportMapper.getWorkInProgressCombinationFootSum(process, laminating, optionVal); |
| | | if (total != null) { |
| | | BigDecimal stockNum = (BigDecimal) total.get("stockNum"); |
| | | BigDecimal stockArea = (BigDecimal) total.get("stockArea"); |
| | | |
| | | if (stockNum != null) { |
| | | totalStockNum += stockNum.doubleValue(); |
| | | } |
| | | if (stockArea != null) { |
| | | totalStockArea += stockArea.doubleValue(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | totalSumMap.put("stockNum", totalStockNum); |
| | | totalSumMap.put("stockArea", totalStockArea); |
| | | |
| | | map.put("data", resultList); |
| | | map.put("total", totalSumMap); |
| | | map.put("process", productionSchedulingMapper.selectProcess()); |
| | | |
| | | return map; |
| | | } |
| | | |
| | | public List exportWorkInProgressCombinationSv(Map<String, Object> dates) { |
| | | String process= (String) dates.get("processes"); |
| | | if (process.equals("全部")){ |
| | | process=""; |
| | | } |
| | | String inputVal= (String) dates.get("inputVal"); |
| | | String project= (String) dates.get("project"); |
| | | if ("null".equals(inputVal)) { |
| | | inputVal = ""; |
| | | } |
| | | if ("null".equals(project)) { |
| | | project = ""; |
| | | } |
| | | |
| | | String laminating = ""; |
| | | |
| | | // 获取所有工序 |
| | | List<String> processList = reportMapper.selectProcess(); |
| | | |
| | | // 最终数据集合 |
| | | List<WorkInProgressCombinationDTO> resultList = new ArrayList<>(); |
| | | |
| | | if (!"".equals(process)) { |
| | | laminating = reportingWorkMapper.getProcessLaminating(process); |
| | | List<WorkInProgressCombinationDTO> singleResult = |
| | | reportMapper.exportWorkInProgressCombination(process, laminating, inputVal); |
| | | if (singleResult != null && !singleResult.isEmpty()) { |
| | | resultList.addAll((Collection<? extends WorkInProgressCombinationDTO>) singleResult); |
| | | } |
| | | |
| | | |
| | | } else { |
| | | for (String processVal : processList) { |
| | | laminating = reportingWorkMapper.getProcessLaminating(processVal); |
| | | |
| | | List<WorkInProgressCombinationDTO> singleResult = |
| | | reportMapper.exportWorkInProgressCombination(processVal, laminating, inputVal); |
| | | |
| | | if (singleResult != null && !singleResult.isEmpty()) { |
| | | resultList.addAll((Collection<? extends WorkInProgressCombinationDTO>) singleResult); |
| | | } |
| | | } |
| | | } |
| | | |
| | | return resultList; |
| | | } |
| | | |
| | | public Object processCardProgressCollectSv(String orderId, List<Integer> columns) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | //获取表格内容数据 |
| | | List<Map<String, String>> dataList = reportMapper.processCardProgressCollectMp(orderId); |
| | | return null; |
| | | } |
| | | } |