huangjiayang
2025-04-25 b079a1727af6eeb2ebcfc44190a9b72a454d4f12
【ADD】增加气体管路产能统计相关代码
已添加6个文件
已修改7个文件
1172 ■■■■■ 文件已修改
aps-modules/aps-core/src/main/java/com/aps/core/controller/ApsGasPipingRouteStatController.java 130 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
aps-modules/aps-core/src/main/java/com/aps/core/controller/basicData/ApsGasPipelineCapacityPlanController.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsGasPipingPlan.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsGasPipingRouteStat.java 150 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsGasPipingPlanMapper.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsGasPipingRouteStatMapper.java 77 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsProcessRouteMapper.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
aps-modules/aps-core/src/main/java/com/aps/core/service/IApsGasPipingRouteStatService.java 85 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsGasPipelineCapacityPlanServiceImpl.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsGasPipingRouteStatServiceImpl.java 472 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
aps-modules/aps-core/src/main/resources/mapper/core/ApsGasPipingPlanMapper.xml 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
aps-modules/aps-core/src/main/resources/mapper/core/ApsGasPipingRouteStatMapper.xml 173 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
aps-modules/aps-core/src/main/resources/mapper/core/ApsProcessRouteMapper.xml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
aps-modules/aps-core/src/main/java/com/aps/core/controller/ApsGasPipingRouteStatController.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,130 @@
package com.aps.core.controller;
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.ApsGasPipingRouteStat;
import com.aps.core.service.IApsGasPipingRouteStatService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
 * æ°”体管路产能负载统计Controller
 *
 * @author hjy
 * @date 2025-04-24
 */
