chenlu
2024-03-01 a1a27eba473c476cade23f003d3ac1f1cc1ac27d
north-glass-erp/src/main/java/com/example/erp/service/pp/FlowCardService.java
@@ -1,30 +1,151 @@
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;
import com.example.erp.entity.sd.OrderDetail;
import com.example.erp.entity.sd.OrderGlassDetail;
import com.example.erp.mapper.pp.FlowCardMapper;
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("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("total", productMapper.getPageTotal(offset, pageSize, glassTypeId, product));
        //System.out.println(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));
        return map;
    }
    //分架明细查询
    public Map<String, Object> DetailsSelectSv(String orderId, FlowCard flowCard) {
        Map<String, Object> map = new HashMap<>();
        map.put("data", flowCardMapper.DetailsSelectMp(orderId, flowCard));
        return map;
    }
    //删除流程卡
    public Boolean DeleteFlowCardSv(String orderId, String processId) {
        if (!orderId.isEmpty() && !processId.isEmpty()) {
            Integer count = flowCardMapper.ReportingWorkCount(processId);
            if (count == 0) {
                //修改订单表分架状态为1,未全部分架完成
                flowCardMapper.UpdateProcessingCard(orderId, 1);
                //修改分架状态
                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));
        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) {
                //查询每个序号的层数
                Integer layer = flowCardMapper.SelectLayer(productionId, flowCard.getOrderNumber());
                //添加流程卡数据
                flowCardMapper.AddFlowCardMp(flowCard.getProcessId(), flowCard.getOrderNumber(), flowCard.getLandingSequence(), flowCard.getQuantity(), productionId, userName,layer);
                //修改分架状态,将状态改为1
                flowCardMapper.UpdateFlowState(productionId, flowCard.getOrderNumber());
                //查询该订单未分架数量
                Integer FlowCount = flowCardMapper.SelectFlowCount(productionId);
                if (FlowCount == 0) {
                    //修改订单表分架状态为2
                    flowCardMapper.UpdateProcessingCard(productionId, 2);
                } else {
                    //修改订单表分架状态为1,未全部分架完成
                    flowCardMapper.UpdateProcessingCard(productionId, 1);
                }
            }
            return true;
        } else {
            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;
    }
}