zhanghl
2025-04-23 eccacd586dfbaace7c47bf52f4c96d096d8ef7dc
钣金按部门统计时间
已添加7个文件
已修改3个文件
858 ■■■■■ 文件已修改
aps-modules/aps-core/src/main/java/com/aps/core/controller/mainPlan/ApsPlateProcessShopStatController.java 74 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsPlateProcessShopPlanStat.java 68 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsPlateProcessShopStat.java 140 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsPlateProcessShopStatMapper.java 67 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
aps-modules/aps-core/src/main/java/com/aps/core/service/IApsPlateProcessShopStatService.java 67 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsPlatePlanServiceImpl.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsPlateProcessShopStatServiceImpl.java 283 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
aps-modules/aps-core/src/main/resources/mapper/core/ApsPlatePlanMapper.xml 37 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
aps-modules/aps-core/src/main/resources/mapper/core/ApsPlateProcessShopStatMapper.xml 118 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
aps-modules/aps-core/src/main/resources/mapper/core/ApsShopMapper.xml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
aps-modules/aps-core/src/main/java/com/aps/core/controller/mainPlan/ApsPlateProcessShopStatController.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,74 @@
package com.aps.core.controller.mainPlan;
import com.aps.common.core.utils.poi.ExcelUtil;
import com.aps.common.core.web.controller.BaseController;
import com.aps.common.core.web.domain.AjaxResult;
import com.aps.common.core.web.page.TableDataInfo;
import com.aps.common.log.annotation.Log;
import com.aps.common.log.enums.BusinessType;
import com.aps.common.security.annotation.RequiresPermissions;
import com.aps.core.domain.ApsPlateProcessShopStat;
import com.aps.core.service.IApsPlateProcessShopStatService;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
 * é’£é‡‘车间统计Controller
 *
 * @author zhl
 * @date 2025-04-23
 */