@Tag(name = "气体管路产能负载统计", description = "气体管路产能负载统计接口")
@RestController
@RequestMapping("/apsGasPipingRouteStat")
public class ApsGasPipingRouteStatController extends BaseController
{
    @Autowired
    private IApsGasPipingRouteStatService apsGasPipingRouteStatService;
    /**
     * æŸ¥è¯¢æ°”体管路产能负载统计列表
     */
    @Operation(summary = "查询气体管路产能负载统计列表", description = "分页查询")
    @RequiresPermissions("apsGasPipingRouteStat:apsGasPipingRouteStat:list")
    @GetMapping("/list")
    public TableDataInfo list(@RequestBody ApsGasPipingRouteStat apsGasPipingRouteStat)
    {
        startPage();
        List<ApsGasPipingRouteStat> list = apsGasPipingRouteStatService.selectApsGasPipingRouteStatList(apsGasPipingRouteStat);
        return getDataTable(list);
    }
    /**
     * å¯¼å‡ºæ°”体管路产能负载统计列表
     */
    @Operation(summary = "导出气体管路产能负载统计列表", description = "导出")
    @RequiresPermissions("apsGasPipingRouteStat:apsGasPipingRouteStat:export")
    @Log(title = "气体管路产能负载统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ApsGasPipingRouteStat apsGasPipingRouteStat)
    {
        List<ApsGasPipingRouteStat> list = apsGasPipingRouteStatService.selectApsGasPipingRouteStatList(apsGasPipingRouteStat);
        ExcelUtil<ApsGasPipingRouteStat> util = new ExcelUtil<ApsGasPipingRouteStat>(ApsGasPipingRouteStat.class);
        util.exportExcel(response, list, "气体管路产能负载统计数据");
    }
    /**
     * èŽ·å–æ°”ä½“ç®¡è·¯äº§èƒ½è´Ÿè½½ç»Ÿè®¡è¯¦ç»†ä¿¡æ¯
     */
    @Operation(summary = "获取气体管路产能负载统计详细信息", description = "根据id获取")
    @RequiresPermissions("apsGasPipingRouteStat:apsGasPipingRouteStat:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(apsGasPipingRouteStatService.selectApsGasPipingRouteStatById(id));
    }
    /**
     * æ–°å¢žæ°”体管路产能负载统计
     */
    @Operation(summary = "新增气体管路产能负载统计", description = "单个新增")
    @RequiresPermissions("apsGasPipingRouteStat:apsGasPipingRouteStat:add")
    @Log(title = "气体管路产能负载统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ApsGasPipingRouteStat apsGasPipingRouteStat)
    {
        return toAjax(apsGasPipingRouteStatService.insertApsGasPipingRouteStat(apsGasPipingRouteStat));
    }
    /**
     * ä¿®æ”¹æ°”体管路产能负载统计
     */
    @Operation(summary = "修改气体管路产能负载统计", description = "单个修改")
    @RequiresPermissions("apsGasPipingRouteStat:apsGasPipingRouteStat:edit")
    @Log(title = "气体管路产能负载统计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ApsGasPipingRouteStat apsGasPipingRouteStat)
    {
        return toAjax(apsGasPipingRouteStatService.updateApsGasPipingRouteStat(apsGasPipingRouteStat));
    }
    /**
     * åˆ é™¤æ°”体管路产能负载统计
     */
    @Operation(summary = "删除气体管路产能负载统计", description = "批量删除")
    @RequiresPermissions("apsGasPipingRouteStat:apsGasPipingRouteStat:remove")
    @Log(title = "气体管路产能负载统计", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(apsGasPipingRouteStatService.deleteApsGasPipingRouteStatByIds(ids));
    }
    @Operation(summary = "计算气体管路产能负载统计", description = "计算")
    @PostMapping("/computeCapacity")
    public void computeCapacity()
    {
        apsGasPipingRouteStatService.computeCapacity();
    }
    @Operation(summary = "获取气体管路产能负载统计", description = "计算")
    @PostMapping("/getCapacityPlanData")
    public AjaxResult getCapacityPlanData(@RequestBody ApsGasPipingRouteStat apsGasPipingRouteStat)
    {
        return AjaxResult.success(apsGasPipingRouteStatService.getCapacityPlanData(apsGasPipingRouteStat));
    }
    @Operation(summary = "导出气体管路产能负载统计Excel表", description = "导出")
    @GetMapping("/exportExcel")
    public void exportExcel(@RequestBody ApsGasPipingRouteStat apsGasPipingRouteStat, HttpServletResponse response)
    {
        apsGasPipingRouteStatService.exportExcel(response, apsGasPipingRouteStat);
    }
}
aps-modules/aps-core/src/main/java/com/aps/core/controller/basicData/ApsGasPipelineCapacityPlanController.java
@@ -42,7 +42,7 @@
     * æŸ¥è¯¢æ°”体管路产能规划列表
     */
    @Operation(summary = "查询气体管路产能规划列表", description = "分页查询")
//    @RequiresPermissions("gasPipelineCapacityPlan:gasPipelineCapacityPlan:list")
    @RequiresPermissions("gasPipelineCapacityPlan:gasPipelineCapacityPlan:list")
    @GetMapping("/list")
    public TableDataInfo list(ApsGasPipelineCapacityPlan apsGasPipelineCapacityPlan)
    {
@@ -57,12 +57,13 @@
                apsGasPipelineCapacityPlanTemp.setProcessName(apsStandardProcessTemp.getProcessName());
                list.add(apsGasPipelineCapacityPlanTemp);
            }
        }else if(processList.size()>list.size()){
        }
        if(processList.size()>list.size()){
            List<String> newProcess = new ArrayList<>();
            for(ApsStandardProcess apsStandardProcessTemp : processList){
                boolean flag = true;
                for(ApsGasPipelineCapacityPlan temp : list){
                    if(apsStandardProcessTemp.getMajor().equals(temp.getMajor())){
                    if(apsStandardProcessTemp.getProcessName().equals(temp.getProcessName())){
                        flag = false;
                        break;
                    }
@@ -109,13 +110,13 @@
     * æ–°å¢žæ°”体管路产能规划
     */
    @Operation(summary = "新增气体管路产能规划", description = "单个新增")
    @RequiresPermissions("gasPipelineCapacityPlan:gasPipelineCapacityPlan:add")
//    @RequiresPermissions("gasPipelineCapacityPlan:gasPipelineCapacityPlan:add")
    @Log(title = "气体管路产能规划", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody List<ApsGasPipelineCapacityPlan> apsGasPipelineCapacityPlan)
    {
        apsGasPipelineCapacityPlan.forEach(apsGasPipelineCapacityPlanTemp -> {
            if(apsGasPipelineCapacityPlanTemp.getId()!=null){
            if(apsGasPipelineCapacityPlanTemp.getId()==null){
                apsGasPipelineCapacityPlanService.insertApsGasPipelineCapacityPlan(apsGasPipelineCapacityPlanTemp);
            }else{
                apsGasPipelineCapacityPlanService.updateApsGasPipelineCapacityPlan(apsGasPipelineCapacityPlanTemp);
aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsGasPipingPlan.java
@@ -8,6 +8,7 @@
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
 * æ°”体管路计划管理对象 aps_gas_piping_plan
@@ -171,6 +172,17 @@
    private String planType;
    /** å·¥åºåˆ—表 */
    private List<ApsProcessRoute> apsProcessRoutes;
    public List<ApsProcessRoute> getApsProcessRoutes() {
        return apsProcessRoutes;
    }
    public void setApsProcessRoutes(List<ApsProcessRoute> apsProcessRoutes) {
        this.apsProcessRoutes = apsProcessRoutes;
    }
    public void setId(String id)
    {
        this.id = id;
aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsGasPipingRouteStat.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,150 @@
package com.aps.core.domain;
import com.aps.common.core.annotation.Excel;
import com.aps.common.core.web.domain.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.springframework.data.annotation.Transient;
import java.math.BigDecimal;
import java.util.Date;
/**
 * æ°”体管路产能负载统计对象 aps_gas_piping_route_stat
 *
 * @author hjy
 * @date 2025-04-24
 */
@Schema(description = "气体管路产能负载统计实体类")
@Data
public class ApsGasPipingRouteStat extends BaseEntity
{
    private static final long serialVersionUID = 1L;
    /** ä¸»é”®id */
    @Schema(description = "主键id", type = "Long")
    private String id;
    /** å·¥å•号 */
    @Excel(name = "工单号")
    @Schema(description = "工单号", type = "String")
    private String workOrderNo;
    /** å·¥åºå· */
    @Excel(name = "工序号")
    @Schema(description = "工序号", type = "String")
    private String roadProcessNumber;
    /** å½“前工序号 */
    @Excel(name = "当前工序号")
    @Schema(description = "当前工序号", type = "String")
    private String currentProcessNumber;
    /** ç”Ÿäº§æ•°é‡ */
    @Excel(name = "生产数量")
    @Schema(description = "生产数量", type = "BigDecimal")
    private BigDecimal productionQuantity;
    /** æ ‡å‡†å·¥æ—¶ */
    @Excel(name = "标准工时")
    @Schema(description = "标准工时", type = "BigDecimal")
    private BigDecimal standardTime;
    /** å·¥åºæ€»å·¥æ—¶ */
    @Excel(name = "工序总工时")
    @Schema(description = "工序总工时", type = "BigDecimal")
    private BigDecimal processTotalTime;
    /** è®¡åˆ’开工日 */
    @Excel(name = "计划开工日")
    @Schema(description = "计划开工日", type = "Date")
    private Date processPlanStartDay;
    /** è®¾è®¡å·¥æ—¶ */
    @Excel(name = "设计工时")
    @Schema(description = "设计工时", type = "Long")
    private Long designTimes;
    /** åˆ é™¤æ ‡å¿—(0代表存在 2代表删除) */
    @Schema(description = "删除标志(0代表存在 2代表删除)", type = "String")
    private String delFlag;
    /** å·¥åºåç§° */
    @Excel(name = "工序名称")
    @Schema(description = "工序名称", type = "String")
    private String processName;
    /** æ–™å· */
    @Excel(name = "料号")
    @Schema(description = "料号", type = "String")
    private String itemNumber;
    /** æ ‡å‡†ç”¨é‡ */
    @Excel(name = "标准用量")
    @Schema(description = "标准用量", type = "BigDecimal")
    private BigDecimal standardDosage;
    /** å·¥åºæ€»ç”¨é‡ */
    @Excel(name = "工序总用量")
    @Schema(description = "工序总用量", type = "BigDecimal")
    private BigDecimal processTotalDosage;
    /** è®¾è®¡äº§èƒ½ */
    @Excel(name = "设计产能")
    @Schema(description = "设计产能", type = "BigDecimal")
    private BigDecimal designCapacity;
    /** è®¾è®¡äº§èƒ½ */
    @Excel(name = "专业")
    @Schema(description = "专业", type = "String")
    private String major;
    /** å¹´ */
    @Excel(name = "å¹´")
    @Schema(description = "å¹´", type = "String")
    private String planStartYear;
    /** æœˆ */
    @Excel(name = "月")
    @Schema(description = "月", type = "String")
    private String planStartMonth;
    /** æ—¥ */
    @Excel(name = "日")
    @Schema(description = "日", type = "String")
    private String planStartDay;
    /** æ‰¹æ¬¡å· */
    @Excel(name = "批次号")
    private String batchNumber;
    @Transient
    private String searchStartDate;
    @Transient
    private String searchEndDate;
    @Transient
    private String searchType;
    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("id", getId())
            .append("workOrderNo", getWorkOrderNo())
            .append("roadProcessNumber", getRoadProcessNumber())
            .append("currentProcessNumber", getCurrentProcessNumber())
            .append("productionQuantity", getProductionQuantity())
            .append("standardTime", getStandardTime())
            .append("processTotalTime", getProcessTotalTime())
            .append("processPlanStartDay", getProcessPlanStartDay())
            .append("designTimes", getDesignTimes())
            .append("delFlag", getDelFlag())
            .append("createBy", getCreateBy())
            .append("processName", getProcessName())
            .append("createTime", getCreateTime())
            .toString();
    }
}
aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsGasPipingPlanMapper.java
@@ -1,8 +1,9 @@
package com.aps.core.mapper;
import java.util.List;
import com.aps.core.domain.ApsGasPipingPlan;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
 * æ°”体管路计划管理Mapper接口
@@ -65,4 +66,11 @@
     * @return ç»“æžœ
     */
    int removeAllPlans();
    /**
     * èŽ·å–æ°”ä½“ç®¡è·¯å·¥å•å…³è”å·¥åºæ•°æ®
     * @param apsGasPipingPlan
     * @return
     */
    public List<ApsGasPipingPlan> selectApsGasPipingPlanWithProcess(ApsGasPipingPlan apsGasPipingPlan);
}
aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsGasPipingRouteStatMapper.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,77 @@
package com.aps.core.mapper;
import com.aps.core.domain.ApsGasPipingRouteStat;
import java.util.List;
/**
 * æ°”体管路产能负载统计Mapper接口
 *
 * @author hjy
 * @date 2025-04-24
 */
public interface ApsGasPipingRouteStatMapper
{
    /**
     * æŸ¥è¯¢æ°”体管路产能负载统计
     *
     * @param id æ°”体管路产能负载统计主键
     * @return æ°”体管路产能负载统计
     */
    public ApsGasPipingRouteStat selectApsGasPipingRouteStatById(String id);
    /**
     * æŸ¥è¯¢æ°”体管路产能负载统计列表
     *
     * @param apsGasPipingRouteStat æ°”体管路产能负载统计
     * @return æ°”体管路产能负载统计集合
     */
    public List<ApsGasPipingRouteStat> selectApsGasPipingRouteStatList(ApsGasPipingRouteStat apsGasPipingRouteStat);
    /**
     * æ–°å¢žæ°”体管路产能负载统计
     *
     * @param apsGasPipingRouteStat æ°”体管路产能负载统计
     * @return ç»“æžœ
     */
    public int insertApsGasPipingRouteStat(ApsGasPipingRouteStat apsGasPipingRouteStat);
    /**
     * ä¿®æ”¹æ°”体管路产能负载统计
     *
     * @param apsGasPipingRouteStat æ°”体管路产能负载统计
     * @return ç»“æžœ
     */
    public int updateApsGasPipingRouteStat(ApsGasPipingRouteStat apsGasPipingRouteStat);
    /**
     * åˆ é™¤æ°”体管路产能负载统计
     *
     * @param id æ°”体管路产能负载统计主键
     * @return ç»“æžœ
     */
    public int deleteApsGasPipingRouteStatById(String id);
    /**
     * æ‰¹é‡åˆ é™¤æ°”体管路产能负载统计
     *
     * @param ids éœ€è¦åˆ é™¤çš„æ•°æ®ä¸»é”®é›†åˆ
     * @return ç»“æžœ
     */
    public int deleteApsGasPipingRouteStatByIds(String[] ids);
    /**
     * æ ¹æ®æ‰¹æ¬¡å·åˆ é™¤æ•°æ®
     * @param batchNumber
     * @return
     */
    public int deleteApsGasPipingRouteStatByBatchNum(String batchNumber);
    /**
     * æ‰¹é‡æ’入管路气柜产能数据
     * @param apsGasPipingRouteStatList
     * @return
     */
    public int insertApsGasPipingRouteStatBatch(List<ApsGasPipingRouteStat> apsGasPipingRouteStatList);
}
aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsProcessRouteMapper.java
@@ -67,4 +67,5 @@
     * @return
     */
    public List<ApsProcessRoute> selectProcessNameList(String orgCode);
}
aps-modules/aps-core/src/main/java/com/aps/core/service/IApsGasPipingRouteStatService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,85 @@
package com.aps.core.service;
import com.alibaba.fastjson2.JSONObject;
import com.aps.core.domain.ApsGasPipingRouteStat;
import jakarta.servlet.http.HttpServletResponse;
import java.util.List;
/**
 * æ°”体管路产能负载统计Service接口
 *
 * @author hjy
 * @date 2025-04-24
 */
public interface IApsGasPipingRouteStatService
{
    /**
     * æŸ¥è¯¢æ°”体管路产能负载统计
     *
     * @param id æ°”体管路产能负载统计主键
     * @return æ°”体管路产能负载统计
     */
    public ApsGasPipingRouteStat selectApsGasPipingRouteStatById(String id);
    /**
     * æŸ¥è¯¢æ°”体管路产能负载统计列表
     *
     * @param apsGasPipingRouteStat æ°”体管路产能负载统计
     * @return æ°”体管路产能负载统计集合
     */
    public List<ApsGasPipingRouteStat> selectApsGasPipingRouteStatList(ApsGasPipingRouteStat apsGasPipingRouteStat);
    /**
     * æ–°å¢žæ°”体管路产能负载统计
     *
     * @param apsGasPipingRouteStat æ°”体管路产能负载统计
     * @return ç»“æžœ
     */
    public int insertApsGasPipingRouteStat(ApsGasPipingRouteStat apsGasPipingRouteStat);
    /**
     * ä¿®æ”¹æ°”体管路产能负载统计
     *
     * @param apsGasPipingRouteStat æ°”体管路产能负载统计
     * @return ç»“æžœ
     */
    public int updateApsGasPipingRouteStat(ApsGasPipingRouteStat apsGasPipingRouteStat);
    /**
     * æ‰¹é‡åˆ é™¤æ°”体管路产能负载统计
     *
     * @param ids éœ€è¦åˆ é™¤çš„æ°”体管路产能负载统计主键集合
     * @return ç»“æžœ
     */
    public int deleteApsGasPipingRouteStatByIds(String[] ids);
    /**
     * åˆ é™¤æ°”体管路产能负载统计信息
     *
     * @param id æ°”体管路产能负载统计主键
     * @return ç»“æžœ
     */
    public int deleteApsGasPipingRouteStatById(String id);
    /**
     * è®¡ç®—产能数据到底表
     * @param yearMonth
     * @return
     */
    boolean computeCapacity();
    /**
     * èŽ·å–äº§èƒ½è®¡åˆ’æ•°æ®
     * @param year
     * @param month
     * @return
     */
    public JSONObject getCapacityPlanData(ApsGasPipingRouteStat apsGasPipingRouteStat);
    /**
     * å¯¼å‡ºæ•°æ®
     * @param response
     */
    public void exportExcel(HttpServletResponse response, ApsGasPipingRouteStat apsGasPipingRouteStat);
}
aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsGasPipelineCapacityPlanServiceImpl.java
@@ -1,6 +1,7 @@
package com.aps.core.service.impl;
import com.aps.common.core.utils.DateUtils;
import com.aps.common.security.utils.SecurityUtils;
import com.aps.core.domain.ApsGasPipelineCapacityPlan;
import com.aps.core.mapper.ApsGasPipelineCapacityPlanMapper;
import com.aps.core.service.IApsGasPipelineCapacityPlanService;
@@ -55,6 +56,7 @@
    public int insertApsGasPipelineCapacityPlan(ApsGasPipelineCapacityPlan apsGasPipelineCapacityPlan)
    {
        apsGasPipelineCapacityPlan.setCreateTime(DateUtils.getNowDate());
        apsGasPipelineCapacityPlan.setCreateBy(SecurityUtils.getUsername());
        return apsGasPipelineCapacityPlanMapper.insertApsGasPipelineCapacityPlan(apsGasPipelineCapacityPlan);
    }
@@ -68,6 +70,7 @@
    public int updateApsGasPipelineCapacityPlan(ApsGasPipelineCapacityPlan apsGasPipelineCapacityPlan)
    {
        apsGasPipelineCapacityPlan.setUpdateTime(DateUtils.getNowDate());
        apsGasPipelineCapacityPlan.setUpdateBy(SecurityUtils.getUsername());
        return apsGasPipelineCapacityPlanMapper.updateApsGasPipelineCapacityPlan(apsGasPipelineCapacityPlan);
    }
aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsGasPipingRouteStatServiceImpl.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,472 @@
package com.aps.core.service.impl;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.aps.common.core.utils.DateUtils;
import com.aps.common.core.utils.uuid.IdUtils;
import com.aps.common.security.utils.SecurityUtils;
import com.aps.core.domain.*;
import com.aps.core.mapper.ApsGasPipelineCapacityPlanMapper;
import com.aps.core.mapper.ApsGasPipingPlanMapper;
import com.aps.core.mapper.ApsGasPipingRouteStatMapper;
import com.aps.core.service.IApsGasMaterialUsageService;
import com.aps.core.service.IApsGasPipingRouteStatService;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.util.IOUtils;
import org.apache.poi.xssf.streaming.SXSSFCell;
import org.apache.poi.xssf.streaming.SXSSFRow;
import org.apache.poi.xssf.streaming.SXSSFSheet;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.YearMonth;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.*;
/**
 * æ°”体管路产能负载统计Service业务层处理
 *
 * @author hjy
 * @date 2025-04-24
 */
@Slf4j
@Service
public class ApsGasPipingRouteStatServiceImpl implements IApsGasPipingRouteStatService
{
    @Autowired
    private ApsGasPipingRouteStatMapper apsGasPipingRouteStatMapper;
    @Autowired
    private ApsGasPipingPlanMapper apsGasPipingPlanMapper;
    @Autowired
    private ApsGasPipelineCapacityPlanMapper apsGasPipelineCapacityPlanMapper;
    @Autowired
    private IApsGasMaterialUsageService apsGasMaterialUsageService;
    /**
     * æŸ¥è¯¢æ°”体管路产能负载统计
     *
     * @param id æ°”体管路产能负载统计主键
     * @return æ°”体管路产能负载统计
     */
    @Override
    public ApsGasPipingRouteStat selectApsGasPipingRouteStatById(String id)
    {
        return apsGasPipingRouteStatMapper.selectApsGasPipingRouteStatById(id);
    }
    /**
     * æŸ¥è¯¢æ°”体管路产能负载统计列表
     *
     * @param apsGasPipingRouteStat æ°”体管路产能负载统计
     * @return æ°”体管路产能负载统计
     */
    @Override
    public List<ApsGasPipingRouteStat> selectApsGasPipingRouteStatList(ApsGasPipingRouteStat apsGasPipingRouteStat)
    {
        return apsGasPipingRouteStatMapper.selectApsGasPipingRouteStatList(apsGasPipingRouteStat);
    }
    /**
     * æ–°å¢žæ°”体管路产能负载统计
     *
     * @param apsGasPipingRouteStat æ°”体管路产能负载统计
     * @return ç»“æžœ
     */
    @Override
    public int insertApsGasPipingRouteStat(ApsGasPipingRouteStat apsGasPipingRouteStat)
    {
        apsGasPipingRouteStat.setCreateTime(DateUtils.getNowDate());
        apsGasPipingRouteStat.setCreateBy(SecurityUtils.getUsername());
        return apsGasPipingRouteStatMapper.insertApsGasPipingRouteStat(apsGasPipingRouteStat);
    }
    /**
     * ä¿®æ”¹æ°”体管路产能负载统计
     *
     * @param apsGasPipingRouteStat æ°”体管路产能负载统计
     * @return ç»“æžœ
     */
    @Override
    public int updateApsGasPipingRouteStat(ApsGasPipingRouteStat apsGasPipingRouteStat)
    {
        apsGasPipingRouteStat.setUpdateBy(SecurityUtils.getUsername());
        apsGasPipingRouteStat.setUpdateTime(DateUtils.getNowDate());
        return apsGasPipingRouteStatMapper.updateApsGasPipingRouteStat(apsGasPipingRouteStat);
    }
    /**
     * æ‰¹é‡åˆ é™¤æ°”体管路产能负载统计
     *
     * @param ids éœ€è¦åˆ é™¤çš„æ°”体管路产能负载统计主键
     * @return ç»“æžœ
     */
    @Override
    public int deleteApsGasPipingRouteStatByIds(String[] ids)
    {
        return apsGasPipingRouteStatMapper.deleteApsGasPipingRouteStatByIds(ids);
    }
    /**
     * åˆ é™¤æ°”体管路产能负载统计信息
     *
     * @param id æ°”体管路产能负载统计主键
     * @return ç»“æžœ
     */
    @Override
    public int deleteApsGasPipingRouteStatById(String id)
    {
        return apsGasPipingRouteStatMapper.deleteApsGasPipingRouteStatById(id);
    }
    @Override
    public boolean computeCapacity() {
//        PageHelper.startPage(1, 500);
        List<ApsGasPipingPlan> apsGasPipingPlans = apsGasPipingPlanMapper.selectApsGasPipingPlanWithProcess(new ApsGasPipingPlan());
        List<ApsGasPipingRouteStat> apsGasPipingRouteStatList = new ArrayList<>();
        /*本次计算批次号*/
        String batchNum = IdUtils.fastSimpleUUID();
        try {
            apsGasPipingPlans.forEach(apsGasPipingPlan -> {
                List<ApsProcessRoute> apsProcessRoutes = apsGasPipingPlan.getApsProcessRoutes();
                //按照工序序号升序排序
                apsProcessRoutes.sort((a, b)->a.getProcessNumber().compareTo(b.getProcessNumber()));
                //是否找到当前工序
                boolean isFind = false;
                for (int i=0;i<apsProcessRoutes.size();i++){
                    ApsProcessRoute apsProcessRoute = apsProcessRoutes.get(i);
                    ApsGasPipingRouteStat apsGasPipingRouteStat = new ApsGasPipingRouteStat();
                    //工单号
                    apsGasPipingRouteStat.setWorkOrderNo(apsGasPipingPlan.getDocumentNumber());
                    //料号
                    apsGasPipingRouteStat.setItemNumber(apsGasPipingPlan.getItemNumber());
                    //当前工序号
                    apsGasPipingRouteStat.setCurrentProcessNumber(apsGasPipingPlan.getProcessNumber());
                    //生产数量
                    apsGasPipingRouteStat.setProductionQuantity(apsGasPipingPlan.getProductionQuantity());
                    //工序名称
                    apsGasPipingRouteStat.setProcessName(apsProcessRoute.getProcessName());
                    //工序号
                    apsGasPipingRouteStat.setRoadProcessNumber(apsProcessRoute.getProcessNumber());
                    //标准工时
                    apsGasPipingRouteStat.setStandardTime(apsProcessRoute.getStandardTime());
                    //专业
                    apsGasPipingRouteStat.setMajor(apsGasPipingPlan.getPlanType());
                    //工序总工时 ç­‰äºŽ æ ‡å‡†å·¥æ—¶*生产数量
                    apsGasPipingRouteStat.setProcessTotalTime(apsProcessRoute.getStandardTime().multiply(apsGasPipingPlan.getProductionQuantity()));
                    //计划开工日
                    if(apsGasPipingRouteStat.getCurrentProcessNumber().equals(apsGasPipingRouteStat.getRoadProcessNumber())) {
                        /* å¯¹ stat.getProcessPlanStartDay() å’Œå½“前日期 è¿›è¡Œå¯¹æ¯”,只对比到日,不用管十分秒*/
                        LocalDate startLocalDate = LocalDate.ofInstant(apsProcessRoute.getProcessPlanStartDay().toInstant(), ZoneId.systemDefault());
                        LocalDate nowLocalDate = LocalDate.now();
                        if (startLocalDate.isBefore(nowLocalDate)) {
                            apsGasPipingRouteStat.setProcessPlanStartDay(new Date());
                        }else{
                            apsGasPipingRouteStat.setProcessPlanStartDay(apsProcessRoute.getProcessPlanStartDay());
                        }
                        isFind = true;
                    }
                    if(!isFind){
                        continue;
                    }
                    // ä¸Šä¸€é“工序的结束时间 = ä¸Šä¸€é“工序的开始时间 + ä¸Šä¸€é“工序的总工时
                    if(apsGasPipingRouteStat.getProcessPlanStartDay()==null){
                        LocalDateTime previousProcessPlanStartDay = apsProcessRoutes.get(i - 1).getProcessPlanStartDay().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
                        long previousProcessTotalTime = apsGasPipingRouteStatList.get(i - 1).getProcessTotalTime().longValue();
                        LocalDateTime currentProcessPlanStartDay = previousProcessPlanStartDay.plusHours(previousProcessTotalTime);
                        apsGasPipingRouteStat.setProcessPlanStartDay(Date.from(Timestamp.valueOf(currentProcessPlanStartDay.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))).toInstant()));
                    }
                    //插入 å¹´ æœˆ æ—¥
                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                    String formattedDate = sdf.format(apsGasPipingRouteStat.getProcessPlanStartDay());
                    String[] dateParts = formattedDate.split("-");
                    apsGasPipingRouteStat.setPlanStartYear(String.valueOf(Integer.parseInt(dateParts[0])));
                    apsGasPipingRouteStat.setPlanStartMonth(String.valueOf(Integer.parseInt(dateParts[1])));
                    apsGasPipingRouteStat.setPlanStartDay(String.valueOf(Integer.parseInt(dateParts[2])));
                    //标准用量 æŸ¥è¯¢ç‰©æ–™ç”¨é‡è¡¨
//                    ApsGasMaterialUsage apsGasMaterialUsage = new ApsGasMaterialUsage();
//                    apsGasMaterialUsage.setItemNumber(apsGasPipingPlan.getItemNumber());
//                    apsGasMaterialUsage.setProcessName(apsProcessRoute.getProcessName());
//                    List<ApsGasMaterialUsage> apsGasMaterialUsageList = apsGasMaterialUsageService.selectApsGasMaterialUsageList(apsGasMaterialUsage);
                    apsGasPipingRouteStat.setStandardDosage(apsProcessRoute.getStandardTime().multiply(apsGasPipingPlan.getProductionQuantity()));
                    //工序总用量 = æ ‡å‡†ç”¨é‡*生产数量
                    apsGasPipingRouteStat.setProcessTotalDosage(apsGasPipingRouteStat.getStandardDosage().multiply(apsGasPipingPlan.getProductionQuantity()));
                    apsGasPipingRouteStat.setCreateTime(DateUtils.getNowDate());
                    apsGasPipingRouteStat.setCreateBy("auto");
                    apsGasPipingRouteStat.setBatchNumber(batchNum);
                    apsGasPipingRouteStat.setId(IdUtils.fastSimpleUUID());
                    apsGasPipingRouteStatList.add(apsGasPipingRouteStat);
                }
            });
            List<ApsGasPipingRouteStat> tempInsertList = new ArrayList<>();
            for (int i = 0; i < apsGasPipingRouteStatList.size(); i++) {
                tempInsertList.add(apsGasPipingRouteStatList.get(i));
                if(tempInsertList.size()==500){
                    apsGasPipingRouteStatMapper.insertApsGasPipingRouteStatBatch(tempInsertList);
                    tempInsertList = new ArrayList<>();
                }else if(i==apsGasPipingRouteStatList.size()-1){
                    apsGasPipingRouteStatMapper.insertApsGasPipingRouteStatBatch(tempInsertList);
                }
            }
            apsGasPipingRouteStatMapper.deleteApsGasPipingRouteStatByBatchNum(batchNum);
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
        return true;
    }
    @Override
    public JSONObject getCapacityPlanData(ApsGasPipingRouteStat apsGasPipingRouteStat) {
        JSONObject result = new JSONObject();
        HashSet<String> startPlanTimeSet = new HashSet<>();
        JSONArray processData = new JSONArray();
        try {
            //获取工序计划产能数据
            HashMap<String, ApsGasPipelineCapacityPlan> apsGasPipingPlanMap = new HashMap<>();
            List<ApsGasPipelineCapacityPlan> apsGasPipelineCapacityPlanList = apsGasPipelineCapacityPlanMapper.selectApsGasPipelineCapacityPlanList(new ApsGasPipelineCapacityPlan());
            apsGasPipelineCapacityPlanList.forEach(apsGasPipelineCapacityPlan -> {
                apsGasPipingPlanMap.put(apsGasPipelineCapacityPlan.getProcessName(),apsGasPipelineCapacityPlan);
            });
            //计算日产能数据
            DateTimeFormatter formatter = null;
            List<ApsGasPipingRouteStat> apsGasPipingRouteStats;
            SimpleDateFormat simpleDateFormat = null;
            YearMonth yearMonth = YearMonth.parse(apsGasPipingRouteStat.getSearchEndDate());
            int daysInMonth = yearMonth.lengthOfMonth();
            apsGasPipingRouteStat.setSearchStartDate(apsGasPipingRouteStat.getSearchStartDate()+"-01 00:00:00");
            apsGasPipingRouteStat.setSearchEndDate(apsGasPipingRouteStat.getSearchEndDate()+"-"+ daysInMonth +" 23:59:59");
            if("day".equals(apsGasPipingRouteStat.getSearchType())){
                formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
                simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
            }else if("month".equals(apsGasPipingRouteStat.getSearchType())){
                formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
                simpleDateFormat = new SimpleDateFormat("yyyy-MM");
            }
            apsGasPipingRouteStats = apsGasPipingRouteStatMapper.selectApsGasPipingRouteStatList(apsGasPipingRouteStat);
            //根据开工日进行升序排序
            apsGasPipingRouteStats.sort((a, b)->a.getPlanStartDay().compareTo(b.getPlanStartDay()));
            //工序分组统计
            HashMap<String, List<ApsResourceDateStat>> processMap = new HashMap<>();
            List<HashMap<String, List<ApsResourceDateStat>>> processList = new ArrayList<>();
            HashMap<String, List<ApsResourceDateStat>> processMapMonth = new HashMap<>();
            List<HashMap<String, List<ApsResourceDateStat>>> processListMonth = new ArrayList<>();
            //工序开工日期
            String planStartDate = "";
            for (ApsGasPipingRouteStat apsGasPipingRouteStatTemp : apsGasPipingRouteStats) {
                planStartDate = simpleDateFormat.format(apsGasPipingRouteStatTemp.getProcessPlanStartDay());
                if("month".equals(apsGasPipingRouteStat.getSearchType())){
                    planStartDate = planStartDate+"-01";
                }
                ApsResourceDateStat apsResourceDateStat = new ApsResourceDateStat();
                apsResourceDateStat.setPlanDay(LocalDate.parse(planStartDate, formatter));
                apsResourceDateStat.setResourceName(apsGasPipingRouteStatTemp.getProcessName());
                //查询气柜管路产能规划表
                apsResourceDateStat.setDesignTimes(apsGasPipingPlanMap.get(apsGasPipingRouteStatTemp.getProcessName())!=null?apsGasPipingPlanMap.get(apsGasPipingRouteStatTemp.getProcessName()).getDayProduceAllNum().intValue():0);
                //查询料号工序产能表
                apsResourceDateStat.setRequireTimes(apsGasPipingRouteStatTemp.getProcessTotalTime().intValue());
                if(apsResourceDateStat.getDesignTimes()!=0){
                    apsResourceDateStat.setCapacityLoad(BigDecimal.valueOf(apsResourceDateStat.getRequireTimes()/apsResourceDateStat.getDesignTimes()* 100L));
                }else{
                    apsResourceDateStat.setCapacityLoad(BigDecimal.valueOf(0));
                }
                List<ApsResourceDateStat> apsResourceDateStatList = new ArrayList<>();
                if(processMap.containsKey(apsGasPipingRouteStatTemp.getProcessName())){
                    apsResourceDateStatList = processMap.get(apsGasPipingRouteStatTemp.getProcessName());
                }
                apsResourceDateStatList.add(apsResourceDateStat);
                processMap.put(apsGasPipingRouteStatTemp.getProcessName(), apsResourceDateStatList);
            }
            processMap.forEach((processName, apsResourceDateStatList) -> {
                HashMap<String, ApsResourceDateStat> dayMap = new HashMap<>();
                apsResourceDateStatList.forEach(apsResourceDateStat -> {
                    startPlanTimeSet.add(apsResourceDateStat.getPlanDay().toString());
                    if("month".equals(apsGasPipingRouteStat.getSearchType())){
                        if(dayMap.containsKey(apsResourceDateStat.getPlanDay().toString())){
                            ApsResourceDateStat apsResourceDateStatTemp = dayMap.get(apsResourceDateStat.getPlanDay().toString());
                            apsResourceDateStatTemp.setDesignTimes(apsGasPipingPlanMap.get(processName)!=null?apsGasPipingPlanMap.get(processName).getMonthProduceAllNum().intValue():0);
                            apsResourceDateStatTemp.setRequireTimes(apsResourceDateStatTemp.getRequireTimes()+apsResourceDateStat.getRequireTimes());
                            if(apsResourceDateStatTemp.getDesignTimes()!=0){
                                apsResourceDateStatTemp.setCapacityLoad(BigDecimal.valueOf(apsResourceDateStatTemp.getRequireTimes()/apsResourceDateStatTemp.getDesignTimes()* 100L));
                            }else{
                                apsResourceDateStatTemp.setCapacityLoad(BigDecimal.valueOf(0));
                            }
                            apsResourceDateStatTemp.setResourceGroupName(processName);
                            apsResourceDateStatTemp.setPlanDay(apsResourceDateStat.getPlanDay());
                            dayMap.put(apsResourceDateStat.getPlanDay().toString(), apsResourceDateStatTemp);
                        }else{
                            dayMap.put(apsResourceDateStat.getPlanDay().toString(), apsResourceDateStat);
                        }
                    }
                });
                if("month".equals(apsGasPipingRouteStat.getSearchType())){
                    List<ApsResourceDateStat> tempList = new ArrayList<>();
                    dayMap.forEach((key, value) -> {
                        tempList.add(value);
                    });
                    processMapMonth.put(processName, tempList);
                }
            });
            List<String> sortedStartPlanTimeList = new ArrayList<>(startPlanTimeSet);
            Collections.sort(sortedStartPlanTimeList);
//            processMap.forEach((processName, apsResourceDateStatList) -> {
//                HashMap<String, ApsResourceDateStat> dayMap = new HashMap<>();
//                apsResourceDateStatList.forEach(apsResourceDateStat -> {
//                    startPlanTimeSet.add(apsResourceDateStat.getPlanDay().toString());
//                    if(dayMap.containsKey(apsResourceDateStat.getPlanDay().toString())){
//                        ApsResourceDateStat apsResourceDateStatTemp = dayMap.get(apsResourceDateStat.getPlanDay().toString());
//                        if("day".equals(apsGasPipingRouteStat.getSearchType())){
//                            apsResourceDateStatTemp.setDesignTimes(apsResourceDateStatTemp.getDesignTimes()+apsResourceDateStat.getDesignTimes());
//                        }else if("month".equals(apsGasPipingRouteStat.getSearchType())){
//                            apsResourceDateStatTemp.setDesignTimes(apsGasPipingPlanMap.get(processName)!=null?apsGasPipingPlanMap.get(processName).getMonthProduceAllNum().intValue():0);
//                        }
//                        apsResourceDateStatTemp.setRequireTimes(apsResourceDateStatTemp.getRequireTimes()+apsResourceDateStat.getRequireTimes());
//                        if(apsResourceDateStatTemp.getDesignTimes()!=0){
//                            apsResourceDateStatTemp.setCapacityLoad(BigDecimal.valueOf(apsResourceDateStatTemp.getRequireTimes()/apsResourceDateStatTemp.getDesignTimes()* 100L));
//                        }
//                        apsResourceDateStatTemp.setResourceGroupName(processName);
//                        dayMap.put(apsResourceDateStat.getPlanDay().toString(), apsResourceDateStatTemp);
//                    }else{
//                        dayMap.put(apsResourceDateStat.getPlanDay().toString(), apsResourceDateStat);
//                    }
//                });
//                JSONArray tempList = new JSONArray();
//                dayMap.forEach((key, value) -> {
//                    JSONObject temp = new JSONObject();
//                    temp.put("planDay", key);
//                    temp.put("designTimes", value.getDesignTimes());
//                    temp.put("requireTimes", value.getRequireTimes());
//                    temp.put("capacityLoad", value.getCapacityLoad());
//                    temp.put("resourceGroupName", value.getResourceGroupName());
//                    tempList.add(temp);
//                });
//                processData.add(new JSONObject().put(processName, tempList));
//            });
            if("month".equals(apsGasPipingRouteStat.getSearchType())){
                for (String key : processMapMonth.keySet()) {
                    HashMap<String, List<ApsResourceDateStat>> temp = new HashMap<>();
                    temp.put(key, processMapMonth.get(key));
                    processListMonth.add(temp);
                }
                result.put("planTable", processListMonth);
            }else{
                for (String key : processMap.keySet()) {
                    HashMap<String, List<ApsResourceDateStat>> temp = new HashMap<>();
                    temp.put(key, processMap.get(key));
                    processList.add(temp);
                }
                result.put("planTable", processList);
            }
            result.put("planTitle", sortedStartPlanTimeList);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
    }
    @Override
    public void exportExcel(HttpServletResponse response, ApsGasPipingRouteStat apsGasPipingRouteStat) {
        SXSSFWorkbook wb = new SXSSFWorkbook(500);
        wb.createSheet();
        wb.setSheetName(0, "气柜管路产能负载统计表");
        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
        response.setCharacterEncoding("utf-8");
        Map<String, CellStyle> styles = createStyles(wb);
        CellStyle title = styles.get("title");
        try
        {
            JSONObject stat = getCapacityPlanData(apsGasPipingRouteStat);
            List<String> days = (List<String>) stat.get("planTitle");
            List<HashMap<String, List<ApsResourceDateStat>>> table= (List<HashMap<String, List<ApsResourceDateStat>>>) stat.get("planTable");
            SXSSFSheet sheet = wb.getSheetAt(0);
            /*填写日期列 å’Œ å·¥æ—¶åˆ—*/
            SXSSFRow rowDay = sheet.createRow(0);
            SXSSFRow rowTitle = sheet.createRow(1);
            SXSSFCell daytitle = rowDay.createCell(0);
            daytitle.setCellValue("日期");
            daytitle.setCellStyle(title);
            SXSSFCell titleCell = rowTitle.createCell(0);
            titleCell.setCellValue("工序");
            titleCell.setCellStyle(title);
            for (int i = 0; i < days.size(); i++) {
                SXSSFCell dateCell = rowDay.createCell(i * 3 + 1);
                SXSSFCell designHoursCell = rowTitle.createCell(i * 3 + 1);
                SXSSFCell requireHoursCell = rowTitle.createCell(i * 3 + 2);
                SXSSFCell loadCell = rowTitle.createCell(i * 3 + 3);
                dateCell.setCellValue(days.get(i));
                designHoursCell.setCellValue("设计工时");
                requireHoursCell.setCellValue("需求工时");
                loadCell.setCellValue("产能负荷");
                /*set cell style*/
                dateCell.setCellStyle(title);
                designHoursCell.setCellStyle(title);
                requireHoursCell.setCellStyle(title);
                loadCell.setCellStyle(title);
                /*合并日期单元格*/
                sheet.addMergedRegion( new CellRangeAddress(0, 0, i*3+1, i*3+3));
            }
            for (int i = 0; i < table.size(); i++) {
                Map<String, List<ApsResourceDateStat>> resourceList = table.get(i);
                /*创建数据行*/
                SXSSFRow dataRow  = sheet.createRow(i+2);
                for( Map.Entry<String, List<ApsResourceDateStat>> entry : resourceList.entrySet()){
                    String resourceName = entry.getKey();
                    List<ApsResourceDateStat> resourceDateStats = entry.getValue();
                    dataRow.createCell(0).setCellValue(resourceName);
                    for (int j = 0; j < resourceDateStats.size(); j++) {
                        ApsResourceDateStat apsResourceDateStat = resourceDateStats.get(j);
                        dataRow.createCell(j*3+1).setCellValue(apsResourceDateStat.getDesignTimes());
                        dataRow.createCell(j*3+2).setCellValue(apsResourceDateStat.getRequireTimes());
                        if(apsResourceDateStat.getCapacityLoad()!=null){
                            dataRow.createCell(j*3+3).setCellValue(apsResourceDateStat.getCapacityLoad().doubleValue()+"%");
                        }else{
                            dataRow.createCell(j*3+3).setCellValue("%");
                        }
                    }
                }
            }
            wb.write(response.getOutputStream());
        }
        catch (Exception e)
        {
            log.error("导出Excel异常{}", e.getMessage());
        }
        finally
        {
            IOUtils.closeQuietly(wb);
        }
    }
    private Map<String,CellStyle> createStyles(SXSSFWorkbook wb)
    {
        Map<String,CellStyle> styles=new HashMap<>();
        CellStyle style = wb.createCellStyle();
        style.setAlignment(HorizontalAlignment.CENTER);
        style.setVerticalAlignment(VerticalAlignment.CENTER);
        Font titleFont = wb.createFont();
        titleFont.setFontName("Arial");
        titleFont.setFontHeightInPoints((short) 12);
        titleFont.setBold(true);
        style.setFont(titleFont);
        DataFormat dataFormat = wb.createDataFormat();
        style.setDataFormat(dataFormat.getFormat("@"));
        styles.put("title", style);
        return styles;
    }
}
aps-modules/aps-core/src/main/resources/mapper/core/ApsGasPipingPlanMapper.xml
@@ -41,6 +41,46 @@
        <result property="hasTurnback"    column="has_turnback"    />
        <result property="hasRisk"    column="has_risk"    />
        <result property="planType"    column="plan_type"    />
<!--        <collection property="apsProcessRoutes" javaType="java.util.ArrayList" ofType="com.aps.core.domain.ApsProcessRoute">-->
<!--            <result property="id"    column="id"    />-->
<!--            <result property="itemNo"    column="item_no"    />-->
<!--            <result property="workOrderNo"    column="work_order_no"    />-->
<!--            <result property="processNumber"    column="process_number_sub"    />-->
<!--            <result property="processName"    column="process_name"    />-->
<!--            <result property="processPlanStartDay"    column="process_plan_start_day"    />-->
<!--            <result property="processPlanEndDay"    column="process_plan_end_day"    />-->
<!--            <result property="notStartWorkCount"    column="not_start_work_count"    />-->
<!--            <result property="completedCount"    column="completed_count"    />-->
<!--            <result property="discardCount"    column="discard_count"    />-->
<!--            <result property="integrationDay"    column="integration_day"    />-->
<!--            <result property="plant"    column="plant"    />-->
<!--            <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"    />-->
<!--            <result property="standardTime"    column="standard_time"    />-->
<!--            <result property="processOrder"    column="process_order"    />-->
<!--            <result property="workCenter"    column="work_center"    />-->
<!--            <result property="processQty"    column="process_qty"    />-->
<!--            <result property="opStatus"    column="op_status"    />-->
<!--            <result property="opStatus"    column="op_status"    />-->
<!--            <result property="orgCode"    column="org_code"    />-->
<!--        </collection>-->
    </resultMap>
    <resultMap type="ApsGasPipingPlan" id="ApsGasPipingPlanResultWithProcess">
        <result property="documentNumber"    column="document_number"    />
        <result property="itemNumber"    column="item_number"    />
        <result property="productionQuantity"    column="production_quantity"    />
        <result property="processNumber"    column="process_number"    />
        <result property="planType"    column="plan_type"    />
        <collection property="apsProcessRoutes" javaType="java.util.ArrayList" ofType="com.aps.core.domain.ApsProcessRoute">
            <result property="processNumber"    column="process_number_sub"    />
            <result property="processName"    column="process_name"    />
            <result property="processPlanStartDay"    column="process_plan_start_day"    />
            <result property="standardTime"    column="standard_time"    />
        </collection>
    </resultMap>
    <sql id="selectApsGasPipingPlanVo">
@@ -233,4 +273,11 @@
    <update id="removeAllPlans" >
        update  aps_gas_piping_plan  set del_flag='1' where del_flag ='0'
    </update>
    <select id="selectApsGasPipingPlanWithProcess" parameterType="ApsGasPipingPlan" resultMap="ApsGasPipingPlanResultWithProcess">
        select c.* from (select a.document_number,a.item_number,a.process_number,a.production_quantity,a.plan_type,b.process_name,b.process_number as process_number_sub,b.standard_time,b.process_plan_start_day from aps_gas_piping_plan a
            left join aps_process_route b on a.document_number = b.work_order_no
            where a.document_status in ('0','1','2','4') and b.process_plan_start_day is not null ORDER BY a.document_number,b.process_number) c GROUP BY c.document_number,c.item_number,c.process_number,c.production_quantity,c.process_name,c.process_number_sub,c.standard_time,c.process_plan_start_day,c.plan_type
    </select>
</mapper>
aps-modules/aps-core/src/main/resources/mapper/core/ApsGasPipingRouteStatMapper.xml
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,173 @@
<?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.ApsGasPipingRouteStatMapper">
    <resultMap type="ApsGasPipingRouteStat" id="ApsGasPipingRouteStatResult">
        <result property="id"    column="id"    />
        <result property="workOrderNo"    column="work_order_no"    />
        <result property="roadProcessNumber"    column="road_process_number"    />
        <result property="currentProcessNumber"    column="current_process_number"    />
        <result property="productionQuantity"    column="production_quantity"    />
        <result property="standardTime"    column="standard_time"    />
        <result property="processTotalTime"    column="process_total_time"    />
        <result property="processPlanStartDay"    column="process_plan_start_day"    />
        <result property="designTimes"    column="design_times"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createBy"    column="create_by"    />
        <result property="processName"    column="process_name"    />
        <result property="createTime"    column="create_time"    />
        <result property="itemNumber"    column="item_number"    />
        <result property="standardDosage"    column="standard_dosage"    />
        <result property="processTotalDosage"    column="process_total_dosage"    />
        <result property="designCapacity"    column="design_capacity"    />
        <result property="major"    column="major"    />
        <result property="planStartYear"    column="plan_start_year"    />
        <result property="planStartMonth"    column="plan_start_month"    />
        <result property="planStartDay"    column="plan_start_day"    />
    </resultMap>
    <sql id="selectApsGasPipingRouteStatVo">
        select id, work_order_no, road_process_number, current_process_number, production_quantity, standard_time, process_total_time, process_plan_start_day, design_times, del_flag, create_by, process_name, create_time, item_number, standard_dosage, process_total_dosage, design_capacity, major, plan_start_year, plan_start_month, plan_start_day from aps_gas_piping_route_stat
    </sql>
    <select id="selectApsGasPipingRouteStatList" parameterType="ApsGasPipingRouteStat" resultMap="ApsGasPipingRouteStatResult">
        <include refid="selectApsGasPipingRouteStatVo"/>
        <where>
            <if test="workOrderNo != null  and workOrderNo != ''"> and work_order_no = #{workOrderNo}</if>
            <if test="roadProcessNumber != null  and roadProcessNumber != ''"> and road_process_number = #{roadProcessNumber}</if>
            <if test="currentProcessNumber != null  and currentProcessNumber != ''"> and current_process_number = #{currentProcessNumber}</if>
            <if test="productionQuantity != null  and productionQuantity != ''"> and production_quantity = #{productionQuantity}</if>
            <if test="standardTime != null  and standardTime != ''"> and standard_time = #{standardTime}</if>
            <if test="processTotalTime != null  and processTotalTime != ''"> and process_total_time = #{processTotalTime}</if>
            <if test="processPlanStartDay != null  and processPlanStartDay != ''"> and process_plan_start_day = #{processPlanStartDay}</if>
            <if test="designTimes != null "> and design_times = #{designTimes}</if>
            <if test="processName != null  and processName != ''"> and process_name like '%' || #{processName} || '%')</if>
            <if test="major != null and major != ''"> and major = #{major} </if>
            <if test="planStartYear != null and planStartYear != ''"> and plan_start_year = #{planStartYear} </if>
            <if test="planStartMonth != null and planStartMonth != ''"> and plan_start_month = #{planStartMonth} </if>
            <if test="planStartDay != null and planStartDay != ''"> and plan_start_day = #{planStartDay} </if>
            <if test="searchStartDate != null and searchStartDate != '' and searchEndDate != null and searchEndDate != ''"> and (process_plan_start_day &gt;= #{searchStartDate} and process_plan_start_day &lt;= #{searchEndDate}) </if>
        </where>
    </select>
    <select id="selectApsGasPipingRouteStatById" parameterType="String" resultMap="ApsGasPipingRouteStatResult">
        <include refid="selectApsGasPipingRouteStatVo"/>
        where id = #{id}
    </select>
    <insert id="insertApsGasPipingRouteStat" parameterType="ApsGasPipingRouteStat">
        insert into aps_gas_piping_route_stat
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="workOrderNo != null">work_order_no,</if>
            <if test="roadProcessNumber != null and roadProcessNumber != ''">road_process_number,</if>
            <if test="currentProcessNumber != null">current_process_number,</if>
            <if test="productionQuantity != null">production_quantity,</if>
            <if test="standardTime != null">standard_time,</if>
            <if test="processTotalTime != null">process_total_time,</if>
            <if test="processPlanStartDay != null and processPlanStartDay != ''">process_plan_start_day,</if>
            <if test="designTimes != null">design_times,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createBy != null">create_by,</if>
            <if test="processName != null">process_name,</if>
            <if test="createTime != null">create_time,</if>
            <if test="itemNumber != null">item_number,</if>
            <if test="standardDosage != null">standard_dosage,</if>
            <if test="processTotalDosage != null">process_total_dosage,</if>
            <if test="designCapacity != null">design_capacity,</if>
            <if test="major != null">major,</if>
            <if test="planStartYear != null">plan_start_year,</if>
            <if test="planStartMonth != null">plan_start_month,</if>
            <if test="planStartDay != null">plan_start_day,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="workOrderNo != null">#{workOrderNo},</if>
            <if test="roadProcessNumber != null and roadProcessNumber != ''">#{roadProcessNumber},</if>
            <if test="currentProcessNumber != null">#{currentProcessNumber},</if>
            <if test="productionQuantity != null">#{productionQuantity},</if>
            <if test="standardTime != null">#{standardTime},</if>
            <if test="processTotalTime != null">#{processTotalTime},</if>
            <if test="processPlanStartDay != null and processPlanStartDay != ''">#{processPlanStartDay},</if>
            <if test="designTimes != null">#{designTimes},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="processName != null">#{processName},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="itemNumber != null">#{itemNumber},</if>
            <if test="standardDosage != null">#{standardDosage},</if>
            <if test="processTotalDosage != null">#{processTotalDosage},</if>
            <if test="designCapacity != null">#{designCapacity},</if>
            <if test="major != null">#{major},</if>
            <if test="planStartYear != null">#{planStartYear},</if>
            <if test="planStartMonth != null">#{planStartMonth},</if>
            <if test="planStartDay != null">#{planStartDay},</if>
         </trim>
    </insert>
    <update id="updateApsGasPipingRouteStat" parameterType="ApsGasPipingRouteStat">
        update aps_gas_piping_route_stat
        <trim prefix="SET" suffixOverrides=",">
            <if test="workOrderNo != null">work_order_no = #{workOrderNo},</if>
            <if test="roadProcessNumber != null and roadProcessNumber != ''">road_process_number = #{roadProcessNumber},</if>
            <if test="currentProcessNumber != null">current_process_number = #{currentProcessNumber},</if>
            <if test="productionQuantity != null">production_quantity = #{productionQuantity},</if>
            <if test="standardTime != null">standard_time = #{standardTime},</if>
            <if test="processTotalTime != null">process_total_time = #{processTotalTime},</if>
            <if test="processPlanStartDay != null and processPlanStartDay != ''">process_plan_start_day = #{processPlanStartDay},</if>
            <if test="designTimes != null">design_times = #{designTimes},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="processName != null">process_name = #{processName},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="itemNumber != null">item_number = #{itemNumber},</if>
            <if test="standardDosage != null">standard_dosage = #{standardDosage},</if>
            <if test="processTotalDosage != null">process_total_dosage = #{processTotalDosage},</if>
            <if test="designCapacity != null">design_capacity = #{designCapacity},</if>
            <if test="major != null">major = #{major},</if>
            <if test="planStartYear != null">plan_start_year = #{planStartYear},</if>
            <if test="planStartMonth != null">plan_start_month = #{planStartMonth},</if>
            <if test="planStartDay != null">plan_start_day = #{planStartDay},</if>
        </trim>
        where id = #{id}
    </update>
    <delete id="deleteApsGasPipingRouteStatById" parameterType="String">
        delete from aps_gas_piping_route_stat where id = #{id}
    </delete>
    <delete id="deleteApsGasPipingRouteStatByIds" parameterType="String">
        delete from aps_gas_piping_route_stat where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    <delete id="deleteApsGasPipingRouteStatByBatchNum" parameterType="String">
        delete from aps_gas_piping_route_stat where batch_number != #{batchNumber}
    </delete>
    <insert id="insertApsGasPipingRouteStatBatch">
        INSERT INTO aps_gas_piping_route_stat
        (
        id,work_order_no, road_process_number, current_process_number, production_quantity, standard_time,
        process_total_time, process_plan_start_day, design_times, del_flag, create_by, process_name,
        create_time, item_number, standard_dosage, process_total_dosage, design_capacity, major,
        plan_start_year, plan_start_month, plan_start_day,batch_number
        )
        VALUES
        <foreach collection="apsGasPipingRouteStatList" item="stat" separator=",">
            (
            #{stat.id},#{stat.workOrderNo}, #{stat.roadProcessNumber}, #{stat.currentProcessNumber}, #{stat.productionQuantity},
            #{stat.standardTime}, #{stat.processTotalTime}, #{stat.processPlanStartDay}, #{stat.designTimes}, #{stat.delFlag},
            #{stat.createBy}, #{stat.processName}, #{stat.createTime}, #{stat.itemNumber}, #{stat.standardDosage},
            #{stat.processTotalDosage}, #{stat.designCapacity}, #{stat.major}, #{stat.planStartYear},
            #{stat.planStartMonth}, #{stat.planStartDay}, #{stat.batchNumber}
            )
        </foreach>
    </insert>
</mapper>
aps-modules/aps-core/src/main/resources/mapper/core/ApsProcessRouteMapper.xml
@@ -145,4 +145,5 @@
    <select id="selectProcessNameList" parameterType="String" resultMap="ApsProcessRouteResult">
        select DISTINCT process_name from aps_process_route where org_code = #{orgCode}
    </select>
</mapper>