123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- package com.steerinfo.dil.service.impl;
- import com.steerinfo.dil.mapper.BackgroundProcessingMapper;
- import com.steerinfo.dil.service.IBackgroundProcessService;
- import com.steerinfo.dil.util.DataChange;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import java.math.BigDecimal;
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.List;
- import java.util.Map;
- @Service(value = "backgroundProcessingService")
- public class BackgroundProcessingServiceImpl implements IBackgroundProcessService {
- @Autowired
- private BackgroundProcessingMapper backgroundProcessingMapper;
- /**
- * 更新订单所属厂区
- * @param map
- * @return
- */
- @Override
- public int updatePurOrgId(Map<String, Object> map) {
- return backgroundProcessingMapper.updatePurOrderOrgId(map);
- }
- /**
- * 删除重复实绩
- * @param orderNumber
- * @return
- */
- public int deleteErrorResult(String orderNumber) {
- Map<String, Object> orderMes = backgroundProcessingMapper.getOrderMesByOrderNum(orderNumber);
- int orderType = DataChange.dataToBigDecimal(orderMes.get("orderType")).intValue();
- List<Integer> arrayList = Arrays.asList(11, 15, 16, 21); //没有固定路线不支持此操作
- if(arrayList.contains(orderType)){
- return 0;
- }
- BigDecimal resultTotalId = DataChange.dataToBigDecimal(orderMes.get("resultTotalId"));
- List<Integer> enFactoryList = backgroundProcessingMapper.enFactoryCheck(resultTotalId);
- if(enFactoryList != null && enFactoryList.size() != 0){
- //查询出当前顺序号中所有的实绩
- for (Integer sqe : enFactoryList) {
- List<Map<String, Object>> mesList = backgroundProcessingMapper.getEnFactoryResult(resultTotalId, sqe);
- closeWay(mesList, 1);
- }
- }
- List<Integer> loadList = backgroundProcessingMapper.loadCheck(resultTotalId);
- if(loadList != null && loadList.size() != 0){
- for (Integer sqe : loadList) {
- List<Map<String, Object>> mesList = backgroundProcessingMapper.loadResult(resultTotalId, sqe);
- closeWay(mesList, 2);
- }
- }
- List<Integer> unloadList = backgroundProcessingMapper.unloadCheck(resultTotalId);
- if(unloadList != null && unloadList.size() != 0){
- for (Integer sqe : unloadList) {
- List<Map<String, Object>> mesList = backgroundProcessingMapper.unloadResult(resultTotalId, sqe);
- closeWay( mesList, 3);
- }
- }
- List<Integer> weightList = backgroundProcessingMapper.weightCheck(resultTotalId);
- if(weightList != null && weightList.size() != 0){
- for (Integer sqe : weightList) {
- List<Map<String, Object>> mesList = backgroundProcessingMapper.weightResult(resultTotalId, sqe);
- closeWay(mesList, 4);
- }
- }
- List<Integer> outFactoryList = backgroundProcessingMapper.outFactoryCheck(resultTotalId);
- if(outFactoryList != null && outFactoryList.size() != 0){
- for (Integer sqe : outFactoryList) {
- List<Map<String, Object>> mesList = backgroundProcessingMapper.outFactoryResult(resultTotalId, sqe);
- closeWay(mesList, 5);
- }
- }
- return 0;
- }
- /**
- * 关闭通用方法
- * @param mesList 这些顺序号的实绩信息
- * @param type 1:进厂 2:计量 3:装货:4:卸货 5:出厂
- */
- public void closeWay(List<Map<String, Object>> mesList, int type){
- List<Integer> resultList = new ArrayList<>();
- for (Map<String, Object> map : mesList) {
- //有过操作时间的不做删除
- if(map.get("time") == null){
- resultList.add(DataChange.dataToBigDecimal(map.get("resultId")).intValue()); //添入列表中
- }
- }
- if(mesList.size() == resultList.size()){
- //如果所有的实绩都为空 ,则只保留一条实绩,其余的全部删除
- resultList.remove(0);
- }
- if(resultList.size() != 0){
- //删除实绩数据
- if(type == 1)
- backgroundProcessingMapper.deleteEnFactoryUnnecessaryResult(resultList);
- else if(type == 2)
- backgroundProcessingMapper.deleteLoadUnnecessaryResult(resultList);
- else if(type == 3)
- backgroundProcessingMapper.deleteUnloadUnnecessaryResult(resultList);
- else if(type == 4)
- backgroundProcessingMapper.deleteWeightUnnecessaryResult(resultList);
- else if(type == 5)
- backgroundProcessingMapper.deleteOutFactoryUnnecessaryResult(resultList);
- }
- }
- }
|