@RestController
@RequestMapping("/ApsPlateProcessShopStat")
public class ApsPlateProcessShopStatController extends BaseController
{
    @Autowired
    private IApsPlateProcessShopStatService apsPlateProcessShopStatService;
    /**
     * å¯¼å‡ºé’£é‡‘车间统计列表
     */
    @RequiresPermissions("ApsPlateProcessShopStat:ApsPlateProcessShopStat:export")
    @Log(title = "钣金车间统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ApsPlateProcessShopStat apsPlateProcessShopStat)
    {
        List<ApsPlateProcessShopStat> list = apsPlateProcessShopStatService.selectApsPlateProcessShopStatList(apsPlateProcessShopStat);
        ExcelUtil<ApsPlateProcessShopStat> util = new ExcelUtil<ApsPlateProcessShopStat>(ApsPlateProcessShopStat.class);
        util.exportExcel(response, list, "钣金车间统计数据");
    }
    /**
     * ä¿®æ”¹é’£é‡‘车间统计
     */
    @Log(title = "钣金车间统计", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    public AjaxResult update(@RequestBody ApsPlateProcessShopStat apsPlateProcessShopStat)
    {
        apsPlateProcessShopStatService.saveShopStat();
        return toAjax(true);
    }
    /**
     * æŸ¥è¯¢é’£é‡‘车间统计列表
     */
    @GetMapping("/list")
    public AjaxResult list(ApsPlateProcessShopStat apsPlateProcessShopStat)
    {
        return apsPlateProcessShopStatService.getShopPlanStat();
    }
}
aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsPlateProcessShopPlanStat.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,68 @@
package com.aps.core.domain;
import com.aps.common.core.annotation.Excel;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Data
public class ApsPlateProcessShopPlanStat implements Serializable {
    @Serial
    private static final long serialVersionUID = 1L;
    /** ä¸»é”®id */
    private String id;
    /** ä¸»ä»¶æ–™å· */
    @Excel(name = "主件料号")
    private String mainPartNumber;
    /** ä¸šåŠ¡ç±»åž‹ */
    @Excel(name = "业务类型")
    private String businessType;
    /** å•据号 */
    @Excel(name = "单据号")
    private String documentNumber;
    /** éœ€æ±‚分类 */
    @Excel(name = "需求分类")
    private String requirementType;
    /** å•据状态 */
    @Excel(name = "单据状态")
    private String documentStatus;
    /** å½“前工序 */
    @Excel(name = "当前工序")
    private String workCenter;
    /** æ–™å· */
    @Excel(name = "料号")
    private String itemNumber;
    /** å›¾å· */
    @Excel(name = "图号")
    private String drawingNo;
    /** ç‰ˆæœ¬å· */
    @Excel(name = "版本号")
    private String versionNumber;
    /** ç”Ÿäº§æ•°é‡ */
    @Excel(name = "生产数量")
    private BigDecimal productionQuantity;
    /** è®¡åˆ’完工日 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "计划完工日", width = 30, dateFormat = "yyyy-MM-dd")
    private Date planEndDay;
    private List<ApsPlateProcessShopStat> deptPlans=new ArrayList<>();
}
aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsPlateProcessShopStat.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,140 @@
package com.aps.core.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.aps.common.core.annotation.Excel;
//import io.swagger.annotations.ApiModel;
//import io.swagger.annotations.ApiModelProperty;
import com.aps.common.core.web.domain.BaseEntity;
/**
 * é’£é‡‘车间统计对象 aps_plate_process_shop_stat
 *
 * @author zhl
 * @date 2025-04-23
 */
//@ApiModel("钣金车间统计实体类")
public class ApsPlateProcessShopStat extends BaseEntity
{
    private static final long serialVersionUID = 1L;
    /** $column.columnComment */
    //@ApiModelProperty("$column.columnComment")
    private Long id;
    /** å•据号 */
    @Excel(name = "单据号")
    ///@ApiModelProperty("单据号")
    private String docNo;
    /** è½¦é—´ç¼–码 */
    @Excel(name = "车间编码")
    //@ApiModelProperty("车间编码")
    private String shopCode;
    /** è½¦é—´åç§° */
    @Excel(name = "车间名称")
    //@ApiModelProperty("车间名称")
    private String shopName;
    /** è®¡åˆ’开始时间 */
    @Excel(name = "计划开始时间")
    //@ApiModelProperty("计划开始时间")
    private String planStartDate;
    /** è®¡åˆ’结束日期 */
    @Excel(name = "计划结束日期")
    //@ApiModelProperty("计划结束日期")
    private String planEndDate;
    /** åˆ é™¤æ ‡å¿—(0代表存在 2代表删除) */
    //@ApiModelProperty("删除标志(0代表存在 2代表删除)")
    private String delFlag;
    public void setId(Long id)
    {
        this.id = id;
    }
    public Long getId()
    {
        return id;
    }
    public void setDocNo(String docNo)
    {
        this.docNo = docNo;
    }
    public String getDocNo()
    {
        return docNo;
    }
    public void setShopCode(String shopCode)
    {
        this.shopCode = shopCode;
    }
    public String getShopCode()
    {
        return shopCode;
    }
    public void setShopName(String shopName)
    {
        this.shopName = shopName;
    }
    public String getShopName()
    {
        return shopName;
    }
    public void setPlanStartDate(String planStartDate)
    {
        this.planStartDate = planStartDate;
    }
    public String getPlanStartDate()
    {
        return planStartDate;
    }
    public void setPlanEndDate(String planEndDate)
    {
        this.planEndDate = planEndDate;
    }
    public String getPlanEndDate()
    {
        return planEndDate;
    }
    public void setDelFlag(String delFlag)
    {
        this.delFlag = delFlag;
    }
    public String getDelFlag()
    {
        return delFlag;
    }
    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("id", getId())
            .append("docNo", getDocNo())
            .append("shopCode", getShopCode())
            .append("shopName", getShopName())
            .append("planStartDate", getPlanStartDate())
            .append("planEndDate", getPlanEndDate())
            .append("delFlag", getDelFlag())
            .append("createBy", getCreateBy())
            .append("createTime", getCreateTime())
            .append("updateBy", getUpdateBy())
            .append("updateTime", getUpdateTime())
            .toString();
    }
}
aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsPlateProcessShopStatMapper.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,67 @@
package com.aps.core.mapper;
import java.util.List;
import com.aps.core.domain.ApsPlateProcessShopStat;
import org.apache.ibatis.annotations.Mapper;
/**
 * é’£é‡‘车间统计Mapper接口
 *
 * @author zhl
 * @date 2025-04-23
 */
@Mapper
public interface ApsPlateProcessShopStatMapper
{
    /**
     * æŸ¥è¯¢é’£é‡‘车间统计
     *
     * @param id é’£é‡‘车间统计主键
     * @return é’£é‡‘车间统计
     */
    public ApsPlateProcessShopStat selectApsPlateProcessShopStatById(Long id);
    /**
     * æŸ¥è¯¢é’£é‡‘车间统计列表
     *
     * @param apsPlateProcessShopStat é’£é‡‘车间统计
     * @return é’£é‡‘车间统计集合
     */
    public List<ApsPlateProcessShopStat> selectApsPlateProcessShopStatList(ApsPlateProcessShopStat apsPlateProcessShopStat);
    /**
     * æ–°å¢žé’£é‡‘车间统计
     *
     * @param apsPlateProcessShopStat é’£é‡‘车间统计
     * @return ç»“æžœ
     */
    public int insertApsPlateProcessShopStat(ApsPlateProcessShopStat apsPlateProcessShopStat);
    /**
     * ä¿®æ”¹é’£é‡‘车间统计
     *
     * @param apsPlateProcessShopStat é’£é‡‘车间统计
     * @return ç»“æžœ
     */
    public int updateApsPlateProcessShopStat(ApsPlateProcessShopStat apsPlateProcessShopStat);
    /**
     * åˆ é™¤é’£é‡‘车间统计
     *
     * @param id é’£é‡‘车间统计主键
     * @return ç»“æžœ
     */
    public int deleteApsPlateProcessShopStatById(Long id);
    /**
     * æ‰¹é‡åˆ é™¤é’£é‡‘车间统计
     *
     * @param ids éœ€è¦åˆ é™¤çš„æ•°æ®ä¸»é”®é›†åˆ
     * @return ç»“æžœ
     */
    public int deleteApsPlateProcessShopStatByIds(Long[] ids);
    int deleteAll();
    void batchInsert(List<ApsPlateProcessShopStat> stats);
}
aps-modules/aps-core/src/main/java/com/aps/core/service/IApsPlateProcessShopStatService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,67 @@
package com.aps.core.service;
import java.util.List;
import com.aps.common.core.web.domain.AjaxResult;
import com.aps.core.domain.ApsPlateProcessShopStat;
/**
 * é’£é‡‘车间统计Service接口
 *
 * @author zhl
 * @date 2025-04-23
 */
public interface IApsPlateProcessShopStatService
{
    /**
     * æŸ¥è¯¢é’£é‡‘车间统计
     *
     * @param id é’£é‡‘车间统计主键
     * @return é’£é‡‘车间统计
     */
    public ApsPlateProcessShopStat selectApsPlateProcessShopStatById(Long id);
    /**
     * æŸ¥è¯¢é’£é‡‘车间统计列表
     *
     * @param apsPlateProcessShopStat é’£é‡‘车间统计
     * @return é’£é‡‘车间统计集合
     */
    public List<ApsPlateProcessShopStat> selectApsPlateProcessShopStatList(ApsPlateProcessShopStat apsPlateProcessShopStat);
    /**
     * æ–°å¢žé’£é‡‘车间统计
     *
     * @param apsPlateProcessShopStat é’£é‡‘车间统计
     * @return ç»“æžœ
     */
    public int insertApsPlateProcessShopStat(ApsPlateProcessShopStat apsPlateProcessShopStat);
    /**
     * ä¿®æ”¹é’£é‡‘车间统计
     *
     * @param apsPlateProcessShopStat é’£é‡‘车间统计
     * @return ç»“æžœ
     */
    public int updateApsPlateProcessShopStat(ApsPlateProcessShopStat apsPlateProcessShopStat);
    /**
     * æ‰¹é‡åˆ é™¤é’£é‡‘车间统计
     *
     * @param ids éœ€è¦åˆ é™¤çš„钣金车间统计主键集合
     * @return ç»“æžœ
     */
    public int deleteApsPlateProcessShopStatByIds(Long[] ids);
    /**
     * åˆ é™¤é’£é‡‘车间统计信息
     *
     * @param id é’£é‡‘车间统计主键
     * @return ç»“æžœ
     */
    public int deleteApsPlateProcessShopStatById(Long id);
    void saveShopStat();
    AjaxResult getShopPlanStat();
}
aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsPlatePlanServiceImpl.java
@@ -183,4 +183,7 @@
           return Strings.EMPTY;
        }
    }
}
aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsPlateProcessShopStatServiceImpl.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,283 @@
package com.aps.core.service.impl;
import java.util.*;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject;
import com.aps.common.core.utils.DateUtils;
import com.aps.common.core.utils.bean.BeanUtils;
import com.aps.common.core.web.domain.AjaxResult;
import com.aps.common.security.utils.SecurityUtils;
import com.aps.core.domain.*;
import com.aps.core.mapper.*;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.aps.core.service.IApsPlateProcessShopStatService;
import org.springframework.transaction.annotation.Transactional;
/**
 * é’£é‡‘车间统计Service业务层处理
 *
 * @author zhl
 * @date 2025-04-23
 */
