母胶计划、终胶计划
This commit is contained in:
@@ -0,0 +1,114 @@
|
||||
package org.jeecg.modules.xslmes.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.Arrays;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslFinalBatchPlan;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslFinalBatchPlanService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
@Tag(name = "终胶计划")
|
||||
@RestController
|
||||
@RequestMapping("/xslmes/mesXslFinalBatchPlan")
|
||||
public class MesXslFinalBatchPlanController
|
||||
extends JeecgController<MesXslFinalBatchPlan, IMesXslFinalBatchPlanService> {
|
||||
|
||||
@Autowired private IMesXslFinalBatchPlanService finalBatchPlanService;
|
||||
|
||||
@Operation(summary = "终胶计划-分页列表查询")
|
||||
@GetMapping("/list")
|
||||
public Result<IPage<MesXslFinalBatchPlan>> queryPageList(
|
||||
MesXslFinalBatchPlan model,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<MesXslFinalBatchPlan> queryWrapper = QueryGenerator.initQueryWrapper(model, req.getParameterMap());
|
||||
queryWrapper.orderByDesc("create_time");
|
||||
IPage<MesXslFinalBatchPlan> pageList = finalBatchPlanService.page(new Page<>(pageNo, pageSize), queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
@AutoLog(value = "终胶计划-添加")
|
||||
@Operation(summary = "终胶计划-添加")
|
||||
@RequiresPermissions("xslmes:mes_xsl_final_batch_plan:add")
|
||||
@PostMapping("/add")
|
||||
public Result<String> add(@RequestBody MesXslFinalBatchPlan model) {
|
||||
fillDerivedFields(model);
|
||||
finalBatchPlanService.save(model);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "终胶计划-编辑")
|
||||
@Operation(summary = "终胶计划-编辑")
|
||||
@RequiresPermissions("xslmes:mes_xsl_final_batch_plan:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody MesXslFinalBatchPlan model) {
|
||||
fillDerivedFields(model);
|
||||
finalBatchPlanService.updateById(model);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "终胶计划-通过id删除")
|
||||
@Operation(summary = "终胶计划-通过id删除")
|
||||
@RequiresPermissions("xslmes:mes_xsl_final_batch_plan:delete")
|
||||
@DeleteMapping("/delete")
|
||||
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
finalBatchPlanService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "终胶计划-批量删除")
|
||||
@Operation(summary = "终胶计划-批量删除")
|
||||
@RequiresPermissions("xslmes:mes_xsl_final_batch_plan:deleteBatch")
|
||||
@DeleteMapping("/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
finalBatchPlanService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
@Operation(summary = "终胶计划-通过id查询")
|
||||
@GetMapping("/queryById")
|
||||
public Result<MesXslFinalBatchPlan> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
MesXslFinalBatchPlan entity = finalBatchPlanService.getById(id);
|
||||
if (entity == null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(entity);
|
||||
}
|
||||
|
||||
@RequiresPermissions("xslmes:mes_xsl_final_batch_plan:exportXls")
|
||||
@RequestMapping("/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, MesXslFinalBatchPlan model) {
|
||||
return super.exportXls(request, model, MesXslFinalBatchPlan.class, "终胶计划");
|
||||
}
|
||||
|
||||
private void fillDerivedFields(MesXslFinalBatchPlan model) {
|
||||
BigDecimal planWeight = model.getPlanWeight();
|
||||
BigDecimal perCarWeight = model.getPerCarWeight();
|
||||
if (planWeight == null || perCarWeight == null || perCarWeight.compareTo(BigDecimal.ZERO) <= 0) {
|
||||
model.setPlannedCarCount(0);
|
||||
return;
|
||||
}
|
||||
model.setPlannedCarCount(planWeight.divide(perCarWeight, 0, RoundingMode.CEILING).intValue());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package org.jeecg.modules.xslmes.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.Arrays;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslMasterBatchPlan;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslMasterBatchPlanService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
@Tag(name = "母胶计划")
|
||||
@RestController
|
||||
@RequestMapping("/xslmes/mesXslMasterBatchPlan")
|
||||
public class MesXslMasterBatchPlanController
|
||||
extends JeecgController<MesXslMasterBatchPlan, IMesXslMasterBatchPlanService> {
|
||||
|
||||
@Autowired private IMesXslMasterBatchPlanService masterBatchPlanService;
|
||||
|
||||
@Operation(summary = "母胶计划-分页列表查询")
|
||||
@GetMapping("/list")
|
||||
public Result<IPage<MesXslMasterBatchPlan>> queryPageList(
|
||||
MesXslMasterBatchPlan model,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<MesXslMasterBatchPlan> queryWrapper = QueryGenerator.initQueryWrapper(model, req.getParameterMap());
|
||||
queryWrapper.orderByDesc("create_time");
|
||||
IPage<MesXslMasterBatchPlan> pageList = masterBatchPlanService.page(new Page<>(pageNo, pageSize), queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
@AutoLog(value = "母胶计划-添加")
|
||||
@Operation(summary = "母胶计划-添加")
|
||||
@RequiresPermissions("xslmes:mes_xsl_master_batch_plan:add")
|
||||
@PostMapping("/add")
|
||||
public Result<String> add(@RequestBody MesXslMasterBatchPlan model) {
|
||||
fillDerivedFields(model);
|
||||
masterBatchPlanService.save(model);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "母胶计划-编辑")
|
||||
@Operation(summary = "母胶计划-编辑")
|
||||
@RequiresPermissions("xslmes:mes_xsl_master_batch_plan:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody MesXslMasterBatchPlan model) {
|
||||
fillDerivedFields(model);
|
||||
masterBatchPlanService.updateById(model);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "母胶计划-通过id删除")
|
||||
@Operation(summary = "母胶计划-通过id删除")
|
||||
@RequiresPermissions("xslmes:mes_xsl_master_batch_plan:delete")
|
||||
@DeleteMapping("/delete")
|
||||
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
masterBatchPlanService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "母胶计划-批量删除")
|
||||
@Operation(summary = "母胶计划-批量删除")
|
||||
@RequiresPermissions("xslmes:mes_xsl_master_batch_plan:deleteBatch")
|
||||
@DeleteMapping("/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
masterBatchPlanService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
@Operation(summary = "母胶计划-通过id查询")
|
||||
@GetMapping("/queryById")
|
||||
public Result<MesXslMasterBatchPlan> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
MesXslMasterBatchPlan entity = masterBatchPlanService.getById(id);
|
||||
if (entity == null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(entity);
|
||||
}
|
||||
|
||||
@RequiresPermissions("xslmes:mes_xsl_master_batch_plan:exportXls")
|
||||
@RequestMapping("/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, MesXslMasterBatchPlan model) {
|
||||
return super.exportXls(request, model, MesXslMasterBatchPlan.class, "母胶计划");
|
||||
}
|
||||
|
||||
private void fillDerivedFields(MesXslMasterBatchPlan model) {
|
||||
BigDecimal planWeight = model.getPlanWeight();
|
||||
BigDecimal perCarWeight = model.getPerCarWeight();
|
||||
if (planWeight == null || perCarWeight == null || perCarWeight.compareTo(BigDecimal.ZERO) <= 0) {
|
||||
model.setPlannedCarCount(0);
|
||||
return;
|
||||
}
|
||||
model.setPlannedCarCount(planWeight.divide(perCarWeight, 0, RoundingMode.CEILING).intValue());
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslMasterBatchPlan;
|
||||
|
||||
@Tag(name = "生产订单")
|
||||
@RestController
|
||||
@@ -92,6 +93,15 @@ public class MesXslProductionOrderController
|
||||
return Result.OK(entity);
|
||||
}
|
||||
|
||||
@AutoLog(value = "生产订单-拆分生成母胶计划")
|
||||
@Operation(summary = "生产订单-拆分生成母胶计划")
|
||||
@RequiresPermissions("xslmes:mes_xsl_production_order:split")
|
||||
@PostMapping("/split")
|
||||
public Result<MesXslMasterBatchPlan> split(@RequestParam(name = "id", required = true) String id) {
|
||||
MesXslMasterBatchPlan plan = mesXslProductionOrderService.splitToMasterBatchPlan(id);
|
||||
return Result.OK("拆分成功", plan);
|
||||
}
|
||||
|
||||
@RequiresPermissions("xslmes:mes_xsl_production_order:exportXls")
|
||||
@RequestMapping("/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, MesXslProductionOrder model) {
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
package org.jeecg.modules.xslmes.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
/**
|
||||
* MES 终胶计划
|
||||
*/
|
||||
@Data
|
||||
@TableName("mes_xsl_final_batch_plan")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(description = "MES终胶计划")
|
||||
public class MesXslFinalBatchPlan implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
@Schema(description = "来源生产订单ID")
|
||||
private String sourceOrderId;
|
||||
|
||||
@Excel(name = "订单流水号", width = 20)
|
||||
private String orderSerialNo;
|
||||
|
||||
@Excel(name = "订单编号", width = 20)
|
||||
private String orderNo;
|
||||
|
||||
@Excel(name = "生产段数", width = 12)
|
||||
private Integer productionSegmentCount;
|
||||
|
||||
@Excel(name = "订单日期", width = 20, format = "yyyy-MM-dd")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private Date orderDate;
|
||||
|
||||
@Excel(name = "物料编码", width = 20)
|
||||
private String materialCode;
|
||||
|
||||
@Excel(name = "MES胶料信息", width = 20)
|
||||
private String mesMaterialName;
|
||||
|
||||
@Excel(name = "计划重量", width = 15)
|
||||
private BigDecimal planWeight;
|
||||
|
||||
@Excel(name = "每车重量", width = 15)
|
||||
private BigDecimal perCarWeight;
|
||||
|
||||
@Excel(name = "计划车数", width = 12)
|
||||
private Integer plannedCarCount;
|
||||
|
||||
@Excel(name = "已排产车数", width = 12)
|
||||
private Integer scheduledCarCount;
|
||||
|
||||
@Excel(name = "完成车数", width = 12)
|
||||
private Integer finishedCarCount;
|
||||
|
||||
@Excel(name = "状态", width = 12, replace = {"未开始_0", "进行中_1", "已完成_2"})
|
||||
private Integer status;
|
||||
|
||||
private Integer tenantId;
|
||||
private String sysOrgCode;
|
||||
private String createBy;
|
||||
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
|
||||
private String updateBy;
|
||||
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
|
||||
private Integer delFlag;
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package org.jeecg.modules.xslmes.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
/**
|
||||
* MES 母胶计划
|
||||
*/
|
||||
@Data
|
||||
@TableName("mes_xsl_master_batch_plan")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(description = "MES母胶计划")
|
||||
public class MesXslMasterBatchPlan implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
@Schema(description = "来源生产订单ID")
|
||||
private String sourceOrderId;
|
||||
|
||||
@Excel(name = "订单流水号", width = 20)
|
||||
private String orderSerialNo;
|
||||
|
||||
@Excel(name = "订单编号", width = 20)
|
||||
private String orderNo;
|
||||
|
||||
@Excel(name = "生产段数", width = 12)
|
||||
private Integer productionSegmentCount;
|
||||
|
||||
@Excel(name = "订单日期", width = 20, format = "yyyy-MM-dd")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private Date orderDate;
|
||||
|
||||
@Excel(name = "物料编号", width = 20)
|
||||
private String materialCode;
|
||||
|
||||
@Excel(name = "MES胶料名称", width = 20)
|
||||
private String mesMaterialName;
|
||||
|
||||
@Excel(name = "计划重量", width = 15)
|
||||
private BigDecimal planWeight;
|
||||
|
||||
@Excel(name = "每车重量", width = 15)
|
||||
private BigDecimal perCarWeight;
|
||||
|
||||
@Excel(name = "计划车数", width = 12)
|
||||
private Integer plannedCarCount;
|
||||
|
||||
@Excel(name = "已排产车数", width = 12)
|
||||
private Integer scheduledCarCount;
|
||||
|
||||
@Excel(name = "完成车数", width = 12)
|
||||
private Integer finishedCarCount;
|
||||
|
||||
@Excel(name = "状态", width = 12, replace = {"未开始_0", "进行中_1", "已完成_2"})
|
||||
private Integer status;
|
||||
|
||||
private Integer tenantId;
|
||||
private String sysOrgCode;
|
||||
private String createBy;
|
||||
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
|
||||
private String updateBy;
|
||||
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
|
||||
private Integer delFlag;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package org.jeecg.modules.xslmes.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslFinalBatchPlan;
|
||||
|
||||
public interface MesXslFinalBatchPlanMapper extends BaseMapper<MesXslFinalBatchPlan> {}
|
||||
@@ -0,0 +1,6 @@
|
||||
package org.jeecg.modules.xslmes.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslMasterBatchPlan;
|
||||
|
||||
public interface MesXslMasterBatchPlanMapper extends BaseMapper<MesXslMasterBatchPlan> {}
|
||||
@@ -0,0 +1,10 @@
|
||||
package org.jeecg.modules.xslmes.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslFinalBatchPlan;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslProductionOrder;
|
||||
|
||||
public interface IMesXslFinalBatchPlanService extends IService<MesXslFinalBatchPlan> {
|
||||
|
||||
MesXslFinalBatchPlan generateFromProductionOrder(MesXslProductionOrder productionOrder);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package org.jeecg.modules.xslmes.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslMasterBatchPlan;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslProductionOrder;
|
||||
|
||||
public interface IMesXslMasterBatchPlanService extends IService<MesXslMasterBatchPlan> {
|
||||
|
||||
MesXslMasterBatchPlan generateFromProductionOrder(MesXslProductionOrder productionOrder);
|
||||
}
|
||||
@@ -1,6 +1,10 @@
|
||||
package org.jeecg.modules.xslmes.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslMasterBatchPlan;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslProductionOrder;
|
||||
|
||||
public interface IMesXslProductionOrderService extends IService<MesXslProductionOrder> {}
|
||||
public interface IMesXslProductionOrderService extends IService<MesXslProductionOrder> {
|
||||
|
||||
MesXslMasterBatchPlan splitToMasterBatchPlan(String id);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
package org.jeecg.modules.xslmes.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jeecg.common.exception.JeecgBootException;
|
||||
import org.jeecg.modules.mes.material.entity.MesMaterial;
|
||||
import org.jeecg.modules.mes.material.mapper.MesMaterialMapper;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslFinalBatchPlan;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslProductionOrder;
|
||||
import org.jeecg.modules.xslmes.mapper.MesXslFinalBatchPlanMapper;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslFinalBatchPlanService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class MesXslFinalBatchPlanServiceImpl
|
||||
extends ServiceImpl<MesXslFinalBatchPlanMapper, MesXslFinalBatchPlan>
|
||||
implements IMesXslFinalBatchPlanService {
|
||||
|
||||
@Autowired private MesMaterialMapper mesMaterialMapper;
|
||||
|
||||
@Override
|
||||
public MesXslFinalBatchPlan generateFromProductionOrder(MesXslProductionOrder productionOrder) {
|
||||
if (productionOrder == null || StringUtils.isBlank(productionOrder.getId())) {
|
||||
throw new JeecgBootException("生产订单不存在,无法拆分终胶计划");
|
||||
}
|
||||
MesXslFinalBatchPlan exists =
|
||||
this.getOne(new LambdaQueryWrapper<MesXslFinalBatchPlan>().eq(MesXslFinalBatchPlan::getSourceOrderId, productionOrder.getId()));
|
||||
if (exists != null) {
|
||||
return exists;
|
||||
}
|
||||
|
||||
MesMaterial finalMaterial = resolveFinalMaterial(productionOrder.getMaterialCode());
|
||||
if (finalMaterial == null) {
|
||||
throw new JeecgBootException("未找到对应终胶物料,请确认MES物料编码");
|
||||
}
|
||||
|
||||
BigDecimal planWeight = productionOrder.getPlanQty() == null ? BigDecimal.ZERO : productionOrder.getPlanQty();
|
||||
BigDecimal perCarWeight = BigDecimal.ZERO;
|
||||
int planCarCount = calcPlanCarCount(planWeight, perCarWeight);
|
||||
|
||||
MesXslFinalBatchPlan plan = new MesXslFinalBatchPlan();
|
||||
plan.setSourceOrderId(productionOrder.getId());
|
||||
plan.setOrderSerialNo(buildOrderSerialNo(productionOrder));
|
||||
plan.setOrderNo(productionOrder.getProductionOrderNo());
|
||||
plan.setProductionSegmentCount(productionOrder.getProcessSegmentCount());
|
||||
plan.setOrderDate(productionOrder.getOrderDate());
|
||||
plan.setMaterialCode(finalMaterial.getMaterialCode());
|
||||
plan.setMesMaterialName(finalMaterial.getMaterialName());
|
||||
plan.setPlanWeight(planWeight);
|
||||
plan.setPerCarWeight(perCarWeight);
|
||||
plan.setPlannedCarCount(planCarCount);
|
||||
plan.setScheduledCarCount(0);
|
||||
plan.setFinishedCarCount(0);
|
||||
plan.setStatus(0);
|
||||
this.save(plan);
|
||||
return plan;
|
||||
}
|
||||
|
||||
private MesMaterial resolveFinalMaterial(String mesMaterialCode) {
|
||||
if (StringUtils.isBlank(mesMaterialCode)) {
|
||||
return null;
|
||||
}
|
||||
return mesMaterialMapper.selectOne(
|
||||
new LambdaQueryWrapper<MesMaterial>()
|
||||
.eq(MesMaterial::getMaterialCode, mesMaterialCode.trim())
|
||||
.last("LIMIT 1"));
|
||||
}
|
||||
|
||||
private String buildOrderSerialNo(MesXslProductionOrder productionOrder) {
|
||||
String orderNo = StringUtils.defaultIfBlank(productionOrder.getProductionOrderNo(), productionOrder.getId());
|
||||
return orderNo + "-F-" + System.currentTimeMillis();
|
||||
}
|
||||
|
||||
private int calcPlanCarCount(BigDecimal planWeight, BigDecimal perCarWeight) {
|
||||
if (planWeight == null || perCarWeight == null || perCarWeight.compareTo(BigDecimal.ZERO) <= 0) {
|
||||
return 0;
|
||||
}
|
||||
return planWeight.divide(perCarWeight, 0, RoundingMode.CEILING).intValue();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package org.jeecg.modules.xslmes.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jeecg.common.exception.JeecgBootException;
|
||||
import org.jeecg.modules.mes.material.entity.MesMaterial;
|
||||
import org.jeecg.modules.mes.material.mapper.MesMaterialMapper;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslMasterBatchPlan;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslProductionOrder;
|
||||
import org.jeecg.modules.xslmes.mapper.MesXslMasterBatchPlanMapper;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslMasterBatchPlanService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class MesXslMasterBatchPlanServiceImpl
|
||||
extends ServiceImpl<MesXslMasterBatchPlanMapper, MesXslMasterBatchPlan>
|
||||
implements IMesXslMasterBatchPlanService {
|
||||
|
||||
@Autowired private MesMaterialMapper mesMaterialMapper;
|
||||
|
||||
@Override
|
||||
public MesXslMasterBatchPlan generateFromProductionOrder(MesXslProductionOrder productionOrder) {
|
||||
if (productionOrder == null || StringUtils.isBlank(productionOrder.getId())) {
|
||||
throw new JeecgBootException("生产订单不存在,无法拆分");
|
||||
}
|
||||
MesMaterial motherMaterial = resolveMotherMaterial(productionOrder.getMaterialCode());
|
||||
if (motherMaterial == null) {
|
||||
throw new JeecgBootException("未找到对应母胶物料(优先B1,其次B2)");
|
||||
}
|
||||
|
||||
MesXslMasterBatchPlan exists =
|
||||
this.getOne(new LambdaQueryWrapper<MesXslMasterBatchPlan>().eq(MesXslMasterBatchPlan::getSourceOrderId, productionOrder.getId()));
|
||||
if (exists != null) {
|
||||
return exists;
|
||||
}
|
||||
|
||||
BigDecimal planWeight = productionOrder.getPlanQty() == null ? BigDecimal.ZERO : productionOrder.getPlanQty();
|
||||
BigDecimal perCarWeight = BigDecimal.ZERO;
|
||||
int planCarCount = calcPlanCarCount(planWeight, perCarWeight);
|
||||
|
||||
MesXslMasterBatchPlan plan = new MesXslMasterBatchPlan();
|
||||
plan.setSourceOrderId(productionOrder.getId());
|
||||
plan.setOrderSerialNo(buildOrderSerialNo(productionOrder));
|
||||
plan.setOrderNo(productionOrder.getProductionOrderNo());
|
||||
plan.setProductionSegmentCount(productionOrder.getProcessSegmentCount());
|
||||
plan.setOrderDate(productionOrder.getOrderDate());
|
||||
plan.setMaterialCode(motherMaterial.getMaterialCode());
|
||||
plan.setMesMaterialName(motherMaterial.getMaterialName());
|
||||
plan.setPlanWeight(planWeight);
|
||||
plan.setPerCarWeight(perCarWeight);
|
||||
plan.setPlannedCarCount(planCarCount);
|
||||
plan.setScheduledCarCount(0);
|
||||
plan.setFinishedCarCount(0);
|
||||
plan.setStatus(0);
|
||||
this.save(plan);
|
||||
return plan;
|
||||
}
|
||||
|
||||
private MesMaterial resolveMotherMaterial(String mesMaterialCode) {
|
||||
if (StringUtils.isBlank(mesMaterialCode)) {
|
||||
return null;
|
||||
}
|
||||
String code = mesMaterialCode.trim();
|
||||
List<String> candidates = buildMotherCandidates(code);
|
||||
for (String c : candidates) {
|
||||
MesMaterial found =
|
||||
mesMaterialMapper.selectOne(
|
||||
new LambdaQueryWrapper<MesMaterial>()
|
||||
.eq(MesMaterial::getMaterialCode, c)
|
||||
.last("LIMIT 1"));
|
||||
if (found != null) {
|
||||
return found;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<String> buildMotherCandidates(String code) {
|
||||
List<String> list = new ArrayList<>(2);
|
||||
if (code.length() > 1 && (code.startsWith("F") || code.startsWith("f"))) {
|
||||
String suffix = code.substring(1);
|
||||
list.add("B1" + suffix);
|
||||
list.add("B2" + suffix);
|
||||
} else {
|
||||
list.add("B1" + code);
|
||||
list.add("B2" + code);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private String buildOrderSerialNo(MesXslProductionOrder productionOrder) {
|
||||
String orderNo = StringUtils.defaultIfBlank(productionOrder.getProductionOrderNo(), productionOrder.getId());
|
||||
return orderNo + "-" + System.currentTimeMillis();
|
||||
}
|
||||
|
||||
private int calcPlanCarCount(BigDecimal planWeight, BigDecimal perCarWeight) {
|
||||
if (planWeight == null || perCarWeight == null || perCarWeight.compareTo(BigDecimal.ZERO) <= 0) {
|
||||
return 0;
|
||||
}
|
||||
return planWeight.divide(perCarWeight, 0, RoundingMode.CEILING).intValue();
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,45 @@
|
||||
package org.jeecg.modules.xslmes.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jeecg.common.exception.JeecgBootException;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslFinalBatchPlanService;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslMasterBatchPlan;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslProductionOrder;
|
||||
import org.jeecg.modules.xslmes.mapper.MesXslProductionOrderMapper;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslMasterBatchPlanService;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslProductionOrderService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
public class MesXslProductionOrderServiceImpl
|
||||
extends ServiceImpl<MesXslProductionOrderMapper, MesXslProductionOrder>
|
||||
implements IMesXslProductionOrderService {}
|
||||
implements IMesXslProductionOrderService {
|
||||
|
||||
@Autowired private IMesXslMasterBatchPlanService masterBatchPlanService;
|
||||
@Autowired private IMesXslFinalBatchPlanService finalBatchPlanService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public MesXslMasterBatchPlan splitToMasterBatchPlan(String id) {
|
||||
if (StringUtils.isBlank(id)) {
|
||||
throw new JeecgBootException("生产订单ID不能为空");
|
||||
}
|
||||
MesXslProductionOrder order = this.getById(id.trim());
|
||||
if (order == null) {
|
||||
throw new JeecgBootException("生产订单不存在");
|
||||
}
|
||||
if (order.getSplitStatus() != null && order.getSplitStatus() == 1) {
|
||||
throw new JeecgBootException("该生产订单已拆分,无需重复操作");
|
||||
}
|
||||
MesXslMasterBatchPlan plan = masterBatchPlanService.generateFromProductionOrder(order);
|
||||
finalBatchPlanService.generateFromProductionOrder(order);
|
||||
MesXslProductionOrder update = new MesXslProductionOrder();
|
||||
update.setId(order.getId());
|
||||
update.setSplitStatus(1);
|
||||
this.updateById(update);
|
||||
return plan;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user