| | |
| | | package com.example.erp.service.pp; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper; |
| | | import com.example.erp.common.Constants; |
| | | import com.example.erp.entity.pp.DamageDetails; |
| | | import com.example.erp.entity.pp.FlowCard; |
| | | 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.example.erp.exception.ServiceException; |
| | | import com.example.erp.mapper.pp.*; |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.example.erp.mapper.sd.OrderMapper; |
| | | 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; |
| | | import java.time.LocalDateTime; |
| | | import java.util.*; |
| | | |
| | | @Service |
| | | @DS("pp") |
| | |
| | | final |
| | | DamageDetailsMapper damageDetailsMapper; |
| | | final |
| | | OrderProcessDetailMapper orderProcessDetailMapper; |
| | | final |
| | | ReportingWorkDetailMapper |
| | | reportingWorkDetailMapper; |
| | | reportingWorkDetailMapper; |
| | | final OrderMapper |
| | | orderMapper; |
| | | |
| | | final |
| | | FlowCardMapper flowCardMapper; |
| | | |
| | | final |
| | | OrderProcessDetailService orderProcessDetailService; |
| | | |
| | | |
| | | public ReportingWorkService(ReportingWorkMapper reportingWorkMapper, BasicDateProduceMapper basicDateProduceMapper, DamageDetailsMapper damageDetailsMapper, ReportingWorkDetailMapper reportingWorkDetailMapper) { |
| | | public ReportingWorkService(ReportingWorkMapper reportingWorkMapper, BasicDateProduceMapper basicDateProduceMapper, DamageDetailsMapper damageDetailsMapper, ReportingWorkDetailMapper reportingWorkDetailMapper, OrderProcessDetailMapper orderProcessDetailMapper, OrderProcessDetailService orderProcessDetailService, OrderMapper orderMapper, FlowCardMapper flowCardMapper) { |
| | | this.reportingWorkMapper = reportingWorkMapper; |
| | | this.basicDateProduceMapper = basicDateProduceMapper; |
| | | this.damageDetailsMapper = damageDetailsMapper; |
| | | this.reportingWorkDetailMapper = reportingWorkDetailMapper; |
| | | this.orderProcessDetailMapper = orderProcessDetailMapper; |
| | | this.orderProcessDetailService = orderProcessDetailService; |
| | | this.orderMapper = orderMapper; |
| | | this.flowCardMapper = flowCardMapper; |
| | | } |
| | | |
| | | public Map<String, Object> AddSelectLastWorkSv(String processIdStr, String technologyStr, String process) { |
| | |
| | | //查询流程卡工艺流程 |
| | | String technologicalProcess = reportingWorkMapper.SelectTechnologicalProcess(processIdStr); |
| | | |
| | | int index = technologicalProcess.indexOf("-"); |
| | | //获取工艺流程第一个工序 |
| | | String interceptProcess = technologicalProcess.substring(0, index); |
| | | |
| | | |
| | | String[] processList = technologicalProcess.split("->"); |
| | | //获取工艺流程第一个工序 |
| | | String interceptProcess = processList[0]; |
| | | int length = processList.length; |
| | | |
| | | //定义当前工序上下工序 |
| | |
| | | } 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("data", reportingWorkMapper.AddSelectLastWorkMp(processIdStr, technologyStr, previousProcess, nextProcess, process)); |
| | | map.put("thisProcess", processList); |
| | | break; |
| | | } |
| | |
| | | //班组下拉框 |
| | | map.put("teams", reportingWorkMapper.SelectWorkBasicTeamsMp(process)); |
| | | |
| | | map.put("breakageType",reportingWorkMapper.selectBasicNameByType("breakagetype")); |
| | | map.put("breakageReason",reportingWorkMapper.selectBasicNameByType("breakagereason")); |
| | | map.put("breakageType", reportingWorkMapper.selectBasicNameByType("breakagetype")); |
| | | map.put("breakageReason", reportingWorkMapper.selectBasicNameByType("breakagereason")); |
| | | |
| | | //查询本工序报工需要哪几层,上工序是什么 |
| | | String obtainTechnology = reportingWorkMapper.SelectWorkTechnologyMp(processIdStr); |
| | | String obtainTechnology = reportingWorkMapper.SelectWorkTechnologyMp(processIdStr); |
| | | |
| | | //判断本工序是不是第一道工序 |
| | | if (interceptProcess.equals(process)) { |
| | | //是第一道工序,查询流程卡数据 |
| | | map.put("Detail", reportingWorkMapper.SelectTechnologicalNumMp(processIdStr,technologyStr)); |
| | | } |
| | | else { |
| | | map.put("Detail", reportingWorkMapper.SelectTechnologicalNumMp(processIdStr, technologyStr, process)); |
| | | } else { |
| | | //不是第一道工序,查询报工数据 |
| | | map.put("Detail", reportingWorkMapper.SelectReworlDetailMp(processIdStr,technologyStr,previousProcess)); |
| | | map.put("Detail", reportingWorkMapper.SelectReworlDetailMp(processIdStr, technologyStr, process)); |
| | | } |
| | | |
| | | // 第一道工序(流程卡数+补片数量-完工数-次破数-返工未完成数-禁用数量) |
| | |
| | | // 后续工序(上工序报工数-完工数-次破数-返工未完成数) |
| | | |
| | | //获取该流程卡号历史报工工序 |
| | | String historyProcess =reportingWorkMapper.historyProcessMp(processIdStr); |
| | | String historyProcess = reportingWorkMapper.historyProcessMp(processIdStr); |
| | | //历史报工工序设备 |
| | | map.put("historyDevice",reportingWorkMapper.historyDeviceMp(historyProcess,process)); |
| | | map.put("historyDevice", reportingWorkMapper.historyDeviceMp(historyProcess, process)); |
| | | //历史报工工序班组 |
| | | map.put("historyTeams",reportingWorkMapper.historyTeamsMp(processIdStr,process)); |
| | | map.put("historyTeams", reportingWorkMapper.historyTeamsMp(processIdStr, process)); |
| | | //历史工序 |
| | | map.put("historyProcess",reportingWorkMapper.SelectHistoryProcessMp(historyProcess,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(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); |
| | | //System.out.println(reportingWork); |
| | | String formattedNumber = String.format("%04d", reportingWorkMapper.selectMaxReportingWorkId()+1); |
| | | //获取当前最大报工单号生成报工单号 |
| | | 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; |
| | | String reportingWorkId = "BG" + formattedDate + formattedNumber; |
| | | reportingWork.setReportingWorkId(reportingWorkId); |
| | | reportingWork.setProcessId(reportingWork.getProcessId().substring(0,13)); |
| | | reportingWork.setProcessId(reportingWork.getProcessId().substring(0, 14)); |
| | | |
| | | int reviewState = (int) reportingWorkJson.get("type"); |
| | | if (reviewState == 1) { |
| | | reportingWork.setReviewed(reportingWork.getCreator()); |
| | | reportingWork.setReviewedState(1); |
| | | } else { |
| | | reportingWork.setReviewedState(0); |
| | | } |
| | | //主表插入 |
| | | reportingWorkMapper.insert(reportingWork); |
| | | |
| | | //副表循环插入,并且插入次破信息表。再根据次破信息修改订单玻璃流程表的完工数量与刺破数量 |
| | | reportingWorkDetails.forEach(reportingWorkDetail -> { |
| | | // reportingWork.setThisProcessQuantity( |
| | | // reportingWork.getThisProcessQuantity() |
| | | // +reportingWorkDetail.getCompletedQuantity() |
| | | // +reportingWorkDetail.getBreakageQuantity()); |
| | | // reportingWork.setThisCompletedQuantity( |
| | | // reportingWork.getThisCompletedQuantity()+reportingWorkDetail.getCompletedQuantity()); |
| | | // reportingWork.setThisWornQuantity( |
| | | // reportingWork.getThisWornQuantity()+reportingWorkDetail.getBreakageQuantity()); |
| | | |
| | | |
| | | reportingWorkDetail.setReportingWorkId(reportingWorkId); |
| | | List<DamageDetails> damageDetails = reportingWorkDetail.getDamageDetails(); |
| | | if(damageDetails!=null && !damageDetails.isEmpty()){ |
| | | damageDetails.forEach(damageDetail ->{ |
| | | //次破明细表插入数据 |
| | | 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())) { |
| | | damageDetail.setQualityInsStatus(1); |
| | | } |
| | | damageDetailsMapper.insert(damageDetail); |
| | | }); |
| | | } |
| | | //System.out.println(reportingWorkDetail); |
| | | reportingWorkDetailMapper.insert(reportingWorkDetail); |
| | | //查询流程卡工艺流程 |
| | | String technologicalProcess = reportingWorkMapper.SelectTechnologicalProcess(reportingWork.getProcessId()); |
| | | |
| | | int index = technologicalProcess.indexOf("-"); |
| | | //获取工艺流程第一个工序 |
| | | String 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()); |
| | | |
| | | //根据订单id,订单序号,以及小片序号 更新小片流程的完工数量以及刺破数量 |
| | | LambdaUpdateWrapper<OrderProcessDetail> updateWrapper = new LambdaUpdateWrapper<>(); |
| | | updateWrapper.eq(OrderProcessDetail::getOrderNumber, reportingWorkDetail.getOrderNumber()) |
| | | .eq(OrderProcessDetail::getProcessId, reportingWork.getProcessId().substring(0, 14)) |
| | | .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("broken_num =broken_num +" + orderProcessDetail.getBrokenNum()); |
| | | orderProcessDetailMapper.update(null, updateWrapper); |
| | | |
| | | //判断完工数量和刺破数量是否为0,为0则不插入到数据库 |
| | | if (!(reportingWorkDetail.getCompletedQuantity() == 0 && reportingWorkDetail.getBreakageQuantity() == 0)) { |
| | | reportingWorkDetailMapper.insert(reportingWorkDetail); |
| | | } |
| | | |
| | | //更新流程卡表的报工数量 |
| | | if (Objects.equals(reportingWork.getNextProcess(), "")) { |
| | | 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); |
| | | } |
| | | |
| | | |
| | | }); |
| | | |
| | | return true; |
| | | } |
| | | |
| | | //下工序审核方法 |
| | | public boolean ReviewReportingWorkSv(Map<String, String> reportingWork) { |
| | | |
| | | String processId = reportingWork.get("processId"); |
| | | |
| | | LambdaUpdateWrapper |
| | | <ReportingWork> updateWrapper = new LambdaUpdateWrapper<>(); |
| | | updateWrapper |
| | | .eq(ReportingWork::getProcessId, processId.substring(0, 14)) |
| | | .eq(ReportingWork::getThisProcess, reportingWork.get("process")) |
| | | .eq(ReportingWork::getReviewedState, 0) |
| | | .setSql("reviewed_state =1"); |
| | | reportingWorkMapper.update(null, updateWrapper); |
| | | |
| | | |
| | | return true; |
| | | } |
| | | |
| | | //报工修改查询 |
| | | public Map<String, Object> selectUpdateReportingWorkSv(String reportingWorkId) { |
| | | //查询报工主表信息 |
| | | ReportingWork reportingWork = reportingWorkMapper.selectOne(new LambdaQueryWrapper<ReportingWork>() |
| | | .eq(ReportingWork::getReportingWorkId, reportingWorkId)); |
| | | //根据报工信息查询订单主表信息 |
| | | reportingWork.setOrder( |
| | | orderMapper.selectOne(new LambdaQueryWrapper<Order>() |
| | | .eq(Order::getOrderId, reportingWork.getOrderId()))); |
| | | reportingWork.setFlowCard(new FlowCard()); |
| | | |
| | | List<Map<String, Object>> reportingWorkDetails = reportingWorkMapper.selectByReportingWorkId(reportingWorkId, reportingWork.getNextProcess()); |
| | | reportingWorkDetails.forEach(reportingWorkDetail -> { |
| | | List<DamageDetails> damageDetailsList = new ArrayList<>(); |
| | | damageDetailsList = damageDetailsMapper.selectList(new LambdaQueryWrapper<DamageDetails>() |
| | | .eq(DamageDetails::getReportingWorkId, reportingWorkId) |
| | | .eq(DamageDetails::getOrderNumber, reportingWorkDetail.get("order_number")) |
| | | .eq(DamageDetails::getTechnologyNumber, reportingWorkDetail.get("technology_number")) |
| | | ); |
| | | reportingWorkDetail.put("damageDetails", damageDetailsList); |
| | | }); |
| | | |
| | | |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("reportingWork", reportingWork); |
| | | map.put("reportingWorkDetails", reportingWorkDetails); |
| | | map.put("basic", getReportingWorkBase(reportingWork.getProcessId(), reportingWork.getThisProcess())); |
| | | //根据报工编号获取层 |
| | | map.put("layer", reportingWorkMapper.selectLayerByReportingWorkId(reportingWorkId)); |
| | | |
| | | return false; |
| | | |
| | | return map; |
| | | |
| | | } |
| | | |
| | | //报工下拉框数据 |
| | | private Map<String, Object> getReportingWorkBase(String processId, String thisProcess) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | //设备下拉框 |
| | | map.put("deviceType", reportingWorkMapper.SelectWorkBasicDeviceMp(thisProcess)); |
| | | //班组下拉框 |
| | | map.put("teamsType", reportingWorkMapper.SelectWorkBasicTeamsMp(thisProcess)); |
| | | |
| | | map.put("breakageType", reportingWorkMapper.selectBasicNameByType("breakagetype")); |
| | | map.put("breakageReason", reportingWorkMapper.selectBasicNameByType("breakagereason")); |
| | | |
| | | //获取该流程卡号历史报工工序 |
| | | String historyProcess = reportingWorkMapper.historyProcessMp(processId); |
| | | //历史报工工序设备 |
| | | map.put("historyDevice", reportingWorkMapper.historyDeviceMp(historyProcess, thisProcess)); |
| | | //历史报工工序班组 |
| | | map.put("historyTeams", reportingWorkMapper.historyTeamsMp(processId, thisProcess)); |
| | | //历史工序 |
| | | map.put("historyProcess", reportingWorkMapper.SelectHistoryProcessMp(historyProcess, thisProcess)); |
| | | |
| | | return map; |
| | | } |
| | | |
| | | |
| | | @Transactional |
| | | //报工修改 |
| | | public Boolean updateReportingWork(Map<String, Object> reportingWorkMap, String reviewState) { |
| | | //接收解析主附表信息 |
| | | 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); |
| | | |
| | | //删除刺破明细表刺破数据 |
| | | damageDetailsMapper.delete( |
| | | new LambdaQueryWrapper<DamageDetails>() |
| | | .eq(DamageDetails::getReportingWorkId, reportingWork.getReportingWorkId()) |
| | | ); |
| | | //修改小片流程表数量 |
| | | orderProcessDetailMapper.updateQuantity(reportingWork.getReportingWorkId(), reportingWork.getThisProcess(), "delete"); |
| | | //删除报工明细表数据 |
| | | reportingWorkDetailMapper |
| | | .delete(new LambdaQueryWrapper<ReportingWorkDetail>() |
| | | .eq(ReportingWorkDetail::getReportingWorkId, reportingWork.getReportingWorkId())); |
| | | |
| | | //更细报工主表 |
| | | reportingWorkMapper.updateById(reportingWork); |
| | | reportingWorkDetails.forEach(reportingWorkDetail -> { |
| | | reportingWorkDetail.setReportingWorkId(reportingWork.getReportingWorkId()); |
| | | List<DamageDetails> damageDetails = reportingWorkDetail.getDamageDetails(); |
| | | //每一条报工数据循环插入次破明细表 |
| | | if (damageDetails != null && !damageDetails.isEmpty()) { |
| | | damageDetails.forEach(damageDetail -> { |
| | | if (!Objects.equals(reportingWork.getThisProcess(), damageDetail.getResponsibleProcess())) { |
| | | damageDetail.setQualityInsStatus(1); |
| | | } |
| | | if (Objects.equals(reviewState, "review")) { |
| | | damageDetail.setQualityInsStatus(2); |
| | | } |
| | | |
| | | damageDetailsMapper.insert(damageDetail); |
| | | }); |
| | | } |
| | | //插入报工数据 |
| | | reportingWorkDetailMapper.insert(reportingWorkDetail); |
| | | orderProcessDetailMapper.insertByReportingWorkDetail(reportingWorkDetail,reportingWork.getProcessId(),reportingWork.getThisProcess()); |
| | | //修改包装时修改库存数量 |
| | | if (reportingWork.getNextProcess()==null || reportingWork.getNextProcess().isEmpty()){ |
| | | //获取该报工修改后的可入库数量 |
| | | Integer inventory = reportingWorkDetailMapper.selectInventory(reportingWork.getProcessId(),Integer.parseInt(reportingWorkDetail.getOrderNumber()),Integer.parseInt(reportingWorkDetail.getTechnologyNumber())); |
| | | //修改流程卡表库存数量 |
| | | flowCardMapper.updateInventory(reportingWork.getProcessId(),reportingWorkDetail.getOrderNumber(),reportingWorkDetail.getTechnologyNumber(),inventory); |
| | | } |
| | | }); |
| | | //获取质检时间 |
| | | if (Objects.equals(reviewState, "review")) { |
| | | LocalDateTime |
| | | currentDate = LocalDateTime.now(); |
| | | reportingWork.setQualityInsTime(currentDate); |
| | | reportingWorkMapper.updateById(reportingWork); |
| | | } |
| | | |
| | | //修改小片流程表数量为报工明细表数量 |
| | | //orderProcessDetailMapper.updateQuantity(reportingWork.getReportingWorkId(), reportingWork.getThisProcess(), "add"); |
| | | return true; |
| | | } |
| | | |
| | | //报工管理查询 |
| | | public Map<String, Object> selectReportingWorkSv(Integer pageNum, Integer pageSize, java.sql.Date selectTime1, java.sql.Date selectTime2, String orderId, ReportingWork reportingWork) { |
| | | Integer offset = (pageNum - 1) * pageSize; |
| | | if ("null".equals(orderId)) { |
| | | orderId = ""; |
| | | } |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("data", reportingWorkMapper.selectReportingWorkMp(offset, pageSize, selectTime1, selectTime2, orderId, reportingWork)); |
| | | map.put("total", reportingWorkMapper.getPageTotal(offset, pageSize, selectTime1, selectTime2, orderId, reportingWork)); |
| | | return map; |
| | | } |
| | | |
| | | //删除报工 |
| | | public Boolean deleteWorkSv(String reportingWorkId, String processId, String thisProcess) { |
| | | if (!reportingWorkId.isEmpty() && !processId.isEmpty() && !thisProcess.isEmpty()) { |
| | | //获取当前报工编号下工序 |
| | | String nextProcess = reportingWorkMapper.selectNextProcess(reportingWorkId); |
| | | //查询当前报工编号下工序是否报工 |
| | | Integer count = reportingWorkMapper.selectCountByProcessId(processId, nextProcess); |
| | | //获取最后一道工序 |
| | | String lastProcess = reportingWorkMapper.selectLastProcess(processId); |
| | | //判断是否是入库工序 |
| | | if (lastProcess.equals(thisProcess)) {//是入库工序 |
| | | //查询该流程卡数量、可入库数量、已入库数量 |
| | | Map<String, Object> list = reportingWorkMapper.selectReceiptQuantity(processId); |
| | | if (list.get("quantity") == list.get("receiptQuantity")) { |
| | | return false; |
| | | } else { |
| | | //转换类型:已入库数量 |
| | | Integer receiptQuantity = Integer.parseInt(list.get("receivedQuantity").toString()); |
| | | //转换类型:可入库数量 |
| | | Integer inventoryQuantity = Integer.parseInt(list.get("inventoryQuantity").toString()); |
| | | //查询该报工编号本工序完工数量 |
| | | Integer completedQuantity = reportingWorkMapper.selectCompletedQuantity(reportingWorkId); |
| | | //当该工序完工数量小于等于已入库数量时 |
| | | //可入库数量-已入库数量>=报工编号本工序完工数量 |
| | | if (inventoryQuantity - receiptQuantity >= completedQuantity) { |
| | | //查询当前报工编号完工次破数量的数据 |
| | | List<Map<String, Object>> workDateList = reportingWorkMapper.reportingWorkDate(reportingWorkId); |
| | | for (Map<String, Object> item : workDateList) { |
| | | //更新流程卡可入库数量 |
| | | reportingWorkMapper.updateInventoryQuantity(processId, item.get("order_number"), item.get("technology_number"), item.get("completed_quantity")); |
| | | //更新报工流程表数据 |
| | | reportingWorkMapper.updateWorkProcess(processId, item.get("order_number"), item.get("technology_number"), item.get("completed_quantity"), item.get("breakage_quantity"), thisProcess); |
| | | } |
| | | //删除报工,将审核状态改为-1 |
| | | reportingWorkMapper.deleteWork(reportingWorkId); |
| | | return true; |
| | | } else { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | } else {//不是入库工序 |
| | | if (count == 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); |
| | | return true; |
| | | } else { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | |
| | | } else { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | //查询质检审核 |
| | | public Map<String, Object> selectQualityTestingSv(Integer pageNum, Integer pageSize, java.sql.Date selectTime1, java.sql.Date selectTime2, Integer state, String processId, ReportingWork reportingWork) { |
| | | Integer offset = (pageNum - 1) * pageSize; |
| | | if ("null".equals(processId)) { |
| | | processId = ""; |
| | | } |
| | | 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)); |
| | | |
| | | return map; |
| | | } |
| | | |
| | | //修改质检审核状态 |
| | | public Boolean updateQualityStatusSv(String reportingWorkId, String username) { |
| | | if (!reportingWorkId.isEmpty()) { |
| | | reportingWorkMapper.updateQualityStatusMp(reportingWorkId, username); |
| | | return true; |
| | | } else { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | //查询质检明细(未使用) |
| | | public Map<String, Object> detailsQualitySv(String reportingWorkId, String processId, String thisProcess, ReportingWork reportingWork) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("data", reportingWorkMapper.detailsQualityMp(reportingWorkId, reportingWork)); |
| | | map.put("basic", getReportingWorkBase(processId, thisProcess)); |
| | | |
| | | return map; |
| | | } |
| | | } |