From 7b817a5edf842c844b1164ec56debffffb2c5ecd Mon Sep 17 00:00:00 2001 From: hwd <582708352@qq.com> Date: Sat, 27 Sep 2025 16:57:34 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=87=BA=E5=BA=93=E7=AE=A1?= =?UTF-8?q?=E7=90=86-=E6=B7=BB=E5=8A=A0=E9=A2=86=E6=96=99=E5=8D=95?= =?UTF-8?q?=EF=BC=8C=E5=BC=B9=E7=AA=97=E9=80=89=E6=8B=A9=E9=87=87=E8=B4=AD?= =?UTF-8?q?=E7=A0=81=EF=BC=88=E4=BA=A7=E5=93=81=EF=BC=89=EF=BC=8C=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E9=95=BF=E6=8F=8F=E8=BF=B0=E3=80=81=E5=85=AC=E7=A7=B0?= =?UTF-8?q?=E7=9B=B4=E5=BE=84(L)=E3=80=81=E5=85=AC=E7=A7=B0=E7=9B=B4?= =?UTF-8?q?=E5=BE=84(S)=EF=BC=9B=E9=80=89=E4=B8=AD=E5=90=8E=E5=B8=A6?= =?UTF-8?q?=E5=9B=9E=E5=AE=8C=E6=95=B4=E9=95=BF=E6=8F=8F=E8=BF=B0=EF=BC=8C?= =?UTF-8?q?=E5=85=AC=E7=A7=B0=E7=9B=B4=E5=BE=84(L)=EF=BC=8C=E5=85=AC?= =?UTF-8?q?=E7=A7=B0=E7=9B=B4=E5=BE=84(S)=EF=BC=9B=E9=95=BF=E6=8F=8F?= =?UTF-8?q?=E8=BF=B0=E5=A4=9A=E5=8F=82=E6=95=B0=E6=90=9C=E7=B4=A2=E7=94=A8?= =?UTF-8?q?=E8=8B=B1=E6=96=87=E9=80=97=E5=8F=B7=E9=9A=94=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/admin/ProductController.java | 22 ++ src/main/java/com/vverp/dao/ProductDao.java | 30 ++ src/main/java/com/vverp/dto/ProductQuery.java | 18 - .../java/com/vverp/dto/ProductQueryDto.java | 72 ++++ .../java/com/vverp/dto/ProductSearchDto.java | 88 +++++ .../com/vverp/service/ProductService.java | 5 + .../webapp/WEB-INF/template/common/index.html | 2 +- .../product/dialog/selectSearchLddlds.html | 347 ++++++++++++++++++ .../webapp/WEB-INF/template/useOrder/add.html | 34 +- src/main/webapp/resources/js/base.js | 4 +- src/main/webapp/resources/js/complex-add.js | 8 +- src/main/webapp/resources/js/select-field.js | 13 +- 12 files changed, 614 insertions(+), 29 deletions(-) delete mode 100644 src/main/java/com/vverp/dto/ProductQuery.java create mode 100644 src/main/java/com/vverp/dto/ProductQueryDto.java create mode 100644 src/main/java/com/vverp/dto/ProductSearchDto.java create mode 100644 src/main/webapp/WEB-INF/template/product/dialog/selectSearchLddlds.html diff --git a/src/main/java/com/vverp/controller/admin/ProductController.java b/src/main/java/com/vverp/controller/admin/ProductController.java index 3eadfd7..76778ef 100644 --- a/src/main/java/com/vverp/controller/admin/ProductController.java +++ b/src/main/java/com/vverp/controller/admin/ProductController.java @@ -2,6 +2,8 @@ package com.vverp.controller.admin; import com.vverp.base.Setting; import com.vverp.dto.ProductBaseDTO; +import com.vverp.dto.ProductQueryDto; +import com.vverp.dto.ProductSearchDto; import com.vverp.entity.*; import com.vverp.enums.OrderStatus; import com.vverp.moli.util.*; @@ -272,6 +274,26 @@ public class ProductController extends BaseController { } } + // 根据长描述、公称直径(L)、公称直径(S)筛选产品 + @RequestMapping("/dialog/selectSearchLddlds") + public String selectSearchLddlds(ModelMap modelMap, String indexSn) { + modelMap.addAttribute("hasProductType", false); + modelMap.addAttribute("dialogName", "sblddldsDialog"); + modelMap.addAttribute("indexSn", indexSn); + return "/product/dialog/selectSearchLddlds"; + } + @RequestMapping("/listLddlds") + @ResponseBody + public RespData listLddlds(ProductQueryDto queryDto) { + try { + List list = productService.listAll(queryDto); + return RespData.success(list); + } catch (Exception e) { + e.printStackTrace(); + return RespData.error("获取失败"); + } + } + @RequestMapping("/selectPage") @ResponseBody public RespData selectPage(Pageable pageable) { diff --git a/src/main/java/com/vverp/dao/ProductDao.java b/src/main/java/com/vverp/dao/ProductDao.java index 367cac4..374bf07 100644 --- a/src/main/java/com/vverp/dao/ProductDao.java +++ b/src/main/java/com/vverp/dao/ProductDao.java @@ -1,6 +1,8 @@ package com.vverp.dao; import com.vverp.dto.ProductBaseDTO; +import com.vverp.dto.ProductQueryDto; +import com.vverp.dto.ProductSearchDto; import com.vverp.entity.Product; import org.apache.commons.lang.StringUtils; import org.springframework.stereotype.Repository; @@ -130,6 +132,34 @@ public class ProductDao extends BaseDao { return entityManager.createQuery(criteriaQuery).getResultList(); } + public List listAll(ProductQueryDto queryDto) { + CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); + CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(ProductSearchDto.class); + Root root = criteriaQuery.from(Product.class); + criteriaQuery.select(criteriaBuilder.construct(ProductSearchDto.class, root.get("id"), root.get("name"), root.get("code"), root.get("productType").get("id"), root.get("longDescription"), root.get("diameterL"), root.get("diameterS"))); + Predicate all = criteriaBuilder.conjunction(); + + if (queryDto.getType() != null) { + all = criteriaBuilder.and(all, criteriaBuilder.equal(root.get("type"), queryDto.getType())); + } + if (queryDto.getProductTypeId() != null) { + all = criteriaBuilder.and(all, criteriaBuilder.equal(root.get("productType").get("id"), queryDto.getProductTypeId())); + } + if (queryDto.getDiameterL() != null) { + all = criteriaBuilder.and(all, criteriaBuilder.equal(root.get("diameterL"), queryDto.getDiameterL())); + } + if (queryDto.getDiameterS() != null) { + all = criteriaBuilder.and(all, criteriaBuilder.equal(root.get("diameterS"), queryDto.getDiameterS())); + } + if (StringUtils.isNotBlank(queryDto.getLongDescription())) { + for (String s : queryDto.getLongDescription().split(",")) { + all = criteriaBuilder.and(all, criteriaBuilder.like(root.get("longDescription"), "%" + s + "%")); + } + } + criteriaQuery.where(all); + return entityManager.createQuery(criteriaQuery).getResultList(); + } + public Page selectPage(Pageable pageable) { CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(Product.class); diff --git a/src/main/java/com/vverp/dto/ProductQuery.java b/src/main/java/com/vverp/dto/ProductQuery.java deleted file mode 100644 index cdfc428..0000000 --- a/src/main/java/com/vverp/dto/ProductQuery.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.vverp.dto; - -/** - * @author - * @date 2020/11/17 上午11:20 - */ -public class ProductQuery { - - private String name; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} diff --git a/src/main/java/com/vverp/dto/ProductQueryDto.java b/src/main/java/com/vverp/dto/ProductQueryDto.java new file mode 100644 index 0000000..b67fa9b --- /dev/null +++ b/src/main/java/com/vverp/dto/ProductQueryDto.java @@ -0,0 +1,72 @@ +package com.vverp.dto; + +import com.vverp.entity.Product; + +import java.math.BigDecimal; + +public class ProductQueryDto { + + private String name; // 名称 + private String code; // 编码 + private Product.Type type; // + private Long productTypeId; // 产品类别id + private String longDescription; // 长描述 + private BigDecimal diameterL; // 公称直径(L) + private BigDecimal diameterS; // 公称直径(S) + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public Product.Type getType() { + return type; + } + + public void setType(Product.Type type) { + this.type = type; + } + + public Long getProductTypeId() { + return productTypeId; + } + + public void setProductTypeId(Long productTypeId) { + this.productTypeId = productTypeId; + } + + public String getLongDescription() { + return longDescription; + } + + public void setLongDescription(String longDescription) { + this.longDescription = longDescription; + } + + public BigDecimal getDiameterL() { + return diameterL; + } + + public void setDiameterL(BigDecimal diameterL) { + this.diameterL = diameterL; + } + + public BigDecimal getDiameterS() { + return diameterS; + } + + public void setDiameterS(BigDecimal diameterS) { + this.diameterS = diameterS; + } +} diff --git a/src/main/java/com/vverp/dto/ProductSearchDto.java b/src/main/java/com/vverp/dto/ProductSearchDto.java new file mode 100644 index 0000000..1f60b06 --- /dev/null +++ b/src/main/java/com/vverp/dto/ProductSearchDto.java @@ -0,0 +1,88 @@ +package com.vverp.dto; + +import java.math.BigDecimal; + +public class ProductSearchDto { + private Long id; + private String name; // 名称 + private String code; // 编码 + private Long productTypeId; // 产品类别id + private String productTypeName; // 产品类别 + private String longDescription; // 长描述 + private BigDecimal diameterL; // 公称直径(L) + private BigDecimal diameterS; // 公称直径(S) + + public ProductSearchDto(Long id, String name, String code, Long productTypeId, String longDescription, BigDecimal diameterL, BigDecimal diameterS) { + this.id = id; + this.name = name; + this.code = code; + this.productTypeId = productTypeId; + this.longDescription = longDescription; + this.diameterL = diameterL; + this.diameterS = diameterS; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public Long getProductTypeId() { + return productTypeId; + } + + public void setProductTypeId(Long productTypeId) { + this.productTypeId = productTypeId; + } + + public String getProductTypeName() { + return productTypeName; + } + + public void setProductTypeName(String productTypeName) { + this.productTypeName = productTypeName; + } + + public String getLongDescription() { + return longDescription; + } + + public void setLongDescription(String longDescription) { + this.longDescription = longDescription; + } + + public BigDecimal getDiameterL() { + return diameterL; + } + + public void setDiameterL(BigDecimal diameterL) { + this.diameterL = diameterL; + } + + public BigDecimal getDiameterS() { + return diameterS; + } + + public void setDiameterS(BigDecimal diameterS) { + this.diameterS = diameterS; + } +} diff --git a/src/main/java/com/vverp/service/ProductService.java b/src/main/java/com/vverp/service/ProductService.java index fa9cb55..297e89a 100644 --- a/src/main/java/com/vverp/service/ProductService.java +++ b/src/main/java/com/vverp/service/ProductService.java @@ -2,6 +2,8 @@ package com.vverp.service; import cn.afterturn.easypoi.excel.entity.ExportParams; import com.vverp.dto.ProductBaseDTO; +import com.vverp.dto.ProductQueryDto; +import com.vverp.dto.ProductSearchDto; import com.vverp.entity.Product; import com.vverp.entity.ProductType; import com.vverp.moli.util.Filter; @@ -55,6 +57,9 @@ public class ProductService extends BaseService { public List listAll(String productTypeChain, String search) { return productDao.listAll(productTypeChain, search); } + public List listAll(ProductQueryDto queryDto) { + return productDao.listAll(queryDto); + } public Page selectPage(Pageable pageable) { return productDao.selectPage(pageable); diff --git a/src/main/webapp/WEB-INF/template/common/index.html b/src/main/webapp/WEB-INF/template/common/index.html index 48f2141..3938734 100644 --- a/src/main/webapp/WEB-INF/template/common/index.html +++ b/src/main/webapp/WEB-INF/template/common/index.html @@ -255,7 +255,7 @@ - + + + + + diff --git a/src/main/webapp/WEB-INF/template/useOrder/add.html b/src/main/webapp/WEB-INF/template/useOrder/add.html index 73f01b0..f293bfb 100644 --- a/src/main/webapp/WEB-INF/template/useOrder/add.html +++ b/src/main/webapp/WEB-INF/template/useOrder/add.html @@ -36,7 +36,10 @@ href="javascript:Dialog.functionDialog(null, null, '/admin/common/selectInsideField.html?name=inside-useOrder-table');"> - 采购码 + 采购码 + 长描述 + 公称直径(L) + 公称直径(S) 数量 备注 操作 @@ -46,9 +49,14 @@ - + + + X @@ -74,8 +82,26 @@ diff --git a/src/main/webapp/resources/js/base.js b/src/main/webapp/resources/js/base.js index 94fee33..00e9b4d 100644 --- a/src/main/webapp/resources/js/base.js +++ b/src/main/webapp/resources/js/base.js @@ -1186,9 +1186,9 @@ function initSelectAction($selects) { updateExtra(that, $dot, $remove); - $dot.on('click', function () { + $dot.on('click', function (e) { if (moreFunc) { - window[moreFunc](); + window[moreFunc](e); } }); diff --git a/src/main/webapp/resources/js/complex-add.js b/src/main/webapp/resources/js/complex-add.js index ea6b22f..3b3442a 100644 --- a/src/main/webapp/resources/js/complex-add.js +++ b/src/main/webapp/resources/js/complex-add.js @@ -8,7 +8,9 @@ $table = $(table); options = optionsX; - fillProductList(); + if (!optionsX.onlyExtra) { + fillProductList(); + } initTable(); initForm(options.successMsg); initDeleteLine(); @@ -791,6 +793,10 @@ function _concatUrl(url, str) { function openProductDialog() { Dialog.functionDialog(null, null, 'product/dialog/select.html'); } +// 根据长描述、公称直径(L)、公称直径(S)筛选产品:领料出库添加 +function openProductSblddldsDialog(e) { + Dialog.functionDialog(null, null, 'product/dialog/selectSearchLddlds.html?indexSn='+$(e.target).closest('tr').index()); +} function selectProductCallback(selected) { var $table = $('.complexAddBody .tableWrap table'); diff --git a/src/main/webapp/resources/js/select-field.js b/src/main/webapp/resources/js/select-field.js index 48f5508..3a4bb8a 100644 --- a/src/main/webapp/resources/js/select-field.js +++ b/src/main/webapp/resources/js/select-field.js @@ -48,7 +48,7 @@ } if (options.multiSelect) { - initMultiSelect($table); + initMultiSelect($table, options.multiSelectSingle); } }; @@ -372,14 +372,16 @@ }; // 初始化【多选】 - var initMultiSelect = function ($table) { + var initMultiSelect = function ($table, single) { var $checkboxCol = $table.find('.checkbox-col'); $checkboxCol.each(function () { var id = $(this).find('.checkbox').attr('data-id'); if (id) { $(this).html(''); } else { - $(this).html(''); + if (!single) { + $(this).html(''); + } } }); @@ -395,6 +397,11 @@ $singleCheckbox.on('click', function () { var flag = $(this).attr('data-flag'); flag = flag === 'true' ? 'false' : 'true'; + if (flag === 'true' && single) { + $table.find("td.checkbox-col .single-checkbox[data-flag='true']").each(function () { + loadSingleCheckboxDom($(this), 'false') + }); + } loadSingleCheckboxDom($(this), flag); var tagName = $(this).parents('.checkbox-col')[0].tagName;