Browse Source

优化 滚动计划提报流程

dev
xiaoyu 1 month ago
parent
commit
33d0fd9333
  1. 9
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/gss/DhcProductInfoController.java
  2. 11
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/RollingPlanController.java
  3. 41
      ruoyi-common/src/main/java/com/ruoyi/common/utils/WeekDateDeserializer.java
  4. 10
      ruoyi-system/src/main/java/com/ruoyi/gss/mapper/DhcProductInfoMapper.java
  5. 16
      ruoyi-system/src/main/java/com/ruoyi/gss/service/IDhcProductInfoService.java
  6. 11
      ruoyi-system/src/main/java/com/ruoyi/gss/service/impl/DhcProductInfoServiceImpl.java
  7. 5
      ruoyi-system/src/main/java/com/ruoyi/system/domain/SalesAreaReport.java
  8. 8
      ruoyi-system/src/main/java/com/ruoyi/system/mapper/RollingPlanMapper.java
  9. 8
      ruoyi-system/src/main/java/com/ruoyi/system/service/IRollingPlanService.java
  10. 137
      ruoyi-system/src/main/java/com/ruoyi/system/service/impl/RollingPlanServiceImpl.java
  11. 14
      ruoyi-system/src/main/resources/mapper/gss/DhcProductInfoMapper.xml
  12. 113
      ruoyi-system/src/main/resources/mapper/system/RollingPlanMapper.xml

9
ruoyi-admin/src/main/java/com/ruoyi/web/controller/gss/DhcProductInfoController.java

@ -54,6 +54,15 @@ public class DhcProductInfoController extends BaseController { @@ -54,6 +54,15 @@ public class DhcProductInfoController extends BaseController {
return success(dhcProductInfoService.selectDhcProductInfoById(productId));
}
/**
* 根据产品编码查询产品信息
*/
@PreAuthorize("@ss.hasPermi('gss:product:query')")
@GetMapping("/code/{productCode}")
public AjaxResult getInfoByCode(@PathVariable("productCode") String productCode) {
return success(dhcProductInfoService.selectDhcProductInfoByCode(productCode));
}
/**
* 新增产品
*/

11
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/RollingPlanController.java

@ -127,4 +127,15 @@ public class RollingPlanController extends BaseController @@ -127,4 +127,15 @@ public class RollingPlanController extends BaseController
rollingPlan.setAuditTime(new Date());
return toAjax(rollingPlanService.auditRollingPlan(rollingPlan));
}
/**
* 批量保存滚动计划
*/
@PreAuthorize("@ss.hasPermi('system:rolling-plan:add')")
@Log(title = "滚动计划", businessType = BusinessType.INSERT)
@PostMapping("/batchSave")
public AjaxResult batchSave(@RequestBody List<RollingPlan> planList)
{
return toAjax(rollingPlanService.batchSaveRollingPlan(planList));
}
}

41
ruoyi-common/src/main/java/com/ruoyi/common/utils/WeekDateDeserializer.java

@ -0,0 +1,41 @@ @@ -0,0 +1,41 @@
package com.ruoyi.common.utils;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import java.io.IOException;
import java.util.Calendar;
import java.util.Date;
public class WeekDateDeserializer extends JsonDeserializer<Date> {
@Override
public Date deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
String dateStr = p.getText();
// 处理周格式 (例如: "2025-W15")
if (dateStr.matches("\\d{4}-W\\d{2}")) {
try {
String[] parts = dateStr.split("-W");
int year = Integer.parseInt(parts[0]);
int week = Integer.parseInt(parts[1]);
Calendar cal = Calendar.getInstance();
cal.clear();
cal.set(Calendar.YEAR, year);
cal.set(Calendar.WEEK_OF_YEAR, week);
cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
return cal.getTime();
} catch (Exception e) {
throw new IOException("无效的周日期格式: " + dateStr, e);
}
}
// 如果不是周格式,尝试标准日期格式
try {
return DateUtils.parseDate(dateStr);
} catch (Exception e) {
throw new IOException("无效的日期格式: " + dateStr, e);
}
}
}

10
ruoyi-system/src/main/java/com/ruoyi/gss/mapper/DhcProductInfoMapper.java

@ -13,4 +13,14 @@ public interface DhcProductInfoMapper { @@ -13,4 +13,14 @@ public interface DhcProductInfoMapper {
public int updateDhcProductInfo(DhcProductInfo dhcProductInfo);
public int deleteDhcProductInfoByIds(Long[] productIds);
public DhcProductInfo selectDhcProductInfoByCode(String productCode);
/**
* 根据产品编码列表批量查询产品信息
*
* @param productCodes 产品编码列表
* @return 产品信息列表
*/
public List<DhcProductInfo> selectDhcProductInfoByCodes(List<String> productCodes);
}

16
ruoyi-system/src/main/java/com/ruoyi/gss/service/IDhcProductInfoService.java

@ -13,4 +13,20 @@ public interface IDhcProductInfoService { @@ -13,4 +13,20 @@ public interface IDhcProductInfoService {
public int updateDhcProductInfo(DhcProductInfo dhcProductInfo);
public int deleteDhcProductInfoByIds(Long[] productIds);
/**
* 根据产品编码查询产品信息
*
* @param productCode 产品编码
* @return 产品信息
*/
public DhcProductInfo selectDhcProductInfoByCode(String productCode);
/**
* 批量查询产品信息
*
* @param productCodes 产品编码列表
* @return 产品信息列表
*/
public List<DhcProductInfo> selectDhcProductInfoByCodes(List<String> productCodes);
}

11
ruoyi-system/src/main/java/com/ruoyi/gss/service/impl/DhcProductInfoServiceImpl.java

@ -36,4 +36,15 @@ public class DhcProductInfoServiceImpl implements IDhcProductInfoService { @@ -36,4 +36,15 @@ public class DhcProductInfoServiceImpl implements IDhcProductInfoService {
public int deleteDhcProductInfoByIds(Long[] productIds) {
return dhcProductInfoMapper.deleteDhcProductInfoByIds(productIds);
}
@Override
public DhcProductInfo selectDhcProductInfoByCode(String productCode) {
return dhcProductInfoMapper.selectDhcProductInfoByCode(productCode);
}
@Override
public List<DhcProductInfo> selectDhcProductInfoByCodes(List<String> productCodes) {
return dhcProductInfoMapper.selectDhcProductInfoByCodes(productCodes);
}
}

5
ruoyi-system/src/main/java/com/ruoyi/system/domain/SalesAreaReport.java

@ -3,6 +3,9 @@ package com.ruoyi.system.domain; @@ -3,6 +3,9 @@ package com.ruoyi.system.domain;
import java.util.Date;
import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.common.annotation.Excel;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.ruoyi.common.utils.WeekDateDeserializer;
public class SalesAreaReport extends BaseEntity {
private static final long serialVersionUID = 1L;
@ -32,6 +35,8 @@ public class SalesAreaReport extends BaseEntity { @@ -32,6 +35,8 @@ public class SalesAreaReport extends BaseEntity {
private String reportStatus;
@Excel(name = "报告时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd")
@JsonDeserialize(using = WeekDateDeserializer.class)
private Date reportTime;
// getter/setter方法

8
ruoyi-system/src/main/java/com/ruoyi/system/mapper/RollingPlanMapper.java

@ -57,4 +57,12 @@ public interface RollingPlanMapper @@ -57,4 +57,12 @@ public interface RollingPlanMapper
* @return 结果
*/
public int deleteRollingPlanByPlanIds(Long[] planIds);
/**
* 批量新增滚动计划
*
* @param planList 滚动计划列表
* @return 结果
*/
public int batchInsertRollingPlan(List<RollingPlan> planList);
}

8
ruoyi-system/src/main/java/com/ruoyi/system/service/IRollingPlanService.java

@ -73,4 +73,12 @@ public interface IRollingPlanService @@ -73,4 +73,12 @@ public interface IRollingPlanService
* @return 结果
*/
public int deleteRollingPlanByPlanId(Long planId);
/**
* 批量保存滚动计划
*
* @param planList 滚动计划列表
* @return 结果
*/
public int batchSaveRollingPlan(List<RollingPlan> planList);
}

137
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/RollingPlanServiceImpl.java

@ -8,6 +8,8 @@ import com.ruoyi.common.utils.DateUtils; // 添加 DateUtils 的导入 @@ -8,6 +8,8 @@ import com.ruoyi.common.utils.DateUtils; // 添加 DateUtils 的导入
import com.ruoyi.system.mapper.RollingPlanMapper;
import com.ruoyi.system.domain.RollingPlan;
import com.ruoyi.system.service.IRollingPlanService;
// 在文件顶部的 import 部分添加
import org.springframework.util.CollectionUtils;
/**
* 滚动计划Service业务层处理
@ -117,4 +119,139 @@ public class RollingPlanServiceImpl implements IRollingPlanService @@ -117,4 +119,139 @@ public class RollingPlanServiceImpl implements IRollingPlanService
{
return rollingPlanMapper.updateRollingPlan(rollingPlan);
}
@Override
public int batchSaveRollingPlan(List<RollingPlan> planList) {
if (CollectionUtils.isEmpty(planList)) {
return 0;
}
Date now = DateUtils.getNowDate();
String datePrefix = DateUtils.dateTimeNow("yyyyMMdd");
// 查询当天最大的计划编号
RollingPlan queryPlan = new RollingPlan();
queryPlan.setPlanNumber(datePrefix);
List<RollingPlan> existingPlans = rollingPlanMapper.selectRollingPlanList(queryPlan);
int startSequence = 1;
if (!CollectionUtils.isEmpty(existingPlans)) {
for (RollingPlan existingPlan : existingPlans) {
String existingNumber = existingPlan.getPlanNumber();
if (existingNumber != null && existingNumber.length() > 8) {
try {
int sequence = Integer.parseInt(existingNumber.substring(8));
startSequence = Math.max(startSequence, sequence + 1);
} catch (NumberFormatException e) {
// 忽略无效的编号格式
}
}
}
}
for (int i = 0; i < planList.size(); i++) {
RollingPlan plan = planList.get(i);
// 生成计划编号
String planNumber = datePrefix + String.format("%05d", startSequence + i);
plan.setPlanNumber(planNumber);
// 设置机器码(使用产品版本号)
plan.setMachineCode(plan.getProductionVersion());
// 设置其他必填字段的默认值
plan.setPlanYear(plan.getPlanYear() != null ? plan.getPlanYear() :
Integer.parseInt(DateUtils.dateTimeNow("yyyy")));
plan.setVersionWeek(plan.getVersionWeek() != null ? plan.getVersionWeek() :
DateUtils.dateTimeNow("ww"));
plan.setProductionMode(plan.getProductionMode() != null ? plan.getProductionMode() : "01");
plan.setStatus(plan.getStatus() != null ? plan.getStatus() : "0");
plan.setAuditStatus(plan.getAuditStatus() != null ? plan.getAuditStatus() : "0");
plan.setIsZeroExecution(plan.getIsZeroExecution() != null ? plan.getIsZeroExecution() : "0");
plan.setIsFirstOrder(plan.getIsFirstOrder() != null ? plan.getIsFirstOrder() : "0");
plan.setIsDirectDelivery(plan.getIsDirectDelivery() != null ? plan.getIsDirectDelivery() : "0");
// 设置销售和客户相关默认值
if (plan.getSalesAreaCode() == null) {
plan.setSalesAreaCode("CN001");
}
if (plan.getCountryCode() == null) {
plan.setCountryCode("CN");
}
if (plan.getSalesCoordinator() == null) {
plan.setSalesCoordinator("default");
}
if (plan.getCustomerName() == null) {
plan.setCustomerName("未知客户");
}
// 设置产品相关默认值
if (plan.getBrandCode() == null) {
plan.setBrandCode("DEFAULT");
}
if (plan.getSalesModel() == null) {
plan.setSalesModel("STANDARD");
}
if (plan.getProductionBase() == null) {
plan.setProductionBase("BASE001");
}
if (plan.getOrderStage() == null) {
plan.setOrderStage("01");
}
if (plan.getOrderType() == null) {
plan.setOrderType("NORMAL");
}
if (plan.getPackingMethod() == null) {
plan.setPackingMethod("STD");
}
if (plan.getPlanSequence() == null) {
plan.setPlanSequence("1");
}
if (plan.getProductCategory() == null) {
plan.setProductCategory("CAT001");
}
if (plan.getProductSize() == null) {
plan.setProductSize("NORMAL");
}
if (plan.getLockWeek() == null) {
plan.setLockWeek("0");
}
// 设置时间相关字段的默认值
if (plan.getScheduleTime() == null) {
plan.setScheduleTime(now);
}
if (plan.getAdjustTime() == null) {
plan.setAdjustTime(now);
}
if (plan.getLastAdjustTime() == null) {
plan.setLastAdjustTime(now);
}
// 设置数量相关默认值
plan.setLastWeekQty(plan.getLastWeekQty() != null ? plan.getLastWeekQty() : 0);
plan.setCurrentWeekQty(plan.getCurrentWeekQty() != null ? plan.getCurrentWeekQty() : 0);
plan.setQtyDifference(plan.getQtyDifference() != null ? plan.getQtyDifference() : 0);
// 设置其他可选字段的默认值
if (plan.getScreenRequirement() == null) {
plan.setScreenRequirement("");
}
if (plan.getPanelManufacturer() == null) {
plan.setPanelManufacturer("");
}
if (plan.getPanelRequirement() == null) {
plan.setPanelRequirement("");
}
if (plan.getCoreRequirement() == null) {
plan.setCoreRequirement("");
}
// 设置创建信息
plan.setCreateTime(now);
plan.setCreateBy("admin");
}
return rollingPlanMapper.batchInsertRollingPlan(planList);
}
}

14
ruoyi-system/src/main/resources/mapper/gss/DhcProductInfoMapper.xml

@ -120,4 +120,18 @@ @@ -120,4 +120,18 @@
</trim>
where product_id = #{productId}
</update>
<select id="selectDhcProductInfoByCode" parameterType="String" resultMap="DhcProductInfoResult">
<include refid="selectDhcProductInfoVo"/>
where product_code = #{productCode} and del_flag = '0'
</select>
<select id="selectDhcProductInfoByCodes" resultMap="DhcProductInfoResult">
<include refid="selectDhcProductInfoVo"/>
where del_flag = '0'
and product_code in
<foreach item="productCode" collection="list" open="(" separator="," close=")">
#{productCode}
</foreach>
</select>
</mapper>

113
ruoyi-system/src/main/resources/mapper/system/RollingPlanMapper.xml

@ -141,90 +141,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -141,90 +141,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where plan_id = #{planId}
</select>
<insert id="insertRollingPlan" parameterType="RollingPlan" useGeneratedKeys="true" keyProperty="planId">
insert into rolling_plan
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="planNumber != null">plan_number,</if>
<if test="machineCode != null">machine_code,</if>
<if test="planYear != null">plan_year,</if>
<if test="versionWeek != null">version_week,</if>
<if test="productionMode != null">production_mode,</if>
<if test="status != null">status,</if>
<if test="salesAreaCode != null">sales_area_code,</if>
<if test="countryCode != null">country_code,</if>
<if test="salesCoordinator != null">sales_coordinator,</if>
<if test="customerName != null">customer_name,</if>
<if test="productionVersion != null">production_version,</if>
<if test="brandCode != null">brand_code,</if>
<if test="salesModel != null">sales_model,</if>
<if test="productionBase != null">production_base,</if>
<if test="isZeroExecution != null">is_zero_execution,</if>
<if test="scheduleTime != null">schedule_time,</if>
<if test="lastAdjustTime != null">last_adjust_time,</if>
<if test="adjustTime != null">adjust_time,</if>
<if test="lastWeekQty != null">last_week_qty,</if>
<if test="currentWeekQty != null">current_week_qty,</if>
<if test="qtyDifference != null">qty_difference,</if>
<if test="orderStage != null">order_stage,</if>
<if test="orderType != null">order_type,</if>
<if test="packingMethod != null">packing_method,</if>
<if test="planSequence != null">plan_sequence,</if>
<if test="isFirstOrder != null">is_first_order,</if>
<if test="isDirectDelivery != null">is_direct_delivery,</if>
<if test="screenRequirement != null">screen_requirement,</if>
<if test="panelManufacturer != null">panel_manufacturer,</if>
<if test="panelRequirement != null">panel_requirement,</if>
<if test="coreRequirement != null">core_requirement,</if>
<if test="productCategory != null">product_category,</if>
<if test="productSize != null">product_size,</if>
<if test="remark != null">remark,</if>
<if test="lockWeek != null">lock_week,</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="planNumber != null">#{planNumber},</if>
<if test="machineCode != null">#{machineCode},</if>
<if test="planYear != null">#{planYear},</if>
<if test="versionWeek != null">#{versionWeek},</if>
<if test="productionMode != null">#{productionMode},</if>
<if test="status != null">#{status},</if>
<if test="salesAreaCode != null">#{salesAreaCode},</if>
<if test="countryCode != null">#{countryCode},</if>
<if test="salesCoordinator != null">#{salesCoordinator},</if>
<if test="customerName != null">#{customerName},</if>
<if test="productionVersion != null">#{productionVersion},</if>
<if test="brandCode != null">#{brandCode},</if>
<if test="salesModel != null">#{salesModel},</if>
<if test="productionBase != null">#{productionBase},</if>
<if test="isZeroExecution != null">#{isZeroExecution},</if>
<if test="scheduleTime != null">#{scheduleTime},</if>
<if test="lastAdjustTime != null">#{lastAdjustTime},</if>
<if test="adjustTime != null">#{adjustTime},</if>
<if test="lastWeekQty != null">#{lastWeekQty},</if>
<if test="currentWeekQty != null">#{currentWeekQty},</if>
<if test="qtyDifference != null">#{qtyDifference},</if>
<if test="orderStage != null">#{orderStage},</if>
<if test="orderType != null">#{orderType},</if>
<if test="packingMethod != null">#{packingMethod},</if>
<if test="planSequence != null">#{planSequence},</if>
<if test="isFirstOrder != null">#{isFirstOrder},</if>
<if test="isDirectDelivery != null">#{isDirectDelivery},</if>
<if test="screenRequirement != null">#{screenRequirement},</if>
<if test="panelManufacturer != null">#{panelManufacturer},</if>
<if test="panelRequirement != null">#{panelRequirement},</if>
<if test="coreRequirement != null">#{coreRequirement},</if>
<if test="productCategory != null">#{productCategory},</if>
<if test="productSize != null">#{productSize},</if>
<if test="remark != null">#{remark},</if>
<if test="lockWeek != null">#{lockWeek},</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 id="batchInsertRollingPlan" parameterType="java.util.List">
insert into rolling_plan (
plan_number, machine_code, plan_year, version_week, production_mode,
status, sales_area_code, country_code, sales_coordinator, customer_name,
production_version, brand_code, sales_model, production_base,
is_zero_execution, schedule_time, adjust_time, last_week_qty,
current_week_qty, qty_difference, order_stage, order_type,
packing_method, plan_sequence, is_first_order, is_direct_delivery,
product_category, product_size, lock_week, audit_status,
screen_requirement, panel_manufacturer, panel_requirement, core_requirement,
create_by, create_time, remark
) values
<foreach collection="list" item="item" separator=",">
(
#{item.planNumber}, #{item.machineCode}, #{item.planYear},
#{item.versionWeek}, #{item.productionMode}, #{item.status},
#{item.salesAreaCode}, #{item.countryCode}, #{item.salesCoordinator},
#{item.customerName}, #{item.productionVersion}, #{item.brandCode},
#{item.salesModel}, #{item.productionBase}, #{item.isZeroExecution},
#{item.scheduleTime}, #{item.adjustTime}, #{item.lastWeekQty},
#{item.currentWeekQty}, #{item.qtyDifference}, #{item.orderStage},
#{item.orderType}, #{item.packingMethod}, #{item.planSequence},
#{item.isFirstOrder}, #{item.isDirectDelivery}, #{item.productCategory},
#{item.productSize}, #{item.lockWeek}, #{item.auditStatus},
#{item.screenRequirement}, #{item.panelManufacturer}, #{item.panelRequirement}, #{item.coreRequirement},
#{item.createBy}, sysdate(), #{item.remark}
)
</foreach>
</insert>
<update id="updateRollingPlan" parameterType="RollingPlan">
@ -263,7 +207,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -263,7 +207,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="coreRequirement != null">core_requirement = #{coreRequirement},</if>
<if test="productCategory != null">product_category = #{productCategory},</if>
<if test="productSize != null">product_size = #{productSize},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="lockWeek != null">lock_week = #{lockWeek},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>

Loading…
Cancel
Save