| | |
| | | import com.example.erp.common.Constants; |
| | | import com.example.erp.dto.pp.OrderNumberTransferDTO; |
| | | import com.example.erp.entity.pp.*; |
| | | import com.example.erp.entity.sd.BasicData; |
| | | import com.example.erp.entity.sd.Order; |
| | | import com.example.erp.entity.sd.OrderDetail; |
| | | 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; |
| | |
| | | this.reportingWorkTransferMapper = reportingWorkTransferMapper; |
| | | }*/ |
| | | |
| | | //将层数字符串用逗号隔开 |
| | | 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> AddSelectLastWorkSv(String processIdStr, String technologyStr, String process, String reportType) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | //获取报工工序是否为复合工程 |
| | | String laminating = reportingWorkMapper.getProcessLaminating(process); |
| | | //查询流程卡工艺流程 |
| | | String technologicalProcess = reportingWorkMapper.SelectTechnologicalProcess(processIdStr,technologyStr); |
| | | String technologicalProcess = reportingWorkMapper.SelectTechnologicalProcess(processIdStr,splitTechNumbers(technologyStr)); |
| | | |
| | | if (technologicalProcess!=null || !technologicalProcess.equals("")){ |
| | | String[] processList = technologicalProcess.split("->"); |
| | |
| | | nextProcess = processList[i + 1]; |
| | | } |
| | | //查询当前工序的表头数据 |
| | | map.put("data", reportingWorkMapper.AddSelectLastWorkMp(processIdStr, technologyStr, previousProcess, nextProcess, process,reportType)); |
| | | map.put("data", reportingWorkMapper.AddSelectLastWorkMp(processIdStr, splitTechNumbers(technologyStr), previousProcess, nextProcess, process,reportType)); |
| | | map.put("thisProcess", processList); |
| | | break; |
| | | } |
| | |
| | | //查询本工序报工需要哪几层,上工序是什么 |
| | | String obtainTechnology = reportingWorkMapper.SelectWorkTechnologyMp(processIdStr); |
| | | |
| | | map.put("numberList", flowCardMapper.getGlassNumber(technologyStr,processIdStr)); |
| | | map.put("numberList", flowCardMapper.getGlassNumber(splitTechNumbers(technologyStr),processIdStr)); |
| | | |
| | | //判断本工序是不是第一道工序 |
| | | if (interceptProcess.equals(process)) { |
| | | //是第一道工序,查询流程卡数据 |
| | | map.put("Detail", reportingWorkMapper.SelectTechnologicalNumMp(processIdStr, technologyStr, process,reportType)); |
| | | map.put("Detail", reportingWorkMapper.SelectTechnologicalNumMp(processIdStr, splitTechNumbers(technologyStr), process,reportType)); |
| | | } else { |
| | | ReportingWork retrievedData = (ReportingWork) map.get("data"); |
| | | if (retrievedData!=null){ |
| | |
| | | //根据审核状态查询未审核数据 |
| | | // if (reviewedState==1){//已审核 |
| | | //不是第一道工序,查询报工数据 |
| | | List<Map<String,String>> details = reportingWorkMapper.SelectReworlDetailMp(processIdStr, technologyStr, process,previousProcess,laminating); |
| | | List<Map<String,String>> details = reportingWorkMapper.SelectReworlDetailMp(processIdStr, splitTechNumbers(technologyStr), process,previousProcess,laminating); |
| | | if(process.equals("中空")){ |
| | | //获取该流程卡订单号 |
| | | String orderId = reportingWorkMapper.selectOrderid(processIdStr); |
| | |
| | | return map; |
| | | } |
| | | |
| | | //报工新增 |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean SaveReportingWorkSv(Map<String, Object> reportingWorkMap) { |
| | | //接收解析主附表信息 |
| | | // 接收解析主附表信息 |
| | | JSONObject reportingWorkJson = new JSONObject(reportingWorkMap); |
| | | ReportingWork reportingWork = JSONObject.parseObject(JSONObject.toJSONString(reportingWorkJson.get("title")), ReportingWork.class); |
| | | List<ReportingWorkDetail> reportingWorkDetails = JSONArray.parseArray(JSONObject.toJSONString(reportingWorkJson.get("detail")), ReportingWorkDetail.class); |
| | | //获取当前最大报工单号生成报工单号 |
| | | String formattedNumber = String.format("%04d", reportingWorkMapper.selectMaxReportingWorkId() + 1); |
| | | //格式化当前日期 |
| | | ReportingWork reportingWork = JSONObject.parseObject( |
| | | JSONObject.toJSONString(reportingWorkJson.get("title")), ReportingWork.class); |
| | | List<ReportingWorkDetail> reportingWorkDetails = JSONArray.parseArray( |
| | | JSONObject.toJSONString(reportingWorkJson.get("detail")), ReportingWorkDetail.class); |
| | | |
| | | // 报工编号 |
| | | Integer maxId = reportingWorkMapper.selectMaxReportingWorkId(); |
| | | if (maxId == null) { |
| | | maxId = 0; |
| | | } |
| | | String formattedNumber = String.format("%04d", maxId + 1); |
| | | |
| | | // 格式化当前日期 |
| | | Date currentDate = new Date(); |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyMMdd"); |
| | | String formattedDate = dateFormat.format(currentDate); |
| | | String reportingWorkId = "BG" + formattedDate + formattedNumber; |
| | | reportingWork.setReportingWorkId(reportingWorkId); |
| | | String[] processIdStr = reportingWork.getProcessId().split("/"); |
| | | reportingWork.setProcessId(processIdStr[0]); |
| | | |
| | | // 处理工序 ID |
| | | String[] processIdStr = reportingWork.getProcessId() != null |
| | | ? reportingWork.getProcessId().split("/") |
| | | : new String[]{""}; |
| | | reportingWork.setProcessId(processIdStr[0]); // 保底只取第一个 |
| | | reportingWork.setThisWornQuantity(0); |
| | | reportingWork.setThisCompletedQuantity(0); |
| | | |
| | | int reviewState = (int) reportingWorkJson.get("type"); |
| | | if (reviewState == 1) {//审核通过 |
| | | // 审核状态 |
| | | Integer reviewState = reportingWorkJson.getInteger("type"); |
| | | if (reviewState != null && reviewState == 1) { // 审核通过 |
| | | reportingWork.setReviewed(reportingWork.getCreator()); |
| | | reportingWork.setReviewedState(1); |
| | | } else { |
| | | reportingWork.setReviewedState(0); |
| | | } |
| | | if(reportingWork.getReportingWorkTime()==null){ |
| | | LocalDateTime localDateTime = LocalDateTime.now(); |
| | | reportingWork.setReportingWorkTime(localDateTime); |
| | | } |
| | | //是否线补 1现补 0未现补 |
| | | int isPatch = (reportingWorkJson.get("isPatch") != null) ? (int) reportingWorkJson.get("isPatch") : 0; |
| | | |
| | | //主表插入 |
| | | // 时间为空则补上当前时间 |
| | | if (reportingWork.getReportingWorkTime() == null) { |
| | | reportingWork.setReportingWorkTime(LocalDateTime.now()); |
| | | } |
| | | |
| | | // 是否线补 1现补 0未现补 |
| | | int isPatch = reportingWorkJson.getInteger("isPatch") != null |
| | | ? reportingWorkJson.getInteger("isPatch") : 0; |
| | | |
| | | // 主表插入 |
| | | reportingWorkMapper.insert(reportingWork); |
| | | //副表循环插入,并且插入次破信息表。再根据次破信息修改订单玻璃流程表的完工数量与刺破数量 |
| | | final Integer[] maxTechnologyNumber = {0,0}; |
| | | |
| | | // 副表循环插入,并处理次破逻辑 |
| | | final Integer[] maxTechnologyNumber = {0, 0}; |
| | | reportingWorkDetails.forEach(reportingWorkDetail -> { |
| | | //合片数量汇总减少 |
| | | if(Integer.parseInt(reportingWorkDetail.getTechnologyNumber()) > maxTechnologyNumber[0]){ |
| | | maxTechnologyNumber[0] = Integer.valueOf(reportingWorkDetail.getTechnologyNumber()); |
| | | maxTechnologyNumber[1]+=1; |
| | | if (reportingWorkDetail == null) return; |
| | | |
| | | // 统一用安全数值,避免 null 报错 |
| | | int completedQty = Optional.ofNullable(reportingWorkDetail.getCompletedQuantity()).orElse(0); |
| | | int breakageQty = Optional.ofNullable(reportingWorkDetail.getBreakageQuantity()).orElse(0); |
| | | |
| | | // 合片数量汇总减少 |
| | | try { |
| | | int techNum = Integer.parseInt(reportingWorkDetail.getTechnologyNumber()); |
| | | if (techNum > maxTechnologyNumber[0]) { |
| | | maxTechnologyNumber[0] = techNum; |
| | | maxTechnologyNumber[1] += 1; |
| | | } |
| | | } catch (NumberFormatException ignored) { |
| | | } |
| | | reportingWork.setThisCompletedQuantity(reportingWork.getThisCompletedQuantity() + reportingWorkDetail.getCompletedQuantity()); |
| | | reportingWork.setThisWornQuantity(reportingWork.getThisWornQuantity() + reportingWorkDetail.getBreakageQuantity()); |
| | | int qualityInsStatus = (int) reportingWorkJson.get("qualityInsStatus"); |
| | | |
| | | reportingWork.setThisCompletedQuantity(reportingWork.getThisCompletedQuantity() + completedQty); |
| | | reportingWork.setThisWornQuantity(reportingWork.getThisWornQuantity() + breakageQty); |
| | | |
| | | int qualityInsStatus = reportingWorkJson.getInteger("qualityInsStatus") != null |
| | | ? reportingWorkJson.getInteger("qualityInsStatus") : 0; |
| | | |
| | | reportingWorkDetail.setReportingWorkId(reportingWorkId); |
| | | List<DamageDetails> damageDetails = reportingWorkDetail.getDamageDetails(); |
| | | reportingWork.setNextProcess(orderProcessDetailMapper.selectNextProcess(processIdStr[0],processIdStr[1],reportingWork.getThisProcess(),reportingWorkDetail.getOrderNumber())); |
| | | |
| | | //次破明细表插入数据 |
| | | reportingWork.setNextProcess(orderProcessDetailMapper.selectNextProcess( |
| | | processIdStr[0], |
| | | processIdStr.length > 1 ? processIdStr[1] : "", |
| | | reportingWork.getThisProcess(), |
| | | reportingWorkDetail.getOrderNumber() |
| | | )); |
| | | |
| | | // 次破明细表插入数据 |
| | | if (damageDetails != null && !damageDetails.isEmpty()) { |
| | | damageDetails.forEach(damageDetail -> { |
| | | if (damageDetail == null) return; |
| | | damageDetail.setReportingWorkId(reportingWorkId); |
| | | damageDetail.setOrderNumber(reportingWorkDetail.getOrderNumber()); |
| | | damageDetail.setProcessId(reportingWork.getProcessId()); |
| | | damageDetail.setTechnologyNumber(reportingWorkDetail.getTechnologyNumber()); |
| | | //跨工序次破修改质检状态 |
| | | if (!damageDetail.getResponsibleProcess().equals(reportingWork.getThisProcess()) && qualityInsStatus==2) { |
| | | |
| | | if (!Objects.equals(damageDetail.getResponsibleProcess(), reportingWork.getThisProcess()) |
| | | && qualityInsStatus == 2) { |
| | | damageDetail.setQualityInsStatus(1); |
| | | } |
| | | if (isPatch == 1){ |
| | | if (isPatch == 1) { |
| | | damageDetail.setQualityInsStatus(2); |
| | | } |
| | | damageDetailsMapper.insert(damageDetail); |
| | | }); |
| | | } |
| | | //查询流程卡工艺流程 |
| | | String technologicalProcess = reportingWorkMapper.SelectTechnologicalProcess(reportingWork.getProcessId(), reportingWorkDetail.getTechnologyNumber()); |
| | | |
| | | int index = technologicalProcess.indexOf("-"); |
| | | String interceptProcess = ""; |
| | | if (index <0){ |
| | | interceptProcess = technologicalProcess; |
| | | } |
| | | else { |
| | | //获取工艺流程第一个工序 |
| | | interceptProcess = technologicalProcess.substring(0, index); |
| | | // 查询工艺流程 |
| | | String technologicalProcess = reportingWorkMapper.SelectTechnologicalProcess( |
| | | reportingWork.getProcessId(), reportingWorkDetail.getTechnologyNumber()); |
| | | String interceptProcess; |
| | | if (technologicalProcess != null) { |
| | | int index = technologicalProcess.indexOf("-"); |
| | | interceptProcess = (index < 0) ? technologicalProcess : technologicalProcess.substring(0, index); |
| | | } else { |
| | | interceptProcess = ""; |
| | | } |
| | | |
| | | |
| | | //判断当前工序是否为第一道工序工序,使用流程卡表数量或者小片流程表上工序数量 |
| | | int processNum = 0; |
| | | // 判断是否第一道工序 |
| | | int processNum; |
| | | if (interceptProcess.equals(reportingWork.getThisProcess())) { |
| | | processNum = reportingWorkMapper.selectFlowCardNum( |
| | | reportingWorkDetail.getOrderNumber(), |
| | |
| | | ); |
| | | } |
| | | |
| | | |
| | | //判断是否大于当前数量并且抛出异常 |
| | | if (processNum < (reportingWorkDetail.getBreakageQuantity() + reportingWorkDetail.getCompletedQuantity())) { |
| | | // 校验数量合法性 |
| | | if (processNum < (breakageQty + completedQty)) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("orderNumber", reportingWorkDetail.getOrderNumber()); |
| | | map.put("technologyNumber", reportingWorkDetail.getOrderNumber()); |
| | | map.put("technologyNumber", reportingWorkDetail.getTechnologyNumber()); // 修复错误 |
| | | map.put("processNum", processNum); |
| | | map.put("sumNum", reportingWorkDetail.getBreakageQuantity() + reportingWorkDetail.getCompletedQuantity()); |
| | | map.put("sumNum", breakageQty + completedQty); |
| | | String msg = JSON.toJSONString(map); |
| | | throw new ServiceException(Constants.Code_600, msg); |
| | | } |
| | | |
| | | OrderProcessDetail orderProcessDetail = new OrderProcessDetail(); |
| | | orderProcessDetail.setBrokenNum(reportingWorkDetail.getBreakageQuantity()); |
| | | orderProcessDetail.setReportingWorkNum(reportingWorkDetail.getCompletedQuantity()); |
| | | orderProcessDetail.setReportingWorkNumCount(reportingWorkDetail.getCompletedQuantity()); |
| | | orderProcessDetail.setBrokenNum(breakageQty); |
| | | orderProcessDetail.setReportingWorkNum(completedQty); |
| | | orderProcessDetail.setReportingWorkNumCount(completedQty); |
| | | |
| | | |
| | | if (isPatch == 0){//未现补 |
| | | //根据订单id,订单序号,以及小片序号 更新小片流程的完工数量以及刺破数量 |
| | | // 未现补:更新小片流程数量 |
| | | if (isPatch == 0) { |
| | | LambdaUpdateWrapper<OrderProcessDetail> updateWrapper = new LambdaUpdateWrapper<>(); |
| | | updateWrapper.eq(OrderProcessDetail::getOrderNumber, reportingWorkDetail.getOrderNumber()) |
| | | .eq(OrderProcessDetail::getProcessId, reportingWork.getProcessId()) |
| | | .eq(OrderProcessDetail::getOrderId, reportingWork.getOrderId()) |
| | | .eq(OrderProcessDetail::getProcess, reportingWork.getThisProcess()) |
| | | .eq(OrderProcessDetail::getTechnologyNumber, reportingWorkDetail.getTechnologyNumber()) |
| | | .setSql("reporting_work_num_count = reporting_work_num_count +" + orderProcessDetail.getReportingWorkNum()) |
| | | .setSql("reporting_work_num =reporting_work_num +" + orderProcessDetail.getReportingWorkNum()) |
| | | .setSql("reporting_work_num_count = reporting_work_num_count +" + completedQty) |
| | | .setSql("reporting_work_num = reporting_work_num +" + completedQty) |
| | | .setSql("update_time = now()") |
| | | .setSql("broken_num =broken_num +" + orderProcessDetail.getBrokenNum()); |
| | | .setSql("broken_num = broken_num +" + breakageQty); |
| | | orderProcessDetailMapper.update(null, updateWrapper); |
| | | } |
| | | |
| | | //判断完工数量和刺破数量是否为0,为0则不插入到数据库 |
| | | if (!(reportingWorkDetail.getCompletedQuantity() == 0 && reportingWorkDetail.getBreakageQuantity() == 0)) { |
| | | // 判断完工数量和次破数量是否为0,为0则不插入 |
| | | if (!(completedQty == 0 && breakageQty == 0)) { |
| | | reportingWorkDetailMapper.insert(reportingWorkDetail); |
| | | } |
| | | |
| | | //更新流程卡表的报工数量 |
| | | // 更新流程卡报工数量 |
| | | if (reportingWork.getNextProcess() == null || reportingWork.getNextProcess().isEmpty()) { |
| | | LambdaUpdateWrapper<FlowCard> flowCardLambdaUpdateWrapper = |
| | | new LambdaUpdateWrapper<>(); |
| | | LambdaUpdateWrapper<FlowCard> flowCardLambdaUpdateWrapper = new LambdaUpdateWrapper<>(); |
| | | flowCardLambdaUpdateWrapper |
| | | .eq(FlowCard::getProcessId, reportingWork.getProcessId()) |
| | | .eq(FlowCard::getOrderNumber, reportingWorkDetail.getOrderNumber()) |
| | | .eq(FlowCard::getTechnologyNumber, reportingWorkDetail.getTechnologyNumber()) |
| | | .setSql("inventory_quantity = inventory_quantity +" + orderProcessDetail.getReportingWorkNum()); |
| | | .setSql("inventory_quantity = inventory_quantity +" + completedQty); |
| | | flowCardMapper.update(null, flowCardLambdaUpdateWrapper); |
| | | } |
| | | |
| | | |
| | | }); |
| | | //获取报工工序是否为复合工程 |
| | | |
| | | reportingWork.setThisCompletedQuantity(reportingWork.getThisCompletedQuantity()/maxTechnologyNumber[1]); |
| | | |
| | | // 获取报工工序是否为复合工程 |
| | | if (maxTechnologyNumber[1] != 0) { |
| | | reportingWork.setThisCompletedQuantity( |
| | | reportingWork.getThisCompletedQuantity() / maxTechnologyNumber[1]); |
| | | } |
| | | |
| | | reportingWorkMapper.update(reportingWork, new LambdaUpdateWrapper<ReportingWork>() |
| | | .eq(ReportingWork::getId, reportingWork.getId())); |
| | | |
| | | //保存日志 |
| | | // 保存日志 |
| | | Log log = new Log(); |
| | | log.setContent(reportingWorkMap.toString()); |
| | | log.setContent(JSON.toJSONString(reportingWorkMap)); |
| | | log.setFunction("saveReportingWork报工新增"); |
| | | log.setOperatorId((String) reportingWorkJson.get("userId")); |
| | | log.setOperator((String) reportingWorkJson.get("userName")); |
| | | log.setOperatorId(reportingWorkJson.getString("userId")); |
| | | log.setOperator(reportingWorkJson.getString("userName")); |
| | | logService.saveLog(log); |
| | | |
| | | return true; |
| | | } |
| | | |
| | | |
| | | //报工新增 |
| | | // @Transactional(rollbackFor = Exception.class) |
| | | // public boolean SaveReportingWorkSv(Map<String, Object> reportingWorkMap) { |
| | | // //接收解析主附表信息 |
| | | // JSONObject reportingWorkJson = new JSONObject(reportingWorkMap); |
| | | // ReportingWork reportingWork = JSONObject.parseObject(JSONObject.toJSONString(reportingWorkJson.get("title")), ReportingWork.class); |
| | | // List<ReportingWorkDetail> reportingWorkDetails = JSONArray.parseArray(JSONObject.toJSONString(reportingWorkJson.get("detail")), ReportingWorkDetail.class); |
| | | // //获取当前最大报工单号生成报工单号 |
| | | // String formattedNumber = String.format("%04d", reportingWorkMapper.selectMaxReportingWorkId() + 1); |
| | | // //格式化当前日期 |
| | | // Date currentDate = new Date(); |
| | | // SimpleDateFormat dateFormat = new SimpleDateFormat("yyMMdd"); |
| | | // String formattedDate = dateFormat.format(currentDate); |
| | | // String reportingWorkId = "BG" + formattedDate + formattedNumber; |
| | | // reportingWork.setReportingWorkId(reportingWorkId); |
| | | // String[] processIdStr = reportingWork.getProcessId().split("/"); |
| | | // reportingWork.setProcessId(processIdStr[0]); |
| | | // reportingWork.setThisWornQuantity(0); |
| | | // reportingWork.setThisCompletedQuantity(0); |
| | | // |
| | | // int reviewState = (int) reportingWorkJson.get("type"); |
| | | // if (reviewState == 1) {//审核通过 |
| | | // reportingWork.setReviewed(reportingWork.getCreator()); |
| | | // reportingWork.setReviewedState(1); |
| | | // } else { |
| | | // reportingWork.setReviewedState(0); |
| | | // } |
| | | // if(reportingWork.getReportingWorkTime()==null){ |
| | | // LocalDateTime localDateTime = LocalDateTime.now(); |
| | | // reportingWork.setReportingWorkTime(localDateTime); |
| | | // } |
| | | // //是否线补 1现补 0未现补 |
| | | // int isPatch = (reportingWorkJson.get("isPatch") != null) ? (int) reportingWorkJson.get("isPatch") : 0; |
| | | // |
| | | // //主表插入 |
| | | // reportingWorkMapper.insert(reportingWork); |
| | | // //副表循环插入,并且插入次破信息表。再根据次破信息修改订单玻璃流程表的完工数量与刺破数量 |
| | | // final Integer[] maxTechnologyNumber = {0,0}; |
| | | // reportingWorkDetails.forEach(reportingWorkDetail -> { |
| | | // //合片数量汇总减少 |
| | | // if(Integer.parseInt(reportingWorkDetail.getTechnologyNumber()) > maxTechnologyNumber[0]){ |
| | | // maxTechnologyNumber[0] = Integer.valueOf(reportingWorkDetail.getTechnologyNumber()); |
| | | // maxTechnologyNumber[1]+=1; |
| | | // } |
| | | // reportingWork.setThisCompletedQuantity(reportingWork.getThisCompletedQuantity() + reportingWorkDetail.getCompletedQuantity()); |
| | | // reportingWork.setThisWornQuantity(reportingWork.getThisWornQuantity() + reportingWorkDetail.getBreakageQuantity()); |
| | | // int qualityInsStatus = (int) reportingWorkJson.get("qualityInsStatus"); |
| | | // reportingWorkDetail.setReportingWorkId(reportingWorkId); |
| | | // List<DamageDetails> damageDetails = reportingWorkDetail.getDamageDetails(); |
| | | // reportingWork.setNextProcess(orderProcessDetailMapper.selectNextProcess(processIdStr[0],processIdStr[1],reportingWork.getThisProcess(),reportingWorkDetail.getOrderNumber())); |
| | | // |
| | | // //次破明细表插入数据 |
| | | // if (damageDetails != null && !damageDetails.isEmpty()) { |
| | | // damageDetails.forEach(damageDetail -> { |
| | | // damageDetail.setReportingWorkId(reportingWorkId); |
| | | // damageDetail.setOrderNumber(reportingWorkDetail.getOrderNumber()); |
| | | // damageDetail.setProcessId(reportingWork.getProcessId()); |
| | | // damageDetail.setTechnologyNumber(reportingWorkDetail.getTechnologyNumber()); |
| | | // //跨工序次破修改质检状态 |
| | | // if (!damageDetail.getResponsibleProcess().equals(reportingWork.getThisProcess()) && qualityInsStatus==2) { |
| | | // damageDetail.setQualityInsStatus(1); |
| | | // } |
| | | // if (isPatch == 1){ |
| | | // damageDetail.setQualityInsStatus(2); |
| | | // } |
| | | // damageDetailsMapper.insert(damageDetail); |
| | | // }); |
| | | // } |
| | | // //查询流程卡工艺流程 |
| | | // String technologicalProcess = reportingWorkMapper.SelectTechnologicalProcess(reportingWork.getProcessId(), reportingWorkDetail.getTechnologyNumber()); |
| | | // |
| | | // int index = technologicalProcess.indexOf("-"); |
| | | // String interceptProcess = ""; |
| | | // if (index <0){ |
| | | // interceptProcess = technologicalProcess; |
| | | // } |
| | | // else { |
| | | // //获取工艺流程第一个工序 |
| | | // interceptProcess = technologicalProcess.substring(0, index); |
| | | // } |
| | | // |
| | | // |
| | | // //判断当前工序是否为第一道工序工序,使用流程卡表数量或者小片流程表上工序数量 |
| | | // int processNum = 0; |
| | | // if (interceptProcess.equals(reportingWork.getThisProcess())) { |
| | | // processNum = reportingWorkMapper.selectFlowCardNum( |
| | | // reportingWorkDetail.getOrderNumber(), |
| | | // reportingWorkDetail.getTechnologyNumber(), |
| | | // reportingWork.getProcessId(), |
| | | // reportingWork.getThisProcess() |
| | | // ); |
| | | // } else { |
| | | // processNum = reportingWorkMapper.selectGlassProcessNum( |
| | | // reportingWorkDetail.getOrderNumber(), |
| | | // reportingWorkDetail.getTechnologyNumber(), |
| | | // reportingWork.getProcessId(), |
| | | // reportingWork.getThisProcess() |
| | | // ); |
| | | // } |
| | | // |
| | | // |
| | | // //判断是否大于当前数量并且抛出异常 |
| | | // if (processNum < (reportingWorkDetail.getBreakageQuantity() + reportingWorkDetail.getCompletedQuantity())) { |
| | | // Map<String, Object> map = new HashMap<>(); |
| | | // map.put("orderNumber", reportingWorkDetail.getOrderNumber()); |
| | | // map.put("technologyNumber", reportingWorkDetail.getOrderNumber()); |
| | | // map.put("processNum", processNum); |
| | | // map.put("sumNum", reportingWorkDetail.getBreakageQuantity() + reportingWorkDetail.getCompletedQuantity()); |
| | | // String msg = JSON.toJSONString(map); |
| | | // throw new ServiceException(Constants.Code_600, msg); |
| | | // } |
| | | // |
| | | // OrderProcessDetail orderProcessDetail = new OrderProcessDetail(); |
| | | // orderProcessDetail.setBrokenNum(reportingWorkDetail.getBreakageQuantity()); |
| | | // orderProcessDetail.setReportingWorkNum(reportingWorkDetail.getCompletedQuantity()); |
| | | // orderProcessDetail.setReportingWorkNumCount(reportingWorkDetail.getCompletedQuantity()); |
| | | // |
| | | // |
| | | // if (isPatch == 0){//未现补 |
| | | // //根据订单id,订单序号,以及小片序号 更新小片流程的完工数量以及刺破数量 |
| | | // LambdaUpdateWrapper<OrderProcessDetail> updateWrapper = new LambdaUpdateWrapper<>(); |
| | | // updateWrapper.eq(OrderProcessDetail::getOrderNumber, reportingWorkDetail.getOrderNumber()) |
| | | // .eq(OrderProcessDetail::getProcessId, reportingWork.getProcessId()) |
| | | // .eq(OrderProcessDetail::getOrderId, reportingWork.getOrderId()) |
| | | // .eq(OrderProcessDetail::getProcess, reportingWork.getThisProcess()) |
| | | // .eq(OrderProcessDetail::getTechnologyNumber, reportingWorkDetail.getTechnologyNumber()) |
| | | // .setSql("reporting_work_num_count = reporting_work_num_count +" + orderProcessDetail.getReportingWorkNum()) |
| | | // .setSql("reporting_work_num =reporting_work_num +" + orderProcessDetail.getReportingWorkNum()) |
| | | // .setSql("update_time = now()") |
| | | // .setSql("broken_num =broken_num +" + orderProcessDetail.getBrokenNum()); |
| | | // orderProcessDetailMapper.update(null, updateWrapper); |
| | | // } |
| | | // |
| | | // //判断完工数量和刺破数量是否为0,为0则不插入到数据库 |
| | | // if (!(reportingWorkDetail.getCompletedQuantity() == 0 && reportingWorkDetail.getBreakageQuantity() == 0)) { |
| | | // reportingWorkDetailMapper.insert(reportingWorkDetail); |
| | | // } |
| | | // |
| | | // //更新流程卡表的报工数量 |
| | | // if (reportingWork.getNextProcess() == null || reportingWork.getNextProcess().isEmpty()) { |
| | | // LambdaUpdateWrapper<FlowCard> flowCardLambdaUpdateWrapper = |
| | | // new LambdaUpdateWrapper<>(); |
| | | // flowCardLambdaUpdateWrapper |
| | | // .eq(FlowCard::getProcessId, reportingWork.getProcessId()) |
| | | // .eq(FlowCard::getOrderNumber, reportingWorkDetail.getOrderNumber()) |
| | | // .eq(FlowCard::getTechnologyNumber, reportingWorkDetail.getTechnologyNumber()) |
| | | // .setSql("inventory_quantity = inventory_quantity +" + orderProcessDetail.getReportingWorkNum()); |
| | | // flowCardMapper.update(null, flowCardLambdaUpdateWrapper); |
| | | // } |
| | | // |
| | | // |
| | | // }); |
| | | // //获取报工工序是否为复合工程 |
| | | // |
| | | // reportingWork.setThisCompletedQuantity(reportingWork.getThisCompletedQuantity()/maxTechnologyNumber[1]); |
| | | // |
| | | // |
| | | // reportingWorkMapper.update(reportingWork, new LambdaUpdateWrapper<ReportingWork>() |
| | | // .eq(ReportingWork::getId, reportingWork.getId())); |
| | | // |
| | | // //保存日志 |
| | | // Log log = new Log(); |
| | | // log.setContent(reportingWorkMap.toString()); |
| | | // log.setFunction("saveReportingWork报工新增"); |
| | | // log.setOperatorId((String) reportingWorkJson.get("userId")); |
| | | // log.setOperator((String) reportingWorkJson.get("userName")); |
| | | // logService.saveLog(log); |
| | | // return true; |
| | | // } |
| | | |
| | | //下工序审核方法 |
| | | public boolean ReviewReportingWorkSv(Map<String, String> reportingWork) { |
| | |
| | | orderMapper.selectOne(new LambdaQueryWrapper<Order>() |
| | | .eq(Order::getOrderId, reportingWork.getOrderId()))); |
| | | reportingWork.setFlowCard(new FlowCard()); |
| | | |
| | | |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | //报工管理查询 |
| | | public Map<String, Object> selectReportingWorkSv(Integer pageNum, Integer pageSize, java.sql.Date selectTime1, java.sql.Date selectTime2, String orderId, ReportingWork reportingWork) { |
| | | public Map<String, Object> selectReportingWorkSv(Integer pageNum, Integer pageSize, List<String> selectDate, String orderId, ReportingWork reportingWork) { |
| | | Integer offset = (pageNum - 1) * pageSize; |
| | | if ("null".equals(orderId)) { |
| | | orderId = ""; |
| | | } |
| | | String endDate = LocalDate.now().toString(); |
| | | String startDate = LocalDate.now().minusDays(3).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", reportingWorkMapper.selectReportingWorkMp(offset, pageSize, selectTime1, selectTime2, orderId, reportingWork)); |
| | | map.put("data", reportingWorkMapper.selectReportingWorkMp(offset, pageSize, startDate, endDate, orderId, reportingWork)); |
| | | // map.put("total", reportingWorkMapper.getPageTotal(offset, pageSize, selectTime1, selectTime2, orderId, reportingWork)); |
| | | map.put("total" ,reportingWorkMapper.getFootSum(offset, pageSize, selectTime1, selectTime2, orderId, reportingWork)); |
| | | map.put("total" ,reportingWorkMapper.getFootSum(offset, pageSize, startDate, endDate, orderId, reportingWork)); |
| | | List<String> list = new ArrayList<>(); |
| | | list.add(startDate); |
| | | list.add(endDate); |
| | | map.put("selectDate",list); |
| | | return map; |
| | | } |
| | | |
| | |
| | | if (transferState !=3){ |
| | | //判断是否有补片返工数据 |
| | | if (countStates==0){ |
| | | //当下工序未审核则删除本工序 |
| | | ReportingWork reportingWork = reportingWorkMapper.selectOne(new LambdaQueryWrapper<ReportingWork>() |
| | | .eq(ReportingWork::getReportingWorkId, reportingWorkId)); |
| | | //保存日志 |
| | | Log log = new Log(); |
| | | log.setContent(reportingWorkId+"-"+processId+"-"+thisProcess); |
| | | log.setFunction("deleteWork报工删除"); |
| | | log.setOperatorId(userId); |
| | | log.setOperator(userName); |
| | | |
| | | |
| | | //判断是否是入库工序 |
| | | if (lastProcess.equals(thisProcess)) {//是入库工序 |
| | | //查询该流程卡数量、可入库数量、已入库数量 |
| | |
| | | } |
| | | //删除报工,将审核状态改为-1 |
| | | reportingWorkMapper.deleteWork(reportingWorkId); |
| | | //保存日志 |
| | | Log log = new Log(); |
| | | log.setContent(reportingWorkId+"-"+processId+"-"+thisProcess); |
| | | log.setFunction("deleteWork报工入库删除"); |
| | | log.setOperatorId(userId); |
| | | log.setOperator(userName); |
| | | logService.saveLog(log); |
| | | return true; |
| | | } else { |
| | |
| | | } |
| | | |
| | | } else {//不是入库工序 |
| | | if(reportingWork.getReviewedState()==0){ |
| | | //查询当前报工编号完工次破数量的数据 |
| | | List<Map<String, Object>> workDateList = reportingWorkMapper.reportingWorkDate(reportingWorkId); |
| | | for (Map<String, Object> item : workDateList) { |
| | | //更新报工流程表数据 |
| | | reportingWorkMapper.updateWorkProcess(processId, item.get("order_number"), item.get("technology_number"), item.get("completed_quantity"), item.get("breakage_quantity"), thisProcess); |
| | | } |
| | | //删除报工,将审核状态改为-1 |
| | | reportingWorkMapper.deleteWork(reportingWorkId); |
| | | logService.saveLog(log); |
| | | return true; |
| | | } |
| | | |
| | | if (count == 0) { |
| | | //查询当前报工编号完工次破数量的数据 |
| | | List<Map<String, Object>> workDateList = reportingWorkMapper.reportingWorkDate(reportingWorkId); |
| | |
| | | //删除报工,将审核状态改为-1 |
| | | reportingWorkMapper.deleteWork(reportingWorkId); |
| | | |
| | | //保存日志 |
| | | Log log = new Log(); |
| | | log.setContent(reportingWorkId+"-"+processId+"-"+thisProcess); |
| | | log.setFunction("deleteWork报工删除"); |
| | | log.setOperatorId(userId); |
| | | log.setOperator(userName); |
| | | |
| | | logService.saveLog(log); |
| | | return true; |
| | | } else { |
| | |
| | | } |
| | | |
| | | //查询质检审核 |
| | | public Map<String, Object> selectQualityTestingSv(Integer pageNum, Integer pageSize, java.sql.Date selectTime1, java.sql.Date selectTime2, Integer state, String processId, ReportingWork reportingWork) { |
| | | public Map<String, Object> selectQualityTestingSv(Integer pageNum, Integer pageSize, List<String> selectDate, Integer state, String processId, ReportingWork reportingWork) { |
| | | Integer offset = (pageNum - 1) * pageSize; |
| | | if ("null".equals(processId)) { |
| | | processId = ""; |
| | | } |
| | | String endDate = LocalDate.now().toString(); |
| | | String startDate = LocalDate.now().minusDays(3).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", reportingWorkMapper.selectQualityTestingMp(offset, pageSize, selectTime1, selectTime2, state, processId, reportingWork)); |
| | | map.put("total", reportingWorkMapper.getQualityPageTotal(offset, pageSize, selectTime1, selectTime2, state, processId, reportingWork)); |
| | | |
| | | map.put("data", reportingWorkMapper.selectQualityTestingMp(offset, pageSize, startDate, endDate, state, processId, reportingWork)); |
| | | map.put("total", reportingWorkMapper.getQualityPageTotal(offset, pageSize, startDate, endDate, state, processId, reportingWork)); |
| | | List<String> list = new ArrayList<>(); |
| | | list.add(startDate); |
| | | list.add(endDate); |
| | | map.put("selectDate",list); |
| | | return map; |
| | | } |
| | | |
| | |
| | | .eq("order_sort", reportingWork.get("oldOrderNumber")) |
| | | .eq("review_status",0) |
| | | ); |
| | | if (patchLogs.isEmpty()){ |
| | | if (!patchLogs.isEmpty()){ |
| | | result.put("msg","旧订单存在补片未审核数据"); |
| | | result.put("data",false); |
| | | return result; |
| | |
| | | .eq("order_sort", reportingWork.get("oldOrderNumber")) |
| | | .eq("review_status",0) |
| | | ); |
| | | if (patchLogs.isEmpty()){ |
| | | if (!patchLogs.isEmpty()){ |
| | | result.put("msg","旧订单存在返工未审核数据,请先审核报工后再进行转出"); |
| | | result.put("data",false); |
| | | return result; |
| | |
| | | //restTemplate.postForObject("http://localhost:8086/order/test",orderNumberTransferList,String.class); |
| | | |
| | | //向mes发送http请求 |
| | | ResponseEntity<OrderNumberTransferDTO> response =restTemplate.exchange( |
| | | /*ResponseEntity<OrderNumberTransferDTO> response =restTemplate.exchange( |
| | | "http://localhost:88/api/loadGlass/order/order/orderChange", |
| | | HttpMethod.POST, |
| | | new HttpEntity<>(orderNumberTransferList), |
| | |
| | | }else{ |
| | | result.put("msg","连接mes响应超时"); |
| | | result.put("data",false); |
| | | } |
| | | }*/ |
| | | |
| | | result.put("data",true); |
| | | return result; |
| | | |
| | | } |
| | |
| | | |
| | | } |
| | | |
| | | public List<BasicDataProduce> selectEquipmentByProcessSv(String process) { |
| | | return reportingWorkMapper.SelectWorkBasicDeviceMp(process); |
| | | } |
| | | public List<BasicDataProduce> selectEquipmentByProcessSv(String process) { |
| | | return reportingWorkMapper.SelectWorkBasicDeviceMp(process); |
| | | } |
| | | |
| | | public String saveWorkStorage(Map<String, Object> object) { |
| | | //List<Map<String, Object>> flowCard = reportingWorkMapper.getStorageData(); |
| | | //finishedGoodsInventoryService.addSelectWarehousing(object); |
| | | return null; |
| | | }} |
| | | public String saveWorkStorage(Map<String, Object> object) { |
| | | //List<Map<String, Object>> flowCard = reportingWorkMapper.getStorageData(); |
| | | //finishedGoodsInventoryService.addSelectWarehousing(object); |
| | | return null; |
| | | } |
| | | |
| | | public Map<String, Object> mesBasicDataSv() { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | //工序 |
| | | map.put("process",flowCardMapper.getProcessNameList()); |
| | | //设备下拉框 |
| | | map.put("device", reportingWorkMapper.mesSelectWorkBasicDeviceMp()); |
| | | //班组下拉框 |
| | | map.put("teams", reportingWorkMapper.mesSelectWorkBasicTeamsMp()); |
| | | //次破类型 |
| | | map.put("breakageType", reportingWorkMapper.selectBasicNameByType("breakagetype")); |
| | | //次破原因 |
| | | map.put("breakageReason", reportingWorkMapper.selectBasicNameByType("breakagereason")); |
| | | return map; |
| | | } |
| | | } |