廖井涛
2024-02-27 926a1e8b90381c7aa085d5462d78de9d2cc6034d
north-glass-erp/src/main/java/com/example/erp/service/pp/FlowCardService.java
@@ -1,6 +1,8 @@
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.pp.FlowCard;
import com.example.erp.entity.sd.Order;
@@ -12,47 +14,117 @@
import java.sql.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
@DS("pp")
public class FlowCardService {
    @Autowired
     FlowCardMapper flowCardMapper;
    FlowCardMapper flowCardMapper;
    public Map<String, Object>  selectProcessCard(Date selectTime1, Date selectTime2, FlowCard flowCard) {
    //流程卡管理查询
    public Map<String, Object> selectProcessCard(Date selectTime1, Date selectTime2, FlowCard flowCard) {
        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(selectTime1, selectTime2, flowCard));
        return map;
    }
    //分架查询
    public Map<String, Object> selectAddProcess(Date selectTime1, Date selectTime2, FlowCard flowCard) {
        Map<String, Object> map = new HashMap<>();
        map.put("data", flowCardMapper.selectFlowCardMp( selectTime1,selectTime2, flowCard));
        map.put("data", flowCardMapper.selectFlowCardMp(selectTime1, selectTime2, flowCard));
        return map;
    }
    //分架明细查询
    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) {
        if (!orderId.isEmpty()&&!processId.isEmpty()){
            flowCardMapper.DeleteFlowCardMp(orderId, processId);
            return true;
        }
        else {
        if (!orderId.isEmpty() && !processId.isEmpty()) {
            Integer count=flowCardMapper.ReportingWorkCount(processId);
            if (count==0){
                //修改分架状态
                flowCardMapper.UpdateDeleteState(orderId, processId);
                //删除分架明细
                flowCardMapper.DeleteFlowCardMp(orderId, processId);
                return true;
            }
            else {
                return false;
            }
        } else {
            return false;
        }
    }
    //分架新增明细查询
    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) {
        if (!processId.isEmpty()) {
            Integer Status = flowCardMapper.SelectLayoutStatus(processId);
            if (Status == 1) {
                flowCardMapper.UpdateLayoutStatusMp(processId);
            } else {
                return false;
            }
            return true;
        } else {
            return false;
        }
    }
    public Boolean AddFlowCardSv(Map<String, Object> object) {
        String userName = "";
        if (object.get("userName") != null) {
            userName = object.get("userName").toString();
        }
        String productionId = "";
        if (object.get("productionId") != null) {
            productionId = object.get("productionId").toString();
        }
        List<FlowCard> FlowCardList = JSONArray.parseArray(JSONObject.toJSONString(object.get("flowCard")), FlowCard.class);
        if (!FlowCardList.isEmpty()) {
            for (FlowCard flowCard : FlowCardList) {
                //添加流程卡数据
                flowCardMapper.AddFlowCardMp(flowCard.getProcessId(),flowCard.getOrderNumber(),flowCard.getLandingSequence(),flowCard.getQuantity(),productionId,userName);
                //修改分架状态,将状态改为1
                flowCardMapper.UpdateFlowState(productionId,flowCard.getOrderNumber());
                //查询该订单未分架数量
               Integer FlowCount= flowCardMapper.SelectFlowCount(productionId);
               if (FlowCount==0){
                   //修改订单表分架状态为2
                   System.out.println("我来试试1");
                   flowCardMapper.UpdateProcessingCard(productionId,2);
               }
               else{
                   //修改订单表分架状态为1,未全部分架完成
                   System.out.println("我来试试2");
                   flowCardMapper.UpdateProcessingCard(productionId,1);
               }
            }
            return  true;
        } else {
            return  false;
        }
    }
}