From c8ca4e450a25d274b60f126cd5eeb0ea82720bb1 Mon Sep 17 00:00:00 2001 From: "JinLu.Yin" <411641505@qq.com> Date: Sat, 14 May 2022 14:32:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E8=89=BA=E6=B5=81=E7=A8=8B=E5=AF=B9?= =?UTF-8?q?=E5=BA=94=E7=9A=84=E4=BA=A7=E5=93=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ProRouteProductController.java | 134 +++++++++++ .../ktg/mes/pro/domain/ProRouteProduct.java | 221 ++++++++++++++++++ .../mes/pro/mapper/ProRouteProductMapper.java | 63 +++++ .../pro/service/IProRouteProductService.java | 68 ++++++ .../impl/ProRouteProductServiceImpl.java | 109 +++++++++ .../mapper/pro/ProRouteProcessMapper.xml | 1 + .../mapper/pro/ProRouteProductMapper.xml | 138 +++++++++++ 7 files changed, 734 insertions(+) create mode 100644 ktg-mes/src/main/java/com/ktg/mes/pro/controller/ProRouteProductController.java create mode 100644 ktg-mes/src/main/java/com/ktg/mes/pro/domain/ProRouteProduct.java create mode 100644 ktg-mes/src/main/java/com/ktg/mes/pro/mapper/ProRouteProductMapper.java create mode 100644 ktg-mes/src/main/java/com/ktg/mes/pro/service/IProRouteProductService.java create mode 100644 ktg-mes/src/main/java/com/ktg/mes/pro/service/impl/ProRouteProductServiceImpl.java create mode 100644 ktg-mes/src/main/resources/mapper/pro/ProRouteProductMapper.xml diff --git a/ktg-mes/src/main/java/com/ktg/mes/pro/controller/ProRouteProductController.java b/ktg-mes/src/main/java/com/ktg/mes/pro/controller/ProRouteProductController.java new file mode 100644 index 0000000..1896953 --- /dev/null +++ b/ktg-mes/src/main/java/com/ktg/mes/pro/controller/ProRouteProductController.java @@ -0,0 +1,134 @@ +package com.ktg.mes.pro.controller; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; + +import cn.hutool.core.collection.CollUtil; +import com.ktg.common.constant.UserConstants; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ktg.common.annotation.Log; +import com.ktg.common.core.controller.BaseController; +import com.ktg.common.core.domain.AjaxResult; +import com.ktg.common.enums.BusinessType; +import com.ktg.mes.pro.domain.ProRouteProduct; +import com.ktg.mes.pro.service.IProRouteProductService; +import com.ktg.common.utils.poi.ExcelUtil; +import com.ktg.common.core.page.TableDataInfo; + +/** + * 产品制程Controller + * + * @author yinjinlu + * @date 2022-05-14 + */ +@RestController +@RequestMapping("/mes/pro/routeproduct") +public class ProRouteProductController extends BaseController +{ + @Autowired + private IProRouteProductService proRouteProductService; + + /** + * 查询产品制程列表 + */ + @PreAuthorize("@ss.hasPermi('mes:pro:routeproduct:list')") + @GetMapping("/list") + public TableDataInfo list(ProRouteProduct proRouteProduct) + { + startPage(); + List list = proRouteProductService.selectProRouteProductList(proRouteProduct); + return getDataTable(list); + } + + /** + * 导出产品制程列表 + */ + @PreAuthorize("@ss.hasPermi('mes:pro:routeproduct:export')") + @Log(title = "产品制程", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, ProRouteProduct proRouteProduct) + { + List list = proRouteProductService.selectProRouteProductList(proRouteProduct); + ExcelUtil util = new ExcelUtil(ProRouteProduct.class); + util.exportExcel(response, list, "产品制程数据"); + } + + /** + * 获取产品制程详细信息 + */ + @PreAuthorize("@ss.hasPermi('mes:pro:routeproduct:query')") + @GetMapping(value = "/{recordId}") + public AjaxResult getInfo(@PathVariable("recordId") Long recordId) + { + return AjaxResult.success(proRouteProductService.selectProRouteProductByRecordId(recordId)); + } + + /** + * 新增产品制程 + */ + @PreAuthorize("@ss.hasPermi('mes:pro:routeproduct:add')") + @Log(title = "产品制程", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody ProRouteProduct proRouteProduct) + { + if(UserConstants.NOT_UNIQUE.equals(proRouteProductService.checkItemUnique(proRouteProduct))){ + return AjaxResult.error("此产品已配置了工艺路线!"); + } + return toAjax(proRouteProductService.insertProRouteProduct(proRouteProduct)); + } + + /** + * 修改产品制程 + */ + @PreAuthorize("@ss.hasPermi('mes:pro:routeproduct:edit')") + @Log(title = "产品制程", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody ProRouteProduct proRouteProduct) + { + if(UserConstants.NOT_UNIQUE.equals(proRouteProductService.checkItemUnique(proRouteProduct))){ + return AjaxResult.error("此产品已配置了工艺路线!"); + } + return toAjax(proRouteProductService.updateProRouteProduct(proRouteProduct)); + } + + /** + * 更改产品的生产路线 + */ + @PreAuthorize("@ss.hasPermi('mes:pro:routeproduct:edit')") + @Log(title = "产品制程", businessType = BusinessType.UPDATE) + @PutMapping("/move") + public AjaxResult move(@RequestBody ProRouteProduct proRouteProduct){ + ProRouteProduct param = new ProRouteProduct(); + param.setItemId(proRouteProduct.getItemId()); + param.setRouteId(proRouteProduct.getRouteId()); + List products = proRouteProductService.selectProRouteProductList(param); + int ret =1; + if(CollUtil.isNotEmpty(products)){ + ProRouteProduct product = products.get(0); + product.setRouteId(proRouteProduct.getRouteId()); + ret =proRouteProductService.updateProRouteProduct(product); + } + return toAjax(ret); + } + + + /** + * 删除产品制程 + */ + @PreAuthorize("@ss.hasPermi('mes:pro:routeproduct:remove')") + @Log(title = "产品制程", businessType = BusinessType.DELETE) + @DeleteMapping("/{recordIds}") + public AjaxResult remove(@PathVariable Long[] recordIds) + { + return toAjax(proRouteProductService.deleteProRouteProductByRecordIds(recordIds)); + } +} diff --git a/ktg-mes/src/main/java/com/ktg/mes/pro/domain/ProRouteProduct.java b/ktg-mes/src/main/java/com/ktg/mes/pro/domain/ProRouteProduct.java new file mode 100644 index 0000000..b7a0b44 --- /dev/null +++ b/ktg-mes/src/main/java/com/ktg/mes/pro/domain/ProRouteProduct.java @@ -0,0 +1,221 @@ +package com.ktg.mes.pro.domain; + +import java.math.BigDecimal; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ktg.common.annotation.Excel; +import com.ktg.common.core.domain.BaseEntity; + +/** + * 产品制程对象 pro_route_product + * + * @author yinjinlu + * @date 2022-05-14 + */ +public class ProRouteProduct extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 记录ID */ + private Long recordId; + + /** 工艺路线ID */ + @Excel(name = "工艺路线ID") + private Long routeId; + + /** 产品物料ID */ + @Excel(name = "产品物料ID") + private Long itemId; + + /** 产品物料编码 */ + @Excel(name = "产品物料编码") + private String itemCode; + + /** 产品物料名称 */ + @Excel(name = "产品物料名称") + private String itemName; + + /** 规格型号 */ + @Excel(name = "规格型号") + private String specification; + + /** 单位 */ + @Excel(name = "单位") + private String unitOfMeasure; + + /** 生产数量 */ + @Excel(name = "生产数量") + private Long quantity; + + /** 生产用时 */ + @Excel(name = "生产用时") + private BigDecimal productionTime; + + /** 时间单位 */ + @Excel(name = "时间单位") + private String timeUnitType; + + /** 预留字段1 */ + private String attr1; + + /** 预留字段2 */ + private String attr2; + + /** 预留字段3 */ + private Long attr3; + + /** 预留字段4 */ + private Long attr4; + + public void setRecordId(Long recordId) + { + this.recordId = recordId; + } + + public Long getRecordId() + { + return recordId; + } + public void setRouteId(Long routeId) + { + this.routeId = routeId; + } + + public Long getRouteId() + { + return routeId; + } + public void setItemId(Long itemId) + { + this.itemId = itemId; + } + + public Long getItemId() + { + return itemId; + } + public void setItemCode(String itemCode) + { + this.itemCode = itemCode; + } + + public String getItemCode() + { + return itemCode; + } + public void setItemName(String itemName) + { + this.itemName = itemName; + } + + public String getItemName() + { + return itemName; + } + public void setSpecification(String specification) + { + this.specification = specification; + } + + public String getSpecification() + { + return specification; + } + public void setUnitOfMeasure(String unitOfMeasure) + { + this.unitOfMeasure = unitOfMeasure; + } + + public String getUnitOfMeasure() + { + return unitOfMeasure; + } + public void setQuantity(Long quantity) + { + this.quantity = quantity; + } + + public Long getQuantity() + { + return quantity; + } + public void setProductionTime(BigDecimal productionTime) + { + this.productionTime = productionTime; + } + + public BigDecimal getProductionTime() + { + return productionTime; + } + public void setTimeUnitType(String timeUnitType) + { + this.timeUnitType = timeUnitType; + } + + public String getTimeUnitType() + { + return timeUnitType; + } + public void setAttr1(String attr1) + { + this.attr1 = attr1; + } + + public String getAttr1() + { + return attr1; + } + public void setAttr2(String attr2) + { + this.attr2 = attr2; + } + + public String getAttr2() + { + return attr2; + } + public void setAttr3(Long attr3) + { + this.attr3 = attr3; + } + + public Long getAttr3() + { + return attr3; + } + public void setAttr4(Long attr4) + { + this.attr4 = attr4; + } + + public Long getAttr4() + { + return attr4; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("recordId", getRecordId()) + .append("routeId", getRouteId()) + .append("itemId", getItemId()) + .append("itemCode", getItemCode()) + .append("itemName", getItemName()) + .append("specification", getSpecification()) + .append("unitOfMeasure", getUnitOfMeasure()) + .append("quantity", getQuantity()) + .append("productionTime", getProductionTime()) + .append("timeUnitType", getTimeUnitType()) + .append("remark", getRemark()) + .append("attr1", getAttr1()) + .append("attr2", getAttr2()) + .append("attr3", getAttr3()) + .append("attr4", getAttr4()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .toString(); + } +} diff --git a/ktg-mes/src/main/java/com/ktg/mes/pro/mapper/ProRouteProductMapper.java b/ktg-mes/src/main/java/com/ktg/mes/pro/mapper/ProRouteProductMapper.java new file mode 100644 index 0000000..818a858 --- /dev/null +++ b/ktg-mes/src/main/java/com/ktg/mes/pro/mapper/ProRouteProductMapper.java @@ -0,0 +1,63 @@ +package com.ktg.mes.pro.mapper; + +import java.util.List; +import com.ktg.mes.pro.domain.ProRouteProduct; + +/** + * 产品制程Mapper接口 + * + * @author yinjinlu + * @date 2022-05-14 + */ +public interface ProRouteProductMapper +{ + /** + * 查询产品制程 + * + * @param recordId 产品制程主键 + * @return 产品制程 + */ + public ProRouteProduct selectProRouteProductByRecordId(Long recordId); + + /** + * 查询产品制程列表 + * + * @param proRouteProduct 产品制程 + * @return 产品制程集合 + */ + public List selectProRouteProductList(ProRouteProduct proRouteProduct); + + public ProRouteProduct checkItemUnique(ProRouteProduct proRouteProduct); + + /** + * 新增产品制程 + * + * @param proRouteProduct 产品制程 + * @return 结果 + */ + public int insertProRouteProduct(ProRouteProduct proRouteProduct); + + /** + * 修改产品制程 + * + * @param proRouteProduct 产品制程 + * @return 结果 + */ + public int updateProRouteProduct(ProRouteProduct proRouteProduct); + + /** + * 删除产品制程 + * + * @param recordId 产品制程主键 + * @return 结果 + */ + public int deleteProRouteProductByRecordId(Long recordId); + + /** + * 批量删除产品制程 + * + * @param recordIds 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteProRouteProductByRecordIds(Long[] recordIds); +} diff --git a/ktg-mes/src/main/java/com/ktg/mes/pro/service/IProRouteProductService.java b/ktg-mes/src/main/java/com/ktg/mes/pro/service/IProRouteProductService.java new file mode 100644 index 0000000..05d4657 --- /dev/null +++ b/ktg-mes/src/main/java/com/ktg/mes/pro/service/IProRouteProductService.java @@ -0,0 +1,68 @@ +package com.ktg.mes.pro.service; + +import java.util.List; +import com.ktg.mes.pro.domain.ProRouteProduct; + +/** + * 产品制程Service接口 + * + * @author yinjinlu + * @date 2022-05-14 + */ +public interface IProRouteProductService +{ + /** + * 查询产品制程 + * + * @param recordId 产品制程主键 + * @return 产品制程 + */ + public ProRouteProduct selectProRouteProductByRecordId(Long recordId); + + /** + * 查询产品制程列表 + * + * @param proRouteProduct 产品制程 + * @return 产品制程集合 + */ + public List selectProRouteProductList(ProRouteProduct proRouteProduct); + + /** + * 检查物料是否已经存在 + * @param proRouteProduct + * @return + */ + public String checkItemUnique(ProRouteProduct proRouteProduct); + + /** + * 新增产品制程 + * + * @param proRouteProduct 产品制程 + * @return 结果 + */ + public int insertProRouteProduct(ProRouteProduct proRouteProduct); + + /** + * 修改产品制程 + * + * @param proRouteProduct 产品制程 + * @return 结果 + */ + public int updateProRouteProduct(ProRouteProduct proRouteProduct); + + /** + * 批量删除产品制程 + * + * @param recordIds 需要删除的产品制程主键集合 + * @return 结果 + */ + public int deleteProRouteProductByRecordIds(Long[] recordIds); + + /** + * 删除产品制程信息 + * + * @param recordId 产品制程主键 + * @return 结果 + */ + public int deleteProRouteProductByRecordId(Long recordId); +} diff --git a/ktg-mes/src/main/java/com/ktg/mes/pro/service/impl/ProRouteProductServiceImpl.java b/ktg-mes/src/main/java/com/ktg/mes/pro/service/impl/ProRouteProductServiceImpl.java new file mode 100644 index 0000000..9f43fdb --- /dev/null +++ b/ktg-mes/src/main/java/com/ktg/mes/pro/service/impl/ProRouteProductServiceImpl.java @@ -0,0 +1,109 @@ +package com.ktg.mes.pro.service.impl; + +import java.util.List; + +import com.ktg.common.constant.UserConstants; +import com.ktg.common.utils.DateUtils; +import com.ktg.common.utils.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ktg.mes.pro.mapper.ProRouteProductMapper; +import com.ktg.mes.pro.domain.ProRouteProduct; +import com.ktg.mes.pro.service.IProRouteProductService; + +/** + * 产品制程Service业务层处理 + * + * @author yinjinlu + * @date 2022-05-14 + */ +@Service +public class ProRouteProductServiceImpl implements IProRouteProductService +{ + @Autowired + private ProRouteProductMapper proRouteProductMapper; + + /** + * 查询产品制程 + * + * @param recordId 产品制程主键 + * @return 产品制程 + */ + @Override + public ProRouteProduct selectProRouteProductByRecordId(Long recordId) + { + return proRouteProductMapper.selectProRouteProductByRecordId(recordId); + } + + /** + * 查询产品制程列表 + * + * @param proRouteProduct 产品制程 + * @return 产品制程 + */ + @Override + public List selectProRouteProductList(ProRouteProduct proRouteProduct) + { + return proRouteProductMapper.selectProRouteProductList(proRouteProduct); + } + + @Override + public String checkItemUnique(ProRouteProduct proRouteProduct) { + ProRouteProduct product = proRouteProductMapper.checkItemUnique(proRouteProduct); + Long productId = proRouteProduct.getRecordId()==null?-1L:proRouteProduct.getRecordId(); + if(StringUtils.isNotNull(product) && product.getRecordId().longValue() != productId.longValue()){ + return UserConstants.NOT_UNIQUE; + } + return UserConstants.UNIQUE; + } + + /** + * 新增产品制程 + * + * @param proRouteProduct 产品制程 + * @return 结果 + */ + @Override + public int insertProRouteProduct(ProRouteProduct proRouteProduct) + { + proRouteProduct.setCreateTime(DateUtils.getNowDate()); + return proRouteProductMapper.insertProRouteProduct(proRouteProduct); + } + + /** + * 修改产品制程 + * + * @param proRouteProduct 产品制程 + * @return 结果 + */ + @Override + public int updateProRouteProduct(ProRouteProduct proRouteProduct) + { + proRouteProduct.setUpdateTime(DateUtils.getNowDate()); + return proRouteProductMapper.updateProRouteProduct(proRouteProduct); + } + + /** + * 批量删除产品制程 + * + * @param recordIds 需要删除的产品制程主键 + * @return 结果 + */ + @Override + public int deleteProRouteProductByRecordIds(Long[] recordIds) + { + return proRouteProductMapper.deleteProRouteProductByRecordIds(recordIds); + } + + /** + * 删除产品制程信息 + * + * @param recordId 产品制程主键 + * @return 结果 + */ + @Override + public int deleteProRouteProductByRecordId(Long recordId) + { + return proRouteProductMapper.deleteProRouteProductByRecordId(recordId); + } +} diff --git a/ktg-mes/src/main/resources/mapper/pro/ProRouteProcessMapper.xml b/ktg-mes/src/main/resources/mapper/pro/ProRouteProcessMapper.xml index 597af31..343f12c 100644 --- a/ktg-mes/src/main/resources/mapper/pro/ProRouteProcessMapper.xml +++ b/ktg-mes/src/main/resources/mapper/pro/ProRouteProcessMapper.xml @@ -50,6 +50,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and default_suf_time = #{defaultSufTime} and color_code = #{colorCode} + order by order_num asc + + + and route_id = #{routeId} + and item_id = #{itemId} + and item_code = #{itemCode} + and item_name like concat('%', #{itemName}, '%') + and specification = #{specification} + and unit_of_measure = #{unitOfMeasure} + and quantity = #{quantity} + and production_time = #{productionTime} + and time_unit_type = #{timeUnitType} + + + + + + + + + insert into pro_route_product + + route_id, + item_id, + item_code, + item_name, + specification, + unit_of_measure, + quantity, + production_time, + time_unit_type, + remark, + attr1, + attr2, + attr3, + attr4, + create_by, + create_time, + update_by, + update_time, + + + #{routeId}, + #{itemId}, + #{itemCode}, + #{itemName}, + #{specification}, + #{unitOfMeasure}, + #{quantity}, + #{productionTime}, + #{timeUnitType}, + #{remark}, + #{attr1}, + #{attr2}, + #{attr3}, + #{attr4}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + + + + + update pro_route_product + + route_id = #{routeId}, + item_id = #{itemId}, + item_code = #{itemCode}, + item_name = #{itemName}, + specification = #{specification}, + unit_of_measure = #{unitOfMeasure}, + quantity = #{quantity}, + production_time = #{productionTime}, + time_unit_type = #{timeUnitType}, + remark = #{remark}, + attr1 = #{attr1}, + attr2 = #{attr2}, + attr3 = #{attr3}, + attr4 = #{attr4}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + + where record_id = #{recordId} + + + + delete from pro_route_product where record_id = #{recordId} + + + + delete from pro_route_product where record_id in + + #{recordId} + + + \ No newline at end of file