| | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.example.erp.entity.pp.FlowCard; |
| | | import com.example.erp.entity.sd.Order; |
| | | import com.example.erp.entity.sd.OrderDetail; |
| | | import com.example.erp.entity.pp.ProductionScheduling; |
| | | import com.example.erp.entity.sd.OrderGlassDetail; |
| | | import com.example.erp.entity.sd.OrderProcessDetail; |
| | | import com.example.erp.mapper.pp.FlowCardMapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import com.example.erp.mapper.sd.OrderGlassDetailMapper; |
| | | import com.example.erp.mapper.sd.OrderProcessDetailMapper; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.sql.Date; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import static com.example.erp.service.sd.OrderService.getOrderProcessDetails; |
| | | |
| | | @Service |
| | | @DS("pp") |
| | | public class FlowCardService { |
| | | @Autowired |
| | | final |
| | | FlowCardMapper flowCardMapper; |
| | | final |
| | | OrderGlassDetailMapper orderGlassDetailMapper; |
| | | final |
| | | OrderProcessDetailMapper orderProcessDetailMapper; |
| | | |
| | | public FlowCardService(FlowCardMapper flowCardMapper, OrderGlassDetailMapper orderGlassDetailMapper, OrderProcessDetailMapper orderProcessDetailMapper) { |
| | | this.flowCardMapper = flowCardMapper; |
| | | this.orderGlassDetailMapper = orderGlassDetailMapper; |
| | | this.orderProcessDetailMapper = orderProcessDetailMapper; |
| | | } |
| | | |
| | | //流程卡管理查询 |
| | | public Map<String, Object> selectProcessCard(Date selectTime1, Date selectTime2, FlowCard flowCard) { |
| | | public Map<String, Object> selectProcessCard(Integer pageNum, Integer pageSize, Date selectTime1, Date selectTime2, FlowCard flowCard) { |
| | | Integer offset = (pageNum - 1) * pageSize; |
| | | Map<String, Object> map = new HashMap<>(); |
| | | //System.out.println(flowCardMapper.selectFlowCard( selectTime1,selectTime2, flowCard)); |
| | | map.put("data", flowCardMapper.selectFlowCard(selectTime1, selectTime2, flowCard)); |
| | | map.put("data", flowCardMapper.selectFlowCard(offset, pageSize, selectTime1, selectTime2, flowCard)); |
| | | map.put("total", flowCardMapper.getPageTotal(offset, pageSize, selectTime1, selectTime2, flowCard)); |
| | | return map; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | //分架明细查询 |
| | | public Map<String, Object> DetailsSelectSv(String orderId, FlowCard flowCard) { |
| | | public Map<String, Object> detailsSelectSv(String orderId, FlowCard flowCard) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("data", flowCardMapper.DetailsSelectMp(orderId, flowCard)); |
| | | map.put("data", flowCardMapper.detailsSelectMp(orderId, flowCard)); |
| | | return map; |
| | | } |
| | | |
| | | //删除工单 |
| | | public Boolean DeleteFlowCardSv(String orderId, String processId) { |
| | | //删除流程卡 |
| | | public Boolean deleteFlowCardSv(String orderId, String processId) { |
| | | if (!orderId.isEmpty() && !processId.isEmpty()) { |
| | | Integer count=flowCardMapper.ReportingWorkCount(processId); |
| | | if (count==0){ |
| | | //判断该流程卡是否报工 |
| | | Integer count = flowCardMapper.reportingWorkCount(processId); |
| | | if (count == 0) { |
| | | |
| | | //修改分架状态 |
| | | flowCardMapper.UpdateDeleteState(orderId, processId); |
| | | flowCardMapper.updateDeleteState(orderId, processId); |
| | | //删除报工流程明细表数据 |
| | | flowCardMapper.deleteReportingWork(processId); |
| | | //删除分架明细 |
| | | flowCardMapper.DeleteFlowCardMp(orderId, processId); |
| | | flowCardMapper.deleteFlowCardMp(orderId, processId); |
| | | //判断该订单流程卡是否全部删除 |
| | | Integer flowNumber = flowCardMapper.selectFlowCardCount(orderId); |
| | | if (flowNumber == 0) { |
| | | //修改订单表分架状态为0,全部删除 |
| | | flowCardMapper.updateProcessingCard(orderId, 0); |
| | | } else { |
| | | //修改订单表分架状态为1,删除部分 |
| | | flowCardMapper.updateProcessingCard(orderId, 1); |
| | | } |
| | | return true; |
| | | } |
| | | else { |
| | | } else { |
| | | return false; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | //分架新增明细查询 |
| | | public Map<String, Object> SelectNoCardSv(String orderId, String productionId, FlowCard flowCard) { |
| | | public Map<String, Object> selectNoCardSv(String orderId, String productionId, FlowCard flowCard) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("data", flowCardMapper.SelectNoCardMp(orderId, productionId, flowCard)); |
| | | map.put("data", flowCardMapper.selectNoCardMp(orderId, productionId, flowCard)); |
| | | return map; |
| | | } |
| | | |
| | | |
| | | //修改排版状态 |
| | | public Boolean UpdateLayoutStatusSv(String processId) { |
| | | public Boolean updateLayoutStatusSv(String processId, Integer state) { |
| | | |
| | | if (!processId.isEmpty()) { |
| | | Integer Status = flowCardMapper.SelectLayoutStatus(processId); |
| | | if (Status == 1) { |
| | | flowCardMapper.UpdateLayoutStatusMp(processId); |
| | | } else { |
| | | return false; |
| | | } |
| | | // Integer Status = flowCardMapper.selectLayoutStatus(processId); |
| | | |
| | | flowCardMapper.updateLayoutStatusMp(processId, state); |
| | | |
| | | |
| | | return true; |
| | | } else { |
| | |
| | | } |
| | | } |
| | | |
| | | public Boolean AddFlowCardSv(Map<String, Object> object) { |
| | | //保存流程卡数据 |
| | | public Boolean addFlowCardSv(Map<String, Object> object) { |
| | | String userName = ""; |
| | | if (object.get("userName") != null) { |
| | | userName = object.get("userName").toString(); |
| | |
| | | List<FlowCard> FlowCardList = JSONArray.parseArray(JSONObject.toJSONString(object.get("flowCard")), FlowCard.class); |
| | | if (!FlowCardList.isEmpty()) { |
| | | for (FlowCard flowCard : FlowCardList) { |
| | | //查询每个序号的层数 |
| | | Integer layer = flowCardMapper.selectLayer(productionId, flowCard.getOrderNumber()); |
| | | //添加流程卡数据 |
| | | flowCardMapper.AddFlowCardMp(flowCard.getProcessId(),flowCard.getOrderNumber(),flowCard.getLandingSequence(),flowCard.getQuantity(),productionId,userName); |
| | | flowCardMapper.addFlowCardMp(flowCard.getProcessId(), flowCard.getOrderNumber(), flowCard.getLandingSequence(), flowCard.getQuantity(), productionId, userName, layer); |
| | | //修改分架状态,将状态改为1 |
| | | flowCardMapper.UpdateFlowState(productionId,flowCard.getOrderNumber()); |
| | | flowCardMapper.updateFlowState(productionId, flowCard.getOrderNumber()); |
| | | //查询该订单未分架数量 |
| | | Integer FlowCount= flowCardMapper.SelectFlowCount(productionId); |
| | | Integer FlowCount = flowCardMapper.selectFlowCount(productionId); |
| | | if (FlowCount == 0) { |
| | | //修改订单表分架状态为2 |
| | | flowCardMapper.updateProcessingCard(productionId, 2); |
| | | } else { |
| | | //修改订单表分架状态为1,未全部分架完成 |
| | | flowCardMapper.updateProcessingCard(productionId, 1); |
| | | } |
| | | //查询订单小片表获取工艺传入小片工艺表 |
| | | List<OrderGlassDetail> orderGlassDetailList = |
| | | orderGlassDetailMapper.selectList( |
| | | new QueryWrapper<OrderGlassDetail>() |
| | | .eq("order_id", flowCard.getProcessId().substring(0, 10)) |
| | | .eq("order_number", flowCard.getOrderNumber()) |
| | | ); |
| | | List<OrderProcessDetail> orderProcessDetailList = getOrderProcessDetails(orderGlassDetailList); |
| | | orderProcessDetailList.forEach( |
| | | orderGlassDetail -> orderGlassDetail.setProcessId(flowCard.getProcessId())); |
| | | |
| | | if (FlowCount==0){ |
| | | //修改订单表分架状态为2 |
| | | System.out.println("我来试试1"); |
| | | flowCardMapper.UpdateProcessingCard(productionId,2); |
| | | } |
| | | else{ |
| | | //修改订单表分架状态为1,未全部分架完成 |
| | | System.out.println("我来试试2"); |
| | | flowCardMapper.UpdateProcessingCard(productionId,1); |
| | | } |
| | | |
| | | //赋值订单工艺表 |
| | | orderProcessDetailMapper.insertOrderProcessDetail(orderProcessDetailList); |
| | | } |
| | | return true; |
| | | |
| | | return true; |
| | | } else { |
| | | return false; |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | public Map<String, Object> selectSchedulingSv(String selectTime1, String selectTime2, String orderId, String processes, Integer state, FlowCard flowCard) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | if (state == 2) {//已排产 |
| | | map.put("data", flowCardMapper.selectOkSchedulingMp(selectTime1, selectTime2, orderId, processes, flowCard)); |
| | | |
| | | } else if (state == 1) {//未排产 |
| | | map.put("data", flowCardMapper.selectNoSchedulingMp(selectTime1, selectTime2, orderId, processes, flowCard)); |
| | | |
| | | } |
| | | |
| | | return map; |
| | | } |
| | | |
| | | |
| | | //首次查询排版数据 |
| | | public Map<String, Object> selectLastScheduling(String selectTime1, String selectTime2, FlowCard flowCard) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("data", flowCardMapper.selectLastSchedulingMp(selectTime1, selectTime2, flowCard)); |
| | | return map; |
| | | } |
| | | |
| | | public Object flowCardDetailSv(String processId, FlowCard flowCard) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("data", flowCardMapper.flowCardDetailMp(processId, flowCard)); |
| | | return map; |
| | | } |
| | | |
| | | public Object selectPrintFlowCardSv(Date selectTime1, Date selectTime2, String orderId, String project, FlowCard flowCard) { |
| | | if ("null".equals(orderId)) { |
| | | orderId = ""; |
| | | } |
| | | if ("null".equals(project)) { |
| | | project = ""; |
| | | } |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("data", flowCardMapper.selectPrintFlowCardMp(selectTime1, selectTime2, orderId, project, flowCard)); |
| | | return map; |
| | | } |
| | | |
| | | public Object selectPrintSv(String orderId, FlowCard flowCard) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("data", flowCardMapper.selectPrintMp(orderId, flowCard)); |
| | | return map; |
| | | } |
| | | |
| | | public Map<String, Object> getSelectPrintingSv(Map<String, Object> object) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();//最终结果 |
| | | List<FlowCard> flowCardList = JSONArray.parseArray(JSONObject.toJSONString(object.get("printList")), FlowCard.class); |
| | | if (!flowCardList.isEmpty()) { |
| | | for (FlowCard flowCard : flowCardList) { |
| | | Map<String, Object> itemmap = new HashMap<>(); |
| | | //流程卡表头表尾数据 |
| | | itemmap.put("detail", flowCardMapper.getPrimaryList(flowCard.getProcessId(), flowCard.getTechnologyNumber())); |
| | | //流程卡明细数据 |
| | | List<Map<String, Object>> detailList = flowCardMapper.getDetailList(flowCard.getProcessId(), flowCard.getTechnologyNumber()); |
| | | //工艺流程 |
| | | List<Map<String, Object>> processList = flowCardMapper.getProcessList(flowCard.getProcessId(), flowCard.getTechnologyNumber()); |
| | | itemmap.put("detailList", detailList); |
| | | itemmap.put("processList", processList); |
| | | list.add(itemmap); |
| | | |
| | | |
| | | } |
| | | } |
| | | map.put("data", list); |
| | | return map; |
| | | } |
| | | |
| | | public Boolean updateComposingSv(Map<String, Object> object) { |
| | | List<FlowCard> flowCardList = JSONArray.parseArray(JSONObject.toJSONString(object.get("composing")), FlowCard.class); |
| | | if (!flowCardList.isEmpty()) { |
| | | for (FlowCard flowCard : flowCardList) { |
| | | flowCardMapper.updateComposing(flowCard.getProcessId()); |
| | | } |
| | | return true; |
| | | } |
| | | else { |
| | | return false; |
| | | |
| | | } |
| | | } |
| | | |
| | | public Map<String, Object> getSelectPrintLabelSv(Map<String, Object> object) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | List<FlowCard> flowCardList = JSONArray.parseArray(JSONObject.toJSONString(object.get("printList")), FlowCard.class); |
| | | if (!flowCardList.isEmpty()) { |
| | | for (FlowCard flowCard : flowCardList) { |
| | | Integer count=flowCard.getQuantity(); |
| | | for (int i = 0; i < count; i++) { |
| | | map.put("data", flowCardMapper.getPrintLabel(flowCard.getProcessId(), flowCard.getTechnologyNumber())); |
| | | //System.out.println(flowCardMapper.getPrintLabel(flowCard.getProcessId(), flowCard.getTechnologyNumber())); |
| | | } |
| | | } |
| | | } |
| | | |
| | | return map; |
| | | } |
| | | } |