New file |
| | |
| | | package com.example.erp.service.pp; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper; |
| | | import com.example.erp.entity.pp.DamageDetails; |
| | | import com.example.erp.entity.pp.ReportingWork; |
| | | import com.example.erp.entity.pp.ReportingWorkDetail; |
| | | 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.mapper.pp.BasicDateProduceMapper; |
| | | import com.example.erp.mapper.pp.DamageDetailsMapper; |
| | | import com.example.erp.mapper.pp.ReportingWorkDetailMapper; |
| | | import com.example.erp.mapper.pp.ReportingWorkMapper; |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.example.erp.mapper.sd.OrderProcessDetailMapper; |
| | | import com.example.erp.service.sd.OrderProcessDetailService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Service |
| | | @DS("pp") |
| | | public class ReportingWorkService { |
| | | final |
| | | ReportingWorkMapper reportingWorkMapper; |
| | | final |
| | | BasicDateProduceMapper basicDateProduceMapper; |
| | | final |
| | | DamageDetailsMapper damageDetailsMapper; |
| | | final |
| | | OrderProcessDetailMapper orderProcessDetailMapper; |
| | | final |
| | | ReportingWorkDetailMapper |
| | | reportingWorkDetailMapper; |
| | | |
| | | final |
| | | OrderProcessDetailService orderProcessDetailService; |
| | | |
| | | |
| | | |
| | | public ReportingWorkService(ReportingWorkMapper reportingWorkMapper, BasicDateProduceMapper basicDateProduceMapper, DamageDetailsMapper damageDetailsMapper, ReportingWorkDetailMapper reportingWorkDetailMapper, OrderProcessDetailMapper orderProcessDetailMapper, OrderProcessDetailService orderProcessDetailService) { |
| | | this.reportingWorkMapper = reportingWorkMapper; |
| | | this.basicDateProduceMapper = basicDateProduceMapper; |
| | | this.damageDetailsMapper = damageDetailsMapper; |
| | | this.reportingWorkDetailMapper = reportingWorkDetailMapper; |
| | | this.orderProcessDetailMapper = orderProcessDetailMapper; |
| | | this.orderProcessDetailService = orderProcessDetailService; |
| | | } |
| | | |
| | | public Map<String, Object> AddSelectLastWorkSv(String processIdStr, String technologyStr, String process) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | //查询流程卡工艺流程 |
| | | String technologicalProcess = reportingWorkMapper.SelectTechnologicalProcess(processIdStr); |
| | | |
| | | int index = technologicalProcess.indexOf("-"); |
| | | //获取工艺流程第一个工序 |
| | | String interceptProcess = technologicalProcess.substring(0, index); |
| | | String[] processList = technologicalProcess.split("->"); |
| | | int length = processList.length; |
| | | |
| | | //定义当前工序上下工序 |
| | | String previousProcess = ""; |
| | | String nextProcess = ""; |
| | | |
| | | //循环该流程卡工艺流程 |
| | | for (int i = 0; i < length; i++) { |
| | | //当到当前工序时 |
| | | if (processList[i].equals(process)) { |
| | | //获取当前工序的上一道工序 |
| | | if (i - 1 < 0) { |
| | | previousProcess = ""; |
| | | } else { |
| | | previousProcess = processList[i - 1]; |
| | | } |
| | | //获取当前工序的下一道工序 |
| | | if (i + 1 > length - 1) { |
| | | nextProcess = ""; |
| | | } else { |
| | | nextProcess = processList[i + 1]; |
| | | } |
| | | //System.out.println("当前工序:" + process + " 上一道工序:" + previousProcess + " 下一道工序:" + nextProcess); |
| | | //查询当前工序的表头数据 |
| | | // System.out.println(reportingWorkMapper.AddSelectLastWorkMp(processIdStr, technologyStr,previousProcess,nextProcess,process)); |
| | | map.put("data", reportingWorkMapper.AddSelectLastWorkMp(processIdStr, technologyStr,previousProcess,nextProcess,process)); |
| | | map.put("thisProcess", processList); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | //设备下拉框 |
| | | map.put("device", reportingWorkMapper.SelectWorkBasicDeviceMp(process)); |
| | | //班组下拉框 |
| | | map.put("teams", reportingWorkMapper.SelectWorkBasicTeamsMp(process)); |
| | | |
| | | map.put("breakageType",reportingWorkMapper.selectBasicNameByType("breakagetype")); |
| | | map.put("breakageReason",reportingWorkMapper.selectBasicNameByType("breakagereason")); |
| | | |
| | | //查询本工序报工需要哪几层,上工序是什么 |
| | | String obtainTechnology = reportingWorkMapper.SelectWorkTechnologyMp(processIdStr); |
| | | |
| | | //判断本工序是不是第一道工序 |
| | | if (interceptProcess.equals(process)) { |
| | | //是第一道工序,查询流程卡数据 |
| | | map.put("Detail", reportingWorkMapper.SelectTechnologicalNumMp(processIdStr,technologyStr,process)); |
| | | } |
| | | else { |
| | | //不是第一道工序,查询报工数据 |
| | | map.put("Detail", reportingWorkMapper.SelectReworlDetailMp(processIdStr,technologyStr,previousProcess)); |
| | | } |
| | | |
| | | // 第一道工序(流程卡数+补片数量-完工数-次破数-返工未完成数-禁用数量) |
| | | |
| | | // 后续工序(上工序报工数-完工数-次破数-返工未完成数) |
| | | |
| | | //获取该流程卡号历史报工工序 |
| | | String historyProcess =reportingWorkMapper.historyProcessMp(processIdStr); |
| | | //历史报工工序设备 |
| | | map.put("historyDevice",reportingWorkMapper.historyDeviceMp(historyProcess,process)); |
| | | //历史报工工序班组 |
| | | map.put("historyTeams",reportingWorkMapper.historyTeamsMp(processIdStr,process)); |
| | | //历史工序 |
| | | map.put("historyProcess",reportingWorkMapper.SelectHistoryProcessMp(historyProcess,process)); |
| | | |
| | | |
| | | |
| | | return map; |
| | | } |
| | | |
| | | public Map<String, Object> SelectProcessSv() { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("process", reportingWorkMapper.SelectProcessMp()); |
| | | return map; |
| | | } |
| | | |
| | | //报工新增 |
| | | @Transactional |
| | | 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); |
| | | reportingWork.setProcessId(reportingWork.getProcessId().substring(0,13)); |
| | | //主表插入 |
| | | reportingWorkMapper.insert(reportingWork); |
| | | |
| | | //副表循环插入,并且插入次破信息表。再根据次破信息修改订单玻璃流程表的完工数量与刺破数量 |
| | | reportingWorkDetails.forEach(reportingWorkDetail -> { |
| | | reportingWorkDetail.setReportingWorkId(reportingWorkId); |
| | | List<DamageDetails> damageDetails = reportingWorkDetail.getDamageDetails(); |
| | | if(damageDetails!=null && !damageDetails.isEmpty()){ |
| | | damageDetails.forEach(damageDetail ->{ |
| | | damageDetail.setReportingWorkId(reportingWorkId); |
| | | damageDetail.setOrderNumber(reportingWorkDetail.getOrderNumber()); |
| | | damageDetail.setProcessId(reportingWork.getProcessId()); |
| | | damageDetail.setTechnologyNumber(reportingWorkDetail.getTechnologyNumber()); |
| | | damageDetailsMapper.insert(damageDetail); |
| | | }); |
| | | } |
| | | //System.out.println(reportingWorkDetail); |
| | | OrderProcessDetail orderProcessDetail = new OrderProcessDetail(); |
| | | orderProcessDetail.setBrokenNum(reportingWorkDetail.getBreakageQuantity()); |
| | | orderProcessDetail.setReportingWorkNum(reportingWorkDetail.getCompletedQuantity()); |
| | | orderProcessDetail.setReportingWorkNumCount(reportingWorkDetail.getCompletedQuantity()); |
| | | |
| | | //根据订单id,订单序号,以及小片序号 更新小片流程的完工数量以及刺破数量 |
| | | LambdaUpdateWrapper<OrderProcessDetail> updateWrapper = new LambdaUpdateWrapper<>(); |
| | | updateWrapper.eq(OrderProcessDetail::getOrderNumber, reportingWorkDetail.getOrderNumber()) |
| | | .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.getReportingWorkNumCount()) |
| | | .setSql("reporting_work_num =reporting_work_num +"+orderProcessDetail.getReportingWorkNum()) |
| | | .setSql("broken_num =broken_num +"+orderProcessDetail.getBrokenNum()); |
| | | |
| | | orderProcessDetailMapper.update(null,updateWrapper); |
| | | reportingWorkDetailMapper.insert(reportingWorkDetail); |
| | | }); |
| | | return false; |
| | | } |
| | | } |