From 437f12e06f150ca7ca88482f4d65ad6f579bf28b Mon Sep 17 00:00:00 2001 From: zhangsiqi <2825463979@qq.com> Date: Sat, 15 Jun 2024 18:25:05 +0800 Subject: [PATCH] =?UTF-8?q?[feat]=E9=87=87=E8=B4=AD=E7=AE=A1=E7=90=86?= =?UTF-8?q?=EF=BC=9A=E4=BF=AE=E6=94=B9=E6=B7=BB=E5=8A=A0=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E9=87=87=E8=B4=AD=E6=8A=A5=E4=BB=B7=E5=AD=90=E8=A1=A8=E6=96=B9?= =?UTF-8?q?=E6=B3=95=EF=BC=8C=E4=BF=AE=E6=94=B9=E9=87=87=E8=B4=AD=E6=8A=A5?= =?UTF-8?q?=E4=BB=B7=E5=AD=90=E8=A1=A8=E5=AD=90=E8=A1=A8=E4=BE=9B=E5=BA=94?= =?UTF-8?q?=E5=95=86=E4=B8=8B=E6=8B=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/PurchaseQuoteController.java | 10 +- .../mapper/PurchaseQuoteChildMapper.java | 4 + .../impl/PurchaseQuoteChildServiceImpl.java | 5 + .../impl/PurchaseQuoteServiceImpl.java | 22 +- .../purchase/PurchaseQuoteChildMapper.xml | 27 +- .../mapper/purchase/PurchaseQuoteMapper.xml | 103 +++---- .../templates/purchase/purchaseQuote/add.html | 270 +++++++++--------- .../purchase/purchaseQuote/edit.html | 94 +----- 8 files changed, 235 insertions(+), 300 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseQuoteController.java b/ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseQuoteController.java index d4cd9cc7..0accde92 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseQuoteController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseQuoteController.java @@ -1,6 +1,8 @@ package com.ruoyi.purchase.controller; import java.util.List; + +import com.ruoyi.ck.utils.Result; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -80,7 +82,7 @@ public class PurchaseQuoteController extends BaseController @Log(title = "采购报价单", businessType = BusinessType.INSERT) @PostMapping("/add") @ResponseBody - public AjaxResult addSave(@RequestBody PurchaseQuote purchaseQuote) + public AjaxResult addSave(@RequestBody PurchaseQuote purchaseQuote) { purchaseQuoteService.insertPurchaseQuote(purchaseQuote); return AjaxResult.success(); @@ -145,5 +147,9 @@ public class PurchaseQuoteController extends BaseController return toAjax(purchaseQuoteService.restorePurchaseQuoteById(id)); } - + @PostMapping( "/getId") + @ResponseBody + public Result getPurchaseQuoteById() throws Exception { + return Result.getSuccessResult(purchaseQuoteService.getId()); + } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/purchase/mapper/PurchaseQuoteChildMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/purchase/mapper/PurchaseQuoteChildMapper.java index d4223db0..bff8eb7d 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/purchase/mapper/PurchaseQuoteChildMapper.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/purchase/mapper/PurchaseQuoteChildMapper.java @@ -51,6 +51,10 @@ public interface PurchaseQuoteChildMapper */ public int deletePurchaseQuoteChildById(Long purchaseQuoteChildId); + /** + * 根据报价单号逻辑删除采购报价单物料信息 + */ + public int deletePurchaseQuoteChildByQuoteCode(String purchaseQuoteCode); /** * 批量删除采购报价单物料信息 * diff --git a/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseQuoteChildServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseQuoteChildServiceImpl.java index 1a944771..a51b0486 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseQuoteChildServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseQuoteChildServiceImpl.java @@ -100,6 +100,11 @@ public class PurchaseQuoteChildServiceImpl implements IPurchaseQuoteChildService return purchaseQuoteChildMapper.deletePurchaseQuoteChildById(purchaseQuoteChildId); } + @Override + public int deletePurchaseQuoteChildByQuoteCode(String purchaseQuoteCode) { + return purchaseQuoteChildMapper.deletePurchaseQuoteChildByQuoteCode(purchaseQuoteCode); + } + /** * 作废采购报价单物料信息 * diff --git a/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseQuoteServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseQuoteServiceImpl.java index 8fddb547..b874b68a 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseQuoteServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseQuoteServiceImpl.java @@ -3,6 +3,7 @@ package com.ruoyi.purchase.service.impl; import java.util.Arrays; import java.util.List; +import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.service.ICommonService; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.ShiroUtils; @@ -46,6 +47,8 @@ public class PurchaseQuoteServiceImpl implements IPurchaseQuoteService @Autowired private ICommonService commonService; + @Autowired + private RedisCache redisCache; @Autowired private SysUserMapper userMapper; @@ -94,7 +97,6 @@ public class PurchaseQuoteServiceImpl implements IPurchaseQuoteService * @return 结果 */ @Override - @Transactional(rollbackFor = Exception.class) public int insertPurchaseQuote(PurchaseQuote purchaseQuote) { String loginName = ShiroUtils.getLoginName(); @@ -119,7 +121,7 @@ public class PurchaseQuoteServiceImpl implements IPurchaseQuoteService } List childList = purchaseQuote.getPurchaseQuoteChildList(); int childResult = childList.size(); - if(childResult >= 1){ + if(childResult > 0){ for(PurchaseQuoteChild child : purchaseQuote.getPurchaseQuoteChildList()){ child.setPurchaseQuoteCode(purchaseQuote.getPurchaseQuoteCode()); child.setCreateBy(loginName); @@ -138,7 +140,6 @@ public class PurchaseQuoteServiceImpl implements IPurchaseQuoteService * @return 结果 */ @Override - @Transactional(rollbackFor = Exception.class) public int updatePurchaseQuote(PurchaseQuote purchaseQuote) { String loginName = ShiroUtils.getLoginName(); @@ -148,8 +149,6 @@ public class PurchaseQuoteServiceImpl implements IPurchaseQuoteService String fileIdStr = purchaseQuote.getFileIdStr(); Long photoAttachId = purchaseQuote.getPhotoAttachId(); String removeFileIdStr = purchaseQuote.getRemoveFileIdStr(); - - if(StringUtils.isNotBlank(removeFileIdStr)){ List removeFileIdList = Arrays.asList(removeFileIdStr.split(";")); commonService.deleteByIds(removeFileIdList); @@ -169,18 +168,20 @@ public class PurchaseQuoteServiceImpl implements IPurchaseQuoteService attachFileService.updateAttachIdByIdList(photoAttachId, fileIdList); } List childList = purchaseQuote.getPurchaseQuoteChildList(); + //逻辑删除采购报价单子表 + purchaseQuoteChildService.deletePurchaseQuoteChildByQuoteCode(purchaseQuote.getPurchaseQuoteCode()); + //重新录入子表 int childResult = childList.size(); - if(childResult >= 1){ + if(childResult > 0){ for(PurchaseQuoteChild child : purchaseQuote.getPurchaseQuoteChildList()){ child.setPurchaseQuoteCode(purchaseQuote.getPurchaseQuoteCode()); child.setCreateBy(loginName); child.setCreateTime(DateUtils.getNowDate()); child.setTaxRate(purchaseQuote.getTaxRate()); - purchaseQuoteChildService.updatePurchaseQuoteChild(child); + purchaseQuoteChildService.insertPurchaseQuoteChild(child); } } return purchaseQuoteMapper.updatePurchaseQuote(purchaseQuote); - } /** @@ -231,4 +232,9 @@ public class PurchaseQuoteServiceImpl implements IPurchaseQuoteService { return purchaseQuoteMapper.restorePurchaseQuoteById(purchaseQuoteId); } + + @Override + public Object getId(){ + return redisCache.generateBillNo("CGBJ"); + } } diff --git a/ruoyi-admin/src/main/resources/mapper/purchase/PurchaseQuoteChildMapper.xml b/ruoyi-admin/src/main/resources/mapper/purchase/PurchaseQuoteChildMapper.xml index 41a8eb3a..81a53207 100644 --- a/ruoyi-admin/src/main/resources/mapper/purchase/PurchaseQuoteChildMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/purchase/PurchaseQuoteChildMapper.xml @@ -39,7 +39,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select purchase.purchase_quote_id, purchase.purchase_quote_code, purchase.purchaseBuyer, - purchase.supplier_quote_code, purchase.supplier_name, purchase.tax_rate, purchase.material_amount, - purchase.pricingDate, purchase.material_no, purchase.first_add_time, purchase.update_info_time, - purchase.material_name, purchase.create_by, purchase.create_time, purchase.update_by, purchase.update_time, - purchase.audit_status, purchase.use_status, purchase.remark,file.url as photo_url from purchase_quote as purchase + select p.purchase_quote_id, p.purchase_quote_code, p.purchaseBuyer, + p.supplier_quote_code, p.supplier_name, p.tax_rate, p.material_amount, + p.pricingDate, p.material_no,p.material_name, p.create_by, p.create_time, p.update_by, + p.update_time,p.audit_status, p.use_status, + p.remark,file.url as photo_url from purchase_quote as p left join ( select att.rel_id @@ -53,31 +49,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where att.source_type = 'purchaseQuote' and att.source_sub_type = 'photo' group by att.rel_id )file - on purchase.purchase_quote_id = file.rel_id - - and purchase.purchase_quote_code = #{purchaseQuoteCode} - and purchase.purchaseBuyer = #{purchaseBuyer} - and purchase.supplier_quote_code = #{supplierQuoteCode} - and purchase.supplier_name like concat('%', #{supplierName}, '%') - and purchase.material_amount = #{materialAmount} - and purchase.pricingDate between #{params.beginPricingDate} and #{params.endPricingDate} - and purchase.material_no = #{materialNo} - and purchase.first_add_time between #{params.beginFirstAddTime} and #{params.endFirstAddTime} - and purchase.update_info_time = #{updateInfoTime} - and purchase.material_name like concat('%', #{materialName}, '%') - and purchase.create_time between #{params.beginCreateTime} and #{params.endCreateTime} - and purchase.audit_status = #{auditStatus} - and purchase.use_status = #{useStatus} + on p.purchase_quote_id = file.rel_id + + and p.purchase_quote_code = #{purchaseQuoteCode} + and p.purchaseBuyer = #{purchaseBuyer} + and p.supplier_quote_code = #{supplierQuoteCode} + and p.supplier_name like concat('%', #{supplierName}, '%') + and p.material_amount = #{materialAmount} + and p.pricingDate between #{params.beginPricingDate} and #{params.endPricingDate} + and p.material_no = #{materialNo} + and p.material_name like concat('%', #{materialName}, '%') + and p.create_time between #{params.beginCreateTime} and #{params.endCreateTime} + and p.audit_status = #{auditStatus} + and p.use_status = #{useStatus} + order by p.create_time desc @@ -101,8 +94,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" material_amount, pricingDate, material_no, - first_add_time, - update_info_time, material_name, create_by, create_time, @@ -121,8 +112,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{materialAmount}, #{pricingDate}, #{materialNo}, - #{firstAddTime}, - #{updateInfoTime}, #{materialName}, #{createBy}, #{createTime}, @@ -145,8 +134,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" material_amount = #{materialAmount}, pricingDate = #{pricingDate}, material_no = #{materialNo}, - first_add_time = #{firstAddTime}, - update_info_time = #{updateInfoTime}, material_name = #{materialName}, create_by = #{createBy}, create_time = #{createTime}, diff --git a/ruoyi-admin/src/main/resources/templates/purchase/purchaseQuote/add.html b/ruoyi-admin/src/main/resources/templates/purchase/purchaseQuote/add.html index af93512f..7e5ead72 100644 --- a/ruoyi-admin/src/main/resources/templates/purchase/purchaseQuote/add.html +++ b/ruoyi-admin/src/main/resources/templates/purchase/purchaseQuote/add.html @@ -13,13 +13,13 @@
- +
-
@@ -27,15 +27,13 @@
- +
- +
@@ -73,7 +71,7 @@
- + %
@@ -102,73 +100,29 @@ \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/purchase/purchaseQuote/edit.html b/ruoyi-admin/src/main/resources/templates/purchase/purchaseQuote/edit.html index feb1d514..713ab9df 100644 --- a/ruoyi-admin/src/main/resources/templates/purchase/purchaseQuote/edit.html +++ b/ruoyi-admin/src/main/resources/templates/purchase/purchaseQuote/edit.html @@ -20,13 +20,13 @@
- +
- +
@@ -175,7 +175,7 @@ pageNum: params.offset / params.limit + 1, sortName: params.sort, sortOrder: params.order, - purchaseQuoteCode: $("#purchaseQuoteCode_edit").val(), + purchaseQuoteCode: purchaseQuote.purchaseQuoteCode, } return temp; }, @@ -183,12 +183,6 @@ model: "物料报价信息", columns: [ {checkbox: true}, - {field: 'index',align: 'center', title: "序号", - formatter: function (value, row, index) { - var columnIndex = $.common.sprintf("", $.table.serialNumber(index)); - return columnIndex + $.table.serialNumber(index); - } - }, {title: '物料索引id',field: 'materialId',align: 'center',visible: false}, {title: '料号',field: 'materialCode',align: 'center'}, {title: '物料名称',field: 'materialName',align: 'center'}, @@ -226,16 +220,13 @@ {title: '操作', align: 'center', formatter: function (value, row, index) { var actions = []; - actions.push('删除 '); + actions.push('删除 '); return actions.join(''); } } ], }; $.table.init(options); - selectSupplier(); - $("#form-purchaseQuote-edit select[name='supplierQuoteCode']").val(purchaseQuote.supplierQuoteCode).trigger("change"); - $("#form-purchaseQuote-edit select[name='supplierName']").val(purchaseQuote.supplierName).trigger("change"); }); function doSubmit(index, layero,uniqueId){ console.log(uniqueId); @@ -275,10 +266,10 @@ $.modal.openOptions(options); } /* 删除指定表格行 */ - function removeRow(index){ - $("#bootstrap-sub-table-purchaseQuoteChild").bootstrapTable('removeByUniqueId', { - field: 'index', - values: index + function removeRow(materialCode){ + $("#bootstrap-sub-table-purchaseQuoteChild").bootstrapTable('remove', { + field: 'materialCode', + values: materialCode }) } function submitHandler() { @@ -296,75 +287,6 @@ } } } - function selectSupplier(){ - $("select[name='supplierQuoteCode']").select2({ - theme: "bootstrap", - allowClear: true, - placeholder: "请选择供应商", - ajax: { - url: ctx + "system/supplier/getSupplier", - type: "post", - dataType: "json", - delay: 250, - processResults: function (res, params) { - var resultList = res.rows; - var options = []; - for (let i in resultList) { - var option = resultList[i]; - option.id = resultList[i]["supplierCode"]; - option.text = resultList[i]["supplierCode"]; - option.title = resultList[i]["supplierName"]; - options.push(option); - } - return {results: options,} - }, - escapeMarkup: function (markup) {return markup;}, - } - }); - $("select[name='supplierName']").select2({ - theme: "bootstrap", - allowClear: true, - placeholder: "请选择供应商", - ajax: { - url: ctx + "system/supplier/getSupplier", - type: "post", - dataType: "json", - delay: 250, - processResults: function (res, params) { - var resultList = res.rows; - var options = []; - for (let i in resultList) { - var option = resultList[i]; - option.id = resultList[i]["supplierName"]; - option.text = resultList[i]["supplierName"]; - options.push(option); - } - return {results: options,} - }, - escapeMarkup: function (markup) {return markup;}, - } - }); - } - $("#form-purchaseQuote-edit select[name='supplierQuoteCode']").on("select2:select",function (e) { - var dataObj = e.params.data; - console.log("codeData",dataObj); - $("#form-purchaseQuote-edit select[name='supplierName']").val(dataObj.supplierName).trigger("change"); - }); - $("#form-purchaseQuote-edit select[name='supplierName']").on("select2:select",function (e) { - var dataObj = e.params.data; - console.log("nameData",dataObj); - $("#form-purchaseQuote-edit select[name='supplierQuoteCode']").val(dataObj.supplierCode).trigger("change"); - }); - $("#form-purchaseQuote-edit select[name='supplierQuoteCode']").on("select2:select",function (e) { - var dataObj = e.params.data; - console.log("codeData",dataObj); - $("#form-purchaseQuote-edit select[name='supplierName']").val(dataObj.supplierName).trigger("change"); - }); - $("#form-purchaseQuote-edit select[name='supplierName']").on("select2:select",function (e) { - var dataObj = e.params.data; - console.log("nameData",dataObj); - $("#form-purchaseQuote-edit select[name='supplierQuoteCode']").val(dataObj.supplierCode).trigger("change"); - }); $("input[name='pricingDate']").datetimepicker({ format: "yyyy-mm-dd", minView: "month",