@Slf4j
@Service
public class ApsPlateProcessShopStatServiceImpl implements IApsPlateProcessShopStatService {
    @Autowired
    private ApsPlateProcessShopStatMapper apsPlateProcessShopStatMapper;
    @Resource
    private ApsPlateProcessStatMapper apsPlateProcessStatMapper;
    @Resource
    private ApsShopMapper shopMapper;
    @Resource
    private ApsStandardProcessMapper standardProcessMapper;
    @Resource
    private ApsPlatePlanMapper apsPlatePlanMapper;
    /**
     * æŸ¥è¯¢é’£é‡‘车间统计
     *
     * @param id é’£é‡‘车间统计主键
     * @return é’£é‡‘车间统计
     */
    @Override
    public ApsPlateProcessShopStat selectApsPlateProcessShopStatById(Long id) {
        return apsPlateProcessShopStatMapper.selectApsPlateProcessShopStatById(id);
    }
    /**
     * æŸ¥è¯¢é’£é‡‘车间统计列表
     *
     * @param apsPlateProcessShopStat é’£é‡‘车间统计
     * @return é’£é‡‘车间统计
     */
    @Override
    public List<ApsPlateProcessShopStat> selectApsPlateProcessShopStatList(ApsPlateProcessShopStat apsPlateProcessShopStat) {
        return apsPlateProcessShopStatMapper.selectApsPlateProcessShopStatList(apsPlateProcessShopStat);
    }
    /**
     * æ–°å¢žé’£é‡‘车间统计
     *
     * @param apsPlateProcessShopStat é’£é‡‘车间统计
     * @return ç»“æžœ
     */
    @Override
    public int insertApsPlateProcessShopStat(ApsPlateProcessShopStat apsPlateProcessShopStat) {
        apsPlateProcessShopStat.setCreateTime(DateUtils.getNowDate());
        return apsPlateProcessShopStatMapper.insertApsPlateProcessShopStat(apsPlateProcessShopStat);
    }
    /**
     * ä¿®æ”¹é’£é‡‘车间统计
     *
     * @param apsPlateProcessShopStat é’£é‡‘车间统计
     * @return ç»“æžœ
     */
    @Override
    public int updateApsPlateProcessShopStat(ApsPlateProcessShopStat apsPlateProcessShopStat) {
        apsPlateProcessShopStat.setUpdateTime(DateUtils.getNowDate());
        return apsPlateProcessShopStatMapper.updateApsPlateProcessShopStat(apsPlateProcessShopStat);
    }
    /**
     * æ‰¹é‡åˆ é™¤é’£é‡‘车间统计
     *
     * @param ids éœ€è¦åˆ é™¤çš„钣金车间统计主键
     * @return ç»“æžœ
     */
    @Override
    public int deleteApsPlateProcessShopStatByIds(Long[] ids) {
        return apsPlateProcessShopStatMapper.deleteApsPlateProcessShopStatByIds(ids);
    }
    /**
     * åˆ é™¤é’£é‡‘车间统计信息
     *
     * @param id é’£é‡‘车间统计主键
     * @return ç»“æžœ
     */
    @Override
    public int deleteApsPlateProcessShopStatById(Long id) {
        return apsPlateProcessShopStatMapper.deleteApsPlateProcessShopStatById(id);
    }
    /**
     * ä¿å­˜é’£é‡‘车间统计
     */
    @Transactional
    @Override
    public void saveShopStat() {
        try {
            // å¼€å§‹ä¹‹å‰å…ˆåˆ é™¤æ‰€æœ‰åŽ†å²æ•°æ®
            apsPlateProcessShopStatMapper.deleteAll();
            // å®šä¹‰è¯¥åŠŸèƒ½ä½¿ç”¨æ•°æ®æºä¸ºå—é€šçš„å·¥åŽ‚
            final String plant = "FORTUNA";
            // æŸ¥è¯¢ç›¸å…³æ•°æ®
            ApsPlatePlan platePlan = new ApsPlatePlan();
            platePlan.setPlant(plant);
            List<ApsPlatePlan> planList = apsPlatePlanMapper.selectApsPlatePlanList(platePlan);
            List<ApsPlateProcessStat> statList = apsPlateProcessStatMapper.selectApsPlateProcessStatList(new ApsPlateProcessStat());
            ApsShop apsShop = new ApsShop();
            apsShop.setPlantCode(plant);
            List<ApsShop> shopList = shopMapper.selectApsShopList(apsShop);
            ApsStandardProcess process = new ApsStandardProcess();
            process.setPlant(plant);
            List<ApsStandardProcess> shopProcesses = standardProcessMapper.selectApsStandardProcessList(process);
            if (planList.isEmpty() || shopList.isEmpty() || shopProcesses.isEmpty()) {
                log.warn("计划列表、车间列表或工序列表为空,无法生成统计信息");
                return;
            }
            // æž„建车间名称到工序名称的映射
            Map<String, List<String>> shopToProcessNames = shopProcesses.stream()
                    .collect(Collectors.groupingBy(ApsStandardProcess::getWorkShop,
                            Collectors.mapping(ApsStandardProcess::getProcessName, Collectors.toList())
                    ));
            // æ‰¹é‡æ’入统计数据
            List<ApsPlateProcessShopStat> statsToInsert = new ArrayList<>();
            for (ApsPlatePlan plan : planList) {
                for (ApsShop shop : shopList) {
                    ApsPlateProcessShopStat stat = createShopStat(plan, shop, shopToProcessNames, statList);
                    statsToInsert.add(stat);
                }
            }
            // æ‰¹é‡æ’入以提高性能
            if (!statsToInsert.isEmpty()) {
                int batchSize = 1000;
                for (int i = 0; i < statsToInsert.size(); i += batchSize) {
                    int end = Math.min(i + batchSize, statsToInsert.size());
                    List<ApsPlateProcessShopStat> batch = statsToInsert.subList(i, end);
                    apsPlateProcessShopStatMapper.batchInsert(batch);
                }
            }
        } catch (Exception e) {
            log.error("保存钣金车间统计时发生异常", e);
            throw new RuntimeException("保存钣金车间统计失败", e);
        }
    }
    /**
     * åˆ›å»ºå•个车间统计对象
     */
    private ApsPlateProcessShopStat createShopStat(ApsPlatePlan plan, ApsShop shop,
                                                   Map<String, List<String>> shopToProcessNames, List<ApsPlateProcessStat> statList) {
        String shopName = shop.getShopName();
        ApsPlateProcessShopStat stat = new ApsPlateProcessShopStat();
        stat.setDocNo(plan.getDocumentNumber());
        stat.setShopCode(shop.getShopCode());
        stat.setShopName(shopName);
        stat.setDelFlag("0");
        stat.setCreateBy(SecurityUtils.getUsername());
        stat.setCreateTime(DateUtils.getNowDate());
        try {
            List<String> processNames = shopToProcessNames.getOrDefault(shopName, Collections.emptyList());
            if (!processNames.isEmpty()) {
                // æ ¹æ®å·¥åºåç§°ï¼ŒæŸ¥è¯¢è¯¥å·¥å•下所有的工序信息
                List<ApsPlateProcessStat> processStats = statList.stream()
                        .filter(x -> processNames.contains(x.getProcessName()) && x.getWorkOrderNo().equals(plan.getDocumentNumber()))
                        .toList();
                if (!processStats.isEmpty()) {
                    // å–出工单下工序的最小开始时间和最大结束时间
                    List<Date> startDayList = processStats.stream().map(ApsPlateProcessStat::getProcessPlanStartDay).filter(Objects::nonNull).toList();
                    if (!startDayList.isEmpty()) {
                        if (startDayList.size() == 1) {
                            stat.setPlanStartDate(DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", startDayList.get(0)));
                        } else {
                            Optional<Date> minStartDay = processStats.stream()
                                    .map(ApsPlateProcessStat::getProcessPlanStartDay)
                                    .min(Comparator.naturalOrder());
                            Date date = minStartDay.get();
                            stat.setPlanStartDate(DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", date));
                        }
                    }
                    List<Date> endDayList = processStats.stream().map(ApsPlateProcessStat::getProcessPlanEndDay).filter(Objects::nonNull).toList();
                    if (!endDayList.isEmpty()) {
                        if (endDayList.size() == 1) {
                            stat.setPlanEndDate(DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", endDayList.get(0)));
                        } else {
                            Optional<Date> maxEndDay = processStats.stream()
                                    .map(ApsPlateProcessStat::getProcessPlanEndDay)
                                    .max(Comparator.naturalOrder());
                            Date date = maxEndDay.get();
                            stat.setPlanEndDate(DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", date));
                        }
                    }
                }
            }
        } catch (Exception e) {
            log.error("computer error:"+ JSONObject.toJSONString(stat));
        }
        return stat;
    }
    @Override
    public AjaxResult getShopPlanStat() {
        // æå–硬编码值为常量
        final String PLANT_CODE = "FORTUNA";
        // åˆå§‹åŒ–对象
        ApsPlatePlan platePlan = new ApsPlatePlan();
        platePlan.setPlant(PLANT_CODE);
        ApsShop apsShop = new ApsShop();
        apsShop.setPlantCode(PLANT_CODE);
        // èŽ·å–è½¦é—´åˆ—è¡¨å¹¶å¤„ç†ç©ºå€¼
        List<String> shopList = Optional.ofNullable(shopMapper.selectApsShopList(apsShop))
                .orElse(Collections.emptyList())
                .stream()
                .map(ApsShop::getShopName)
                .toList();
        // èŽ·å–è®¡åˆ’åˆ—è¡¨å’ŒçŠ¶æ€åˆ—è¡¨
        List<ApsPlatePlan> planList = Optional.ofNullable(apsPlatePlanMapper.selectApsPlatePlanList(platePlan))
                .orElse(Collections.emptyList());
        List<ApsPlateProcessShopStat> shopStates = Optional.ofNullable(apsPlateProcessShopStatMapper.selectApsPlateProcessShopStatList(new ApsPlateProcessShopStat()))
                .orElse(Collections.emptyList());
        // æå‰å¯¹ shopStates æŒ‰ docNo åˆ†ç»„,减少重复流操作
        Map<String, List<ApsPlateProcessShopStat>> shopStatesByDocNo = shopStates.stream()
                .collect(Collectors.groupingBy(ApsPlateProcessShopStat::getDocNo));
        // æž„建结果列表
        List<ApsPlateProcessShopPlanStat> shopPlanStats = planList.stream()
                .map(plan -> {
                    ApsPlateProcessShopPlanStat shopPlanStat = new ApsPlateProcessShopPlanStat();
                    BeanUtils.copyProperties(plan, shopPlanStat); // ç¡®ä¿ç›®æ ‡å¯¹è±¡æ˜¯åˆæ³•的单个对象实例
                    // æ ¹æ® docNo èŽ·å–å¯¹åº”çš„ shopStatList
                    List<ApsPlateProcessShopStat> shopStatList = shopStatesByDocNo.getOrDefault(plan.getDocumentNumber(), Collections.emptyList());
                    shopPlanStat.setDeptPlans(shopStatList);
                    return shopPlanStat;
                })
                .toList();
        // æž„建返回结果
        AjaxResult success = AjaxResult.success(shopPlanStats);
        success.put("shopNames", shopList);
        return success;
    }
}
aps-modules/aps-core/src/main/resources/mapper/core/ApsPlatePlanMapper.xml
@@ -49,40 +49,41 @@
    <select id="selectApsPlatePlanList" parameterType="ApsPlatePlan" resultMap="ApsPlatePlanResult">
        <include refid="selectApsPlatePlanVo"/>
        <where>  
            <if test="masterPlanner != null  and masterPlanner != ''"> and master_planner like concat('%', #{masterPlanner}, '%')</if>
            <if test="masterPlanner != null  and masterPlanner != ''"> and master_planner like '%'|| #{masterPlanner}|| '%'</if>
            <if test="weekDay != null "> and week_day = #{weekDay}</if>
            <if test="weekCycle != null  and weekCycle != ''"> and week_cycle like concat('%', #{weekCycle}, '%')</if>
            <if test="mainPartNumber != null  and mainPartNumber != ''"> and main_part_number like concat('%', #{mainPartNumber}, '%')</if>
            <if test="mainPartDrawingNumber != null  and mainPartDrawingNumber != ''"> and main_part_drawing_number like concat('%', #{mainPartDrawingNumber}, '%')</if>
            <if test="weekCycle != null  and weekCycle != ''"> and week_cycle like '%'||  #{weekCycle}|| '%' </if>
            <if test="mainPartNumber != null  and mainPartNumber != ''"> and main_part_number like '%'|| #{mainPartNumber}  ||'%' </if>
            <if test="mainPartDrawingNumber != null  and mainPartDrawingNumber != ''"> and main_part_drawing_number like  '%'|| #{mainPartDrawingNumber}|| '%'</if>
            <if test="customer != null  and customer != ''"> and customer like  '%' || #{customer} || '%'</if>
            <if test="businessType != null  and businessType != ''"> and business_type = #{businessType}</if>
            <if test="documentNumber != null  and documentNumber != ''"> and document_number like '%'|| #{documentNumber}|| '%'</if>
            <if test="requirementType != null  and requirementType != ''"> and requirement_type like concat('%', #{requirementType}, '%')</if>
            <if test="requirementType != null  and requirementType != ''"> and requirement_type like   '%'|| #{requirementType}||'%' </if>
            <if test="documentStatus != null  and documentStatus != ''"> and document_status = #{documentStatus}</if>
            <if test="itemNumber != null  and itemNumber != ''"> and item_number like concat('%', #{itemNumber}, '%')</if>
            <if test="drawingNo != null  and drawingNo != ''"> and drawing_no like concat('%', #{drawingNo}, '%')</if>
            <if test="versionNumber != null  and versionNumber != ''"> and version_number like concat('%', #{versionNumber}, '%')</if>
            <if test="itemNumber != null  and itemNumber != ''"> and item_number like '%'|| #{itemNumber}|| '%'</if>
            <if test="drawingNo != null  and drawingNo != ''"> and drawing_no like  '%'|| #{drawingNo}|| '%'</if>
            <if test="versionNumber != null  and versionNumber != ''"> and version_number like  '%'|| #{versionNumber}|| '%'</if>
            <if test="productionQuantity != null "> and production_quantity = #{productionQuantity}</if>
            <if test="goodProductsQuantity != null "> and good_products_quantity = #{goodProductsQuantity}</if>
            <if test="processNumber != null  and processNumber != ''"> and process_number like concat('%', #{processNumber}, '%')</if>
            <if test="workCenter != null  and workCenter != ''"> and work_center like concat('%', #{workCenter}, '%')</if>
            <if test="department != null  and department != ''"> and department like concat('%', #{department}, '%')</if>
            <if test="processNumber != null  and processNumber != ''"> and process_number like  '%'|| #{processNumber}||'%'</if>
            <if test="workCenter != null  and workCenter != ''"> and work_center like  '%'|| #{workCenter}||'%'</if>
            <if test="department != null  and department != ''"> and department like  '%'|| #{department}||'%'</if>
            <if test="params.beginPlanStartDay != null and params.beginPlanStartDay != '' and params.endPlanStartDay != null and params.endPlanStartDay != ''"> and plan_start_day between #{params.beginPlanStartDay} and #{params.endPlanStartDay}</if>
            <if test="params.beginPlanEndDay != null and params.beginPlanEndDay != '' and params.endPlanEndDay != null and params.endPlanEndDay != ''"> and plan_end_day between #{params.beginPlanEndDay} and #{params.endPlanEndDay}</if>
            <if test="standbyNumber != null  and standbyNumber != ''"> and standby_number like concat('%', #{standbyNumber}, '%')</if>
            <if test="standbyName != null  and standbyName != ''"> and standby_name like concat('%', #{standbyName}, '%')</if>
            <if test="standbyNumber != null  and standbyNumber != ''"> and standby_number like  '%'|| #{standbyNumber}|| '%'</if>
            <if test="standbyName != null  and standbyName != ''"> and standby_name like  '%'|| #{standbyName}||'%'</if>
            <if test="standbyStock != null "> and standby_stock = #{standbyStock}</if>
            <if test="nextProcessDeparment != null  and nextProcessDeparment != ''"> and next_process_deparment like concat('%', #{nextProcessDeparment}, '%')</if>
            <if test="nextProcessDeparment != null  and nextProcessDeparment != ''"> and next_process_deparment like   '%'|| #{nextProcessDeparment}|| '%'</if>
            <if test="isSuspended != null "> and is_suspended = #{isSuspended}</if>
            <if test="isOutsourcing != null  and isOutsourcing != ''"> and is_outsourcing like concat('%', #{isOutsourcing}, '%')</if>
            <if test="account != null  and account != ''"> and account like concat('%', #{account}, '%')</if>
            <if test="advancedMaterials != null  and advancedMaterials != ''"> and advanced_materials like concat('%', #{advancedMaterials}, '%')</if>
            <if test="advancedDocumentNumber != null  and advancedDocumentNumber != ''"> and advanced_document_number like concat('%', #{advancedDocumentNumber}, '%')</if>
            <if test="isOutsourcing != null  and isOutsourcing != ''"> and is_outsourcing like  '%'|| #{isOutsourcing}||'%'</if>
            <if test="account != null  and account != ''"> and account like  '%'|| #{account}|| '%'</if>
            <if test="advancedMaterials != null  and advancedMaterials != ''"> and advanced_materials like  '%'|| #{advancedMaterials}|| '%'</if>
            <if test="advancedDocumentNumber != null  and advancedDocumentNumber != ''"> and advanced_document_number  '%'|| #{advancedDocumentNumber}|| '%'</if>
            <if test="params.beginAdvancedRequirementDay != null and params.beginAdvancedRequirementDay != '' and params.endAdvancedRequirementDay != null and params.endAdvancedRequirementDay != ''"> and advanced_requirement_day between #{params.beginAdvancedRequirementDay} and #{params.endAdvancedRequirementDay}</if>
            <if test="isPlanComplete != null "> and is_plan_complete = #{isPlanComplete}</if>
            <if test="isStockComplete != null "> and is_stock_complete = #{isStockComplete}</if>
            <if test="hasTurnback != null "> and has_turnback = #{hasTurnback}</if>
            <if test="hasRisk != null "> and has_risk = #{hasRisk}</if>
            <if test="plant != null "> and plant = #{plant}</if>
             and del_flag='0'
        </where>
    </select>
aps-modules/aps-core/src/main/resources/mapper/core/ApsPlateProcessShopStatMapper.xml
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,118 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.aps.core.mapper.ApsPlateProcessShopStatMapper">
    <resultMap type="ApsPlateProcessShopStat" id="ApsPlateProcessShopStatResult">
        <result property="id"    column="id"    />
        <result property="docNo"    column="doc_no"    />
        <result property="shopCode"    column="shop_code"    />
        <result property="shopName"    column="shop_name"    />
        <result property="planStartDate"    column="plan_start_date"    />
        <result property="planEndDate"    column="plan_end_date"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>
    <sql id="selectApsPlateProcessShopStatVo">
        select id, doc_no, shop_code, shop_name, plan_start_date, plan_end_date, del_flag, create_by, create_time, update_by, update_time from aps_plate_process_shop_stat
    </sql>
    <select id="selectApsPlateProcessShopStatList" parameterType="ApsPlateProcessShopStat" resultMap="ApsPlateProcessShopStatResult">
        <include refid="selectApsPlateProcessShopStatVo"/>
        <where>
            <if test="docNo != null  and docNo != ''"> and doc_no = #{docNo}</if>
            <if test="shopCode != null  and shopCode != ''"> and shop_code = #{shopCode}</if>
            <if test="shopName != null  and shopName != ''"> and shop_name = #{shopName}</if>
            <if test="planStartDate != null  and planStartDate != ''"> and plan_start_date = #{planStartDate}</if>
            <if test="planEndDate != null  and planEndDate != ''"> and plan_end_date = #{planEndDate}</if>
             and del_flag='0'
        </where>
    </select>
    <select id="selectApsPlateProcessShopStatById" parameterType="Long" resultMap="ApsPlateProcessShopStatResult">
        <include refid="selectApsPlateProcessShopStatVo"/>
        where id = #{id}
    </select>
    <insert id="insertApsPlateProcessShopStat" parameterType="ApsPlateProcessShopStat" useGeneratedKeys="true" keyProperty="id">
        insert into aps_plate_process_shop_stat
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="docNo != null">doc_no,</if>
            <if test="shopCode != null">shop_code,</if>
            <if test="shopName != null">shop_name,</if>
            <if test="planStartDate != null">plan_start_date,</if>
            <if test="planEndDate != null">plan_end_date,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="docNo != null">#{docNo},</if>
            <if test="shopCode != null">#{shopCode},</if>
            <if test="shopName != null">#{shopName},</if>
            <if test="planStartDate != null">#{planStartDate},</if>
            <if test="planEndDate != null">#{planEndDate},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>
    <update id="updateApsPlateProcessShopStat" parameterType="ApsPlateProcessShopStat">
        update aps_plate_process_shop_stat
        <trim prefix="SET" suffixOverrides=",">
            <if test="docNo != null">doc_no = #{docNo},</if>
            <if test="shopCode != null">shop_code = #{shopCode},</if>
            <if test="shopName != null">shop_name = #{shopName},</if>
            <if test="planStartDate != null">plan_start_date = #{planStartDate},</if>
            <if test="planEndDate != null">plan_end_date = #{planEndDate},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>
    <delete id="deleteApsPlateProcessShopStatById" parameterType="Long">
        delete from aps_plate_process_shop_stat where id = #{id}
    </delete>
    <delete id="deleteApsPlateProcessShopStatByIds" parameterType="String">
        delete from aps_plate_process_shop_stat where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    <delete id="deleteAll" >
        delete from aps_plate_process_shop_stat where del_flag in ('0','1')
    </delete>
    <insert id="batchInsert" parameterType="java.util.List">
        insert into aps_plate_process_shop_stat
        (doc_no, shop_code, shop_name, plan_start_date, plan_end_date, del_flag, create_by, create_time)
        values
        <foreach collection="list" item="item" separator=",">
        (
            #{item.docNo},
            #{item.shopCode},
            #{item.shopName},
            #{item.planStartDate},
            #{item.planEndDate},
            #{item.delFlag},
            #{item.createBy},
            #{item.createTime}
        )
        </foreach>
    </insert>
</mapper>
aps-modules/aps-core/src/main/resources/mapper/core/ApsShopMapper.xml
@@ -27,6 +27,7 @@
            <if test="shopCode != null  and shopCode != ''"> and shop_code = #{shopCode}</if>
            <if test="plantCode != null  and plantCode != ''"> and plant_code = #{plantCode}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
             and status='1'
        </where>
    </select>