| | |
| | | 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.exception.ServiceException; |
| | | import com.example.erp.mapper.pp.*; |
| | |
| | | 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; |
| | | |
| | |
| | | public Map<String, Object> AddSelectLastWorkSv(String processIdStr, String technologyStr, String process) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | //查询流程卡工艺流程 |
| | | String technologicalProcess = reportingWorkMapper.SelectTechnologicalProcess(processIdStr); |
| | | String technologicalProcess = reportingWorkMapper.SelectTechnologicalProcess(processIdStr,technologyStr); |
| | | |
| | | int index = technologicalProcess.indexOf("-"); |
| | | //获取工艺流程第一个工序 |
| | | String interceptProcess = technologicalProcess.substring(0, index); |
| | | |
| | | |
| | | String[] processList = technologicalProcess.split("->"); |
| | | //获取工艺流程第一个工序 |
| | | String interceptProcess = processList[0]; |
| | | int length = processList.length; |
| | | |
| | | //定义当前工序上下工序 |
| | |
| | | } |
| | | } |
| | | |
| | | //工艺流程 |
| | | map.put("technologicalProcess", technologicalProcess); |
| | | |
| | | //设备下拉框 |
| | | map.put("device", reportingWorkMapper.SelectWorkBasicDeviceMp(process)); |
| | | //班组下拉框 |
| | |
| | | |
| | | //查询本工序报工需要哪几层,上工序是什么 |
| | | String obtainTechnology = reportingWorkMapper.SelectWorkTechnologyMp(processIdStr); |
| | | |
| | | map.put("numberList", flowCardMapper.getGlassNumber(Integer.valueOf(technologyStr),processIdStr)); |
| | | |
| | | //判断本工序是不是第一道工序 |
| | | if (interceptProcess.equals(process)) { |
| | |
| | | map.put("historyTeams", reportingWorkMapper.historyTeamsMp(processIdStr, process)); |
| | | //历史工序 |
| | | map.put("historyProcess", reportingWorkMapper.SelectHistoryProcessMp(historyProcess, process)); |
| | | |
| | | |
| | | return map; |
| | | } |
| | | |
| | |
| | | String formattedDate = dateFormat.format(currentDate); |
| | | 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) { |
| | |
| | | damageDetail.setOrderNumber(reportingWorkDetail.getOrderNumber()); |
| | | damageDetail.setProcessId(reportingWork.getProcessId()); |
| | | damageDetail.setTechnologyNumber(reportingWorkDetail.getTechnologyNumber()); |
| | | if (damageDetail.getResponsibleProcess() != reportingWork.getThisProcess()) { |
| | | if (!damageDetail.getResponsibleProcess().equals(reportingWork.getThisProcess())) { |
| | | damageDetail.setQualityInsStatus(1); |
| | | } |
| | | damageDetailsMapper.insert(damageDetail); |
| | | }); |
| | | } |
| | | //查询流程卡工艺流程 |
| | | String technologicalProcess = reportingWorkMapper.SelectTechnologicalProcess(reportingWork.getProcessId()); |
| | | String technologicalProcess = reportingWorkMapper.SelectTechnologicalProcess(reportingWork.getProcessId(), reportingWorkDetail.getTechnologyNumber()); |
| | | |
| | | int index = technologicalProcess.indexOf("-"); |
| | | //获取工艺流程第一个工序 |
| | | String interceptProcess = technologicalProcess.substring(0, index); |
| | | String interceptProcess = ""; |
| | | if (index <0){ |
| | | interceptProcess = technologicalProcess; |
| | | } |
| | | else { |
| | | //获取工艺流程第一个工序 |
| | | interceptProcess = technologicalProcess.substring(0, index); |
| | | } |
| | | |
| | | |
| | | //判断当前工序是否为第一道工序工序,使用流程卡表数量或者小片流程表上工序数量 |
| | | int processNum = 0; |
| | |
| | | //根据订单id,订单序号,以及小片序号 更新小片流程的完工数量以及刺破数量 |
| | | LambdaUpdateWrapper<OrderProcessDetail> updateWrapper = new LambdaUpdateWrapper<>(); |
| | | updateWrapper.eq(OrderProcessDetail::getOrderNumber, reportingWorkDetail.getOrderNumber()) |
| | | .eq(OrderProcessDetail::getProcessId, reportingWork.getProcessId().substring(0, 13)) |
| | | .eq(OrderProcessDetail::getProcessId, reportingWork.getProcessId().substring(0, 14)) |
| | | .eq(OrderProcessDetail::getOrderId, reportingWork.getOrderId()) |
| | | .eq(OrderProcessDetail::getProcess, reportingWork.getThisProcess()) |
| | | .eq(OrderProcessDetail::getTechnologyNumber, reportingWorkDetail.getTechnologyNumber()) |
| | |
| | | public boolean ReviewReportingWorkSv(Map<String, String> reportingWork) { |
| | | |
| | | String processId = reportingWork.get("processId"); |
| | | String thisProcess = reportingWork.get("thisProcess"); |
| | | int index = processId.lastIndexOf("/") + 1; |
| | | String result = processId.substring(index); |
| | | |
| | | LambdaUpdateWrapper |
| | | if (thisProcess.equals("夹胶") || thisProcess.equals("中空") || thisProcess.equals("仓储")){ |
| | | LambdaUpdateWrapper |
| | | <ReportingWork> updateWrapper = new LambdaUpdateWrapper<>(); |
| | | updateWrapper |
| | | .eq(ReportingWork::getProcessId, processId.substring(0, 13)) |
| | | .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); |
| | | }else { |
| | | reportingWorkMapper.ReviewReportingWorkMp(processId.substring(0, 14),reportingWork.get("process"),result); |
| | | |
| | | |
| | | } |
| | | return true; |
| | | } |
| | | |
| | |
| | | .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<>(); |
| | |
| | | .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)); |
| | | map.put("numberList", flowCardMapper.getGlassNumber(reportingWorkMapper.selectLayerByReportingWorkId(reportingWorkId),reportingWork.getProcessId())); |
| | | |
| | | return map; |
| | | |
| | |
| | | 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>() |
| | |
| | | //更细报工主表 |
| | | reportingWorkMapper.updateById(reportingWork); |
| | | reportingWorkDetails.forEach(reportingWorkDetail -> { |
| | | reportingWorkDetail.setReportingWorkId(reportingWork.getReportingWorkId()); |
| | | List<DamageDetails> damageDetails = reportingWorkDetail.getDamageDetails(); |
| | | //每一条报工数据循环插入次破明细表 |
| | | if (damageDetails != null && !damageDetails.isEmpty()) { |
| | |
| | | } |
| | | //插入报工数据 |
| | | 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")) { |
| | |
| | | } |
| | | |
| | | //修改小片流程表数量为报工明细表数量 |
| | | orderProcessDetailMapper.updateQuantity(reportingWork.getReportingWorkId(), reportingWork.getThisProcess(), "add"); |
| | | //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 (orderId.equals("null")) { |
| | | if ("null".equals(orderId)) { |
| | | orderId = ""; |
| | | } |
| | | Map<String, Object> map = new HashMap<>(); |
| | |
| | | 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) { |
| | | //获取是否有已补片或返工 |
| | | Integer countStates= Integer.valueOf(reportingWorkMapper.getPatchConditionMp(reportingWorkId)); |
| | | //判断是否有补片返工数据 |
| | | if (countStates==0){ |
| | | //判断是否是入库工序 |
| | | 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.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); |
| | | } |
| | |
| | | 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; |
| | | } |
| | | |
| | | } 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 (processId.equals("null")) { |
| | | if ("null".equals(processId)) { |
| | | processId = ""; |
| | | } |
| | | Map<String, Object> map = new HashMap<>(); |
| | |
| | | |
| | | return map; |
| | | } |
| | | |
| | | public String getPatchConditionSv(String reportingWorkId) { |
| | | String count=reportingWorkMapper.getPatchConditionMp(reportingWorkId); |
| | | return count; |
| | | } |
| | | } |