diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/gss/DhcProductInfoController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/gss/DhcProductInfoController.java index 5315f3f..3c97001 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/gss/DhcProductInfoController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/gss/DhcProductInfoController.java @@ -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)); + } + /** * 新增产品 */ diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/RollingPlanController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/RollingPlanController.java index 00366d3..69c72fb 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/RollingPlanController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/RollingPlanController.java @@ -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 planList) + { + return toAjax(rollingPlanService.batchSaveRollingPlan(planList)); + } } \ No newline at end of file diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/WeekDateDeserializer.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/WeekDateDeserializer.java new file mode 100644 index 0000000..1e25dbb --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/WeekDateDeserializer.java @@ -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 { + @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); + } + } +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/gss/mapper/DhcProductInfoMapper.java b/ruoyi-system/src/main/java/com/ruoyi/gss/mapper/DhcProductInfoMapper.java index 0826a80..cca9bb3 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/gss/mapper/DhcProductInfoMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/gss/mapper/DhcProductInfoMapper.java @@ -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 selectDhcProductInfoByCodes(List productCodes); } \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/gss/service/IDhcProductInfoService.java b/ruoyi-system/src/main/java/com/ruoyi/gss/service/IDhcProductInfoService.java index 9c5b81a..873ea08 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/gss/service/IDhcProductInfoService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/gss/service/IDhcProductInfoService.java @@ -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 selectDhcProductInfoByCodes(List productCodes); } \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/gss/service/impl/DhcProductInfoServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/gss/service/impl/DhcProductInfoServiceImpl.java index b3c2ad3..e50e24f 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/gss/service/impl/DhcProductInfoServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/gss/service/impl/DhcProductInfoServiceImpl.java @@ -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 selectDhcProductInfoByCodes(List productCodes) { + return dhcProductInfoMapper.selectDhcProductInfoByCodes(productCodes); + } } \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SalesAreaReport.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/SalesAreaReport.java index 9d24b6e..6e2e7dd 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SalesAreaReport.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/SalesAreaReport.java @@ -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 { 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方法 diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/RollingPlanMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/RollingPlanMapper.java index ccce96e..fd1b1b0 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/RollingPlanMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/RollingPlanMapper.java @@ -57,4 +57,12 @@ public interface RollingPlanMapper * @return 结果 */ public int deleteRollingPlanByPlanIds(Long[] planIds); + + /** + * 批量新增滚动计划 + * + * @param planList 滚动计划列表 + * @return 结果 + */ + public int batchInsertRollingPlan(List planList); } \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/IRollingPlanService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/IRollingPlanService.java index a84d1da..3930df5 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/IRollingPlanService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/IRollingPlanService.java @@ -73,4 +73,12 @@ public interface IRollingPlanService * @return 结果 */ public int deleteRollingPlanByPlanId(Long planId); + + /** + * 批量保存滚动计划 + * + * @param planList 滚动计划列表 + * @return 结果 + */ + public int batchSaveRollingPlan(List planList); } \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/RollingPlanServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/RollingPlanServiceImpl.java index be1280f..d89fe8a 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/RollingPlanServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/RollingPlanServiceImpl.java @@ -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 { return rollingPlanMapper.updateRollingPlan(rollingPlan); } + + @Override + public int batchSaveRollingPlan(List planList) { + if (CollectionUtils.isEmpty(planList)) { + return 0; + } + + Date now = DateUtils.getNowDate(); + String datePrefix = DateUtils.dateTimeNow("yyyyMMdd"); + + // 查询当天最大的计划编号 + RollingPlan queryPlan = new RollingPlan(); + queryPlan.setPlanNumber(datePrefix); + List 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); + } } \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/gss/DhcProductInfoMapper.xml b/ruoyi-system/src/main/resources/mapper/gss/DhcProductInfoMapper.xml index ff40082..ae9978f 100644 --- a/ruoyi-system/src/main/resources/mapper/gss/DhcProductInfoMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/gss/DhcProductInfoMapper.xml @@ -120,4 +120,18 @@ where product_id = #{productId} + + + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/system/RollingPlanMapper.xml b/ruoyi-system/src/main/resources/mapper/system/RollingPlanMapper.xml index caa2216..d1f9714 100644 --- a/ruoyi-system/src/main/resources/mapper/system/RollingPlanMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/RollingPlanMapper.xml @@ -141,90 +141,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where plan_id = #{planId} - - 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, - last_adjust_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, - screen_requirement, - panel_manufacturer, - panel_requirement, - core_requirement, - product_category, - product_size, - remark, - lock_week, - create_by, - create_time, - update_by, - update_time, - - - #{planNumber}, - #{machineCode}, - #{planYear}, - #{versionWeek}, - #{productionMode}, - #{status}, - #{salesAreaCode}, - #{countryCode}, - #{salesCoordinator}, - #{customerName}, - #{productionVersion}, - #{brandCode}, - #{salesModel}, - #{productionBase}, - #{isZeroExecution}, - #{scheduleTime}, - #{lastAdjustTime}, - #{adjustTime}, - #{lastWeekQty}, - #{currentWeekQty}, - #{qtyDifference}, - #{orderStage}, - #{orderType}, - #{packingMethod}, - #{planSequence}, - #{isFirstOrder}, - #{isDirectDelivery}, - #{screenRequirement}, - #{panelManufacturer}, - #{panelRequirement}, - #{coreRequirement}, - #{productCategory}, - #{productSize}, - #{remark}, - #{lockWeek}, - #{createBy}, - #{createTime}, - #{updateBy}, - #{updateTime}, - + + 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 + + ( + #{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} + ) + @@ -263,7 +207,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" core_requirement = #{coreRequirement}, product_category = #{productCategory}, product_size = #{productSize}, - remark = #{remark}, lock_week = #{lockWeek}, update_by = #{updateBy}, update_time = #{updateTime},