New file |
| | |
| | | |
| | | package com.example.erp.service.pp; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.example.erp.entity.sd.OrderDetail; |
| | | import com.example.erp.entity.sd.OrderGlassDetail; |
| | | import com.example.erp.mapper.pp.WorkOrderMapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.sql.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Service |
| | | @DS("sd") |
| | | public class WorkOrderService { |
| | | @Autowired |
| | | WorkOrderMapper workOrderMapper; |
| | | |
| | | //查询工单 |
| | | public Map<String, Object> defaultDateWork(Date selectTime1, Date selectTime2, Integer state, OrderGlassDetail orderGlassDetail) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | if (state == 1) { |
| | | map.put("data", workOrderMapper.selectWordOrder(selectTime1, selectTime2, orderGlassDetail)); |
| | | } else { |
| | | map.put("data", workOrderMapper.selectWordOrderNo(selectTime1, selectTime2, orderGlassDetail)); |
| | | } |
| | | |
| | | return map; |
| | | } |
| | | |
| | | //转生产订单查询 |
| | | public Map<String, Object> addDateWork(String orderId, OrderDetail orderDetail) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("data", workOrderMapper.addWordOrder(orderId, orderDetail)); |
| | | return map; |
| | | } |
| | | |
| | | //新增生产订单 |
| | | public Boolean addOrderWorkSv(Map<String, Object> object) { |
| | | String userName = ""; |
| | | if (object.get("userName") != null) { |
| | | userName = object.get("userName").toString(); |
| | | } |
| | | |
| | | //定义生产订单号生成需要的条件 |
| | | char lettr = 'A'; |
| | | char letters = '1'; |
| | | int count = 25; |
| | | String productIdVl = ""; |
| | | //将接收到的信息解析成list |
| | | List<OrderDetail> orderDetaillist = JSONArray.parseArray(JSONObject.toJSONString(object.get("orderdetail")), OrderDetail.class); |
| | | String orderId = orderDetaillist.get(0).getOrderId(); |
| | | |
| | | for (OrderDetail orderDetail : orderDetaillist) { |
| | | //生成生产订单号 |
| | | for (int i = 0; i < count; i++) { |
| | | letters = lettr++; |
| | | productIdVl = orderId + letters; |
| | | //查询生成的生产订单号是否存在 |
| | | Integer workCount = workOrderMapper.selectOrderNumber(productIdVl); |
| | | if (workCount < 1) { |
| | | break; |
| | | } |
| | | |
| | | } |
| | | //添加生产订单 |
| | | workOrderMapper.addOrderWorkMp(productIdVl, orderDetail.getOrderId(), orderDetail.getProductId(), orderDetail.getProductName(), userName); |
| | | Integer state = 2; |
| | | Integer states = 1; |
| | | //查询该订单未转生产订单的条数 |
| | | Integer noWorkCount = workOrderMapper.selectWorkCount(orderDetail.getOrderId()); |
| | | if (noWorkCount == 0) { |
| | | //条数为0修改转生产订单状态为2,否则为1 |
| | | workOrderMapper.updateWorkType(orderDetail.getOrderId(), state); |
| | | } else { |
| | | workOrderMapper.updateWorkType(orderDetail.getOrderId(), states); |
| | | } |
| | | } |
| | | return true; |
| | | |
| | | } |
| | | |
| | | //删除生产订单 |
| | | public Boolean deleteOrderWorkSv(String orderId, String productionId) { |
| | | if (!orderId.isEmpty() && !productionId.isEmpty()) { |
| | | //查询该订单是否已经建立流程卡 |
| | | Integer getProcessCard = workOrderMapper.selectProcessCard(orderId); |
| | | if (getProcessCard == 0){ |
| | | //删除订单小片表生产订单号 |
| | | workOrderMapper.deleteOrderWorkMp(orderId, productionId); |
| | | int state = 0; |
| | | int states = 1; |
| | | //查询该订单未转生产订单的条数 |
| | | Integer noWorkCount = workOrderMapper.selectWorkCount(orderId); |
| | | //查询该订单转生产订单的条数 |
| | | Integer yesWorkCount = workOrderMapper.selectYesWorkCount(orderId); |
| | | if (noWorkCount.equals(yesWorkCount)) { |
| | | workOrderMapper.updateWorkType(orderId, state); |
| | | } else { |
| | | workOrderMapper.updateWorkType(orderId, states); |
| | | } |
| | | return true; |
| | | } |
| | | else { |
| | | return false; |
| | | } |
| | | |
| | | } else { |
| | | return false; |
| | | } |
| | | } |
| | | } |