yuansh пре 2 дана
родитељ
комит
cecde23806

+ 10 - 8
srm-module-code/src/main/java/org/jeecg/modules/cuspCode/controller/CuspCustomerProfileController.java

@@ -101,16 +101,16 @@ public class CuspCustomerProfileController {
 	@PostMapping(value = "/add")
 	public Result<String> add(@RequestBody CuspCustomerProfilePage cuspCustomerProfilePage) {
 
-		String code = cuspCustomerProfilePage.getCode();
-		if (StringUtils.isNotBlank(code)) {
+		String name = cuspCustomerProfilePage.getName();
+		if (StringUtils.isNotBlank(name)) {
 
 			QueryWrapper<CuspCustomerProfile> queryWrapper = new QueryWrapper();
-			queryWrapper.eq("code", code);
+//			queryWrapper.eq("name", name);
 			queryWrapper.eq("del_flag", "0");
-
+			queryWrapper.eq("LOWER(name)", name.toLowerCase());
 			List<CuspCustomerProfile> list = cuspCustomerProfileService.list(queryWrapper);
 			if (list.size() != 0) {
-				return Result.error("客户档案编码重复,请修改!");
+				return Result.error("客户档案名称重复,请修改!");
 			}
 		} else {
 
@@ -146,15 +146,17 @@ public class CuspCustomerProfileController {
 			return Result.error("未找到对应数据");
 		}
 
-		String code = cuspCustomerProfile.getCode();
+		String name = cuspCustomerProfile.getName();
 		QueryWrapper<CuspCustomerProfile> queryWrapper = new QueryWrapper();
-		queryWrapper.eq("code", code);
+//		queryWrapper.eq("code", code);
+
+		queryWrapper.eq("LOWER(name)", name.toLowerCase());
 		queryWrapper.eq("del_flag", "0");
 		queryWrapper.notIn("id", cuspCustomerProfile.getId());
 
 		List<CuspCustomerProfile> list = cuspCustomerProfileService.list(queryWrapper);
 		if (list.size() != 0) {
-			return Result.error("客户档案编码重复,请修改!");
+			return Result.error("客户档案名称重复,请修改!");
 		}
 
 		cuspCustomerProfileService.updateMain(cuspCustomerProfile, cuspCustomerProfilePage.getCuspCustomerProfileManList());

+ 126 - 8
srm-module-code/src/main/java/org/jeecg/modules/cuspCode/controller/CuspSupplierProfileController.java

@@ -6,16 +6,26 @@ import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 import java.util.HashMap;
+import java.util.stream.Collectors;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import cn.hutool.core.bean.BeanUtil;
+import org.jeecg.common.api.dto.message.BusTemplateMessageDTO;
+import org.jeecg.common.api.dto.message.MessageDTO;
+import org.jeecg.common.api.dto.message.TemplateMessageDTO;
+import org.jeecg.common.constant.CommonConstant;
+import org.jeecg.common.constant.enums.MessageTypeEnum;
+import org.jeecg.common.constant.enums.SysAnnmentTypeEnum;
+import org.jeecg.common.system.api.ISysBaseAPI;
 import org.jeecg.modules.baseCode.service.ISerialPatternService;
 import org.jeecg.modules.cuspCode.vo.CuspSupplierDeadlineReminderVo;
 import org.apache.commons.lang.StringUtils;
 import org.jeecg.modules.cuspCode.entity.CuspSupplierProfile;
 import org.jeecg.modules.cuspCode.entity.CuspSupplierProfileMan;
 import org.jeecg.modules.cuspCode.entity.CuspSupplierProfileQualification;
+import org.jeecg.modules.system.service.ISysDictService;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
 import org.jeecgframework.poi.excel.def.NormalExcelConstants;
 import org.jeecgframework.poi.excel.entity.ExportParams;
@@ -66,6 +76,10 @@ public class CuspSupplierProfileController {
     private ICuspSupplierProfileQualificationService cuspSupplierProfileQualificationService;
     @Autowired
     private ISerialPatternService serialPatternService;
+    @Autowired
+    ISysBaseAPI sysBaseAPI;
+    @Autowired
+    private ISysDictService sysDictService;
 
 
     /**
@@ -158,16 +172,17 @@ public class CuspSupplierProfileController {
     public Result<String> add(@RequestBody CuspSupplierProfilePage cuspSupplierProfilePage) {
 
 
-        String code = cuspSupplierProfilePage.getCode();
-        if (StringUtils.isNotBlank(code)) {
+        String name = cuspSupplierProfilePage.getName();
+        if (StringUtils.isNotBlank(name)) {
 
             QueryWrapper<CuspSupplierProfile> queryWrapper = new QueryWrapper();
-            queryWrapper.eq("code", code);
+//            queryWrapper.eq("code", code);
+            queryWrapper.eq("LOWER(name)", name.toLowerCase());
             queryWrapper.eq("del_flag", "0");
 
             List<CuspSupplierProfile> list = cuspSupplierProfileService.list(queryWrapper);
             if (list.size() != 0) {
-                return Result.error("供应商档案编码重复,请修改!");
+                return Result.error("供应商档案名称重复,请修改!");
             }
         } else {
 
@@ -178,13 +193,84 @@ public class CuspSupplierProfileController {
             cuspSupplierProfilePage.setCode(result.getMessage());
         }
 
-
         CuspSupplierProfile cuspSupplierProfile = new CuspSupplierProfile();
         BeanUtils.copyProperties(cuspSupplierProfilePage, cuspSupplierProfile);
         cuspSupplierProfileService.saveMain(cuspSupplierProfile, cuspSupplierProfilePage.getCuspSupplierProfileManList(), cuspSupplierProfilePage.getCuspSupplierProfileQualificationList());
+
+        Map<String, Object> mapRepresentation = BeanUtil.beanToMap(cuspSupplierProfile);
+        sendTemplateAnnouncement(mapRepresentation);
         return Result.OK("添加成功!");
     }
 
+
+    //发送给审批人
+    public void sendTemplateAnnouncement(Map<String, Object> mapRepresentation) {
+
+        String checkQuota = sysDictService.queryDescriptionByKey("supplier_approval_user");
+        if(StringUtils.isBlank(checkQuota)){
+            return;
+        }
+
+        String[] userIds = checkQuota.split(",");
+
+        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        //发送人
+//        String fromUser = "admin";
+        String fromUser = sysUser.getUsername();
+        //接收人
+//        String toUser = "admin";
+        String toUser = checkQuota;
+        //标题
+        String title = "供应商审批("+mapRepresentation.get("name")+")";
+        //模版编码
+        String templateCode = "supplier_approval";
+
+        //模版参数
+//        Map templateParam = new HashMap<>();
+//        templateParam.put("realname","JEECG用户");
+
+        Map<String, String> templateParam = mapRepresentation.entrySet().stream()
+                .collect(Collectors.toMap(
+                        Map.Entry::getKey,
+                        entry -> entry.getValue() == null? "" : entry.getValue().toString() // 将对象转换为字符串
+                ));
+        templateParam.put("createBy",sysUser.getRealname());
+
+        for(String o:userIds){
+//            sysBaseAPI.sendTemplateAnnouncement(new TemplateMessageDTO(fromUser,toUser,title,templateParam,templateCode));
+            sysBaseAPI.sendTemplateAnnouncement(new TemplateMessageDTO(fromUser,o,title,templateParam,templateCode));
+        }
+    }
+
+    /**
+     * 发送系统消息
+     */
+    public void sendSysAnnouncement(String toUserId,String name,String st,String info) {
+
+//        状态(1-启用,0-停用)"
+        if(st.equals("1")){
+            st = "启用";
+        }else{
+            st = "停用";
+        }
+
+        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        //发送人
+//        String fromUser = "admin";
+        String fromUser = sysUser.getUsername();
+        //接收人
+        String toUser = toUserId;
+        //标题
+        String title = "供应商档案"+st+"通知("+name+")";
+        //内容
+        String msgContent = "您申请的供应商档案:'"+name+"'已"+st+",请知悉。";
+        if(StringUtils.isNotBlank(info)){
+            msgContent = msgContent+"停用原因:"+info;
+        }
+        //发送系统消息
+        sysBaseAPI.sendSysAnnouncement(new MessageDTO(fromUser, toUser, title, msgContent));
+    }
+
     /**
      * 编辑
      *
@@ -203,18 +289,22 @@ public class CuspSupplierProfileController {
             return Result.error("未找到对应数据");
         }
 
-        String code = cuspSupplierProfile.getCode();
+        String name = cuspSupplierProfile.getName();
         QueryWrapper<CuspSupplierProfile> queryWrapper = new QueryWrapper();
-        queryWrapper.eq("code", code);
+//        queryWrapper.eq("code", code);
+        queryWrapper.eq("LOWER(name)", name.toLowerCase());
         queryWrapper.eq("del_flag", "0");
         queryWrapper.notIn("id", cuspSupplierProfile.getId());
 
         List<CuspSupplierProfile> list = cuspSupplierProfileService.list(queryWrapper);
         if (list.size() != 0) {
-            return Result.error("供应商档案编码重复,请修改!");
+            return Result.error("供应商档案名称重复,请修改!");
         }
 
         cuspSupplierProfileService.updateMain(cuspSupplierProfile, cuspSupplierProfilePage.getCuspSupplierProfileManList(), cuspSupplierProfilePage.getCuspSupplierProfileQualificationList());
+
+        Map<String, Object> mapRepresentation = BeanUtil.beanToMap(cuspSupplierProfile);
+        sendTemplateAnnouncement(mapRepresentation);
         return Result.OK("编辑成功!");
     }
 
@@ -248,6 +338,34 @@ public class CuspSupplierProfileController {
         return Result.OK("批量删除成功!");
     }
 
+    /**
+     * 启用停用
+     *
+     * @param ids
+     * @return
+     */
+    @AutoLog(value = "供应商档案-启用停用")
+    @ApiOperation(value = "供应商档案-启用停用", notes = "供应商档案-启用停用")
+    @GetMapping(value = "/getDisable")
+    public Result<String> getDisable(@RequestParam(name = "ids", required = true) String ids, String info) {
+
+        CuspSupplierProfile ent = cuspSupplierProfileService.getById(ids);
+        String st = StringUtils.isBlank(info) ? "1" : "0";
+        if(st.equals(ent.getStatus())){
+
+            return Result.error("请勿重复操作!");
+        }
+        CuspSupplierProfile cuspSupplierProfile = new CuspSupplierProfile();
+        cuspSupplierProfile.setStatus(Integer.valueOf(st));
+        cuspSupplierProfile.setId(ids);
+        cuspSupplierProfile.setReasonFor(info);
+        cuspSupplierProfileService.updateById(cuspSupplierProfile);
+
+        sendSysAnnouncement(ent.getCreateBy(),ent.getName(),st,info);
+
+        return Result.OK("执行成功!");
+    }
+
     /**
      * 通过id查询
      *

+ 4 - 0
srm-module-code/src/main/java/org/jeecg/modules/cuspCode/entity/CuspSupplierProfile.java

@@ -49,6 +49,10 @@ public class CuspSupplierProfile implements Serializable {
     private String subordinateDepart;
 
 
+    //停用原因
+    private String reasonFor;
+
+
     /**
      * 创建时间
      */

+ 3 - 2
srm-module-code/src/main/java/org/jeecg/modules/purCode/controller/PurQuotationSelectionController.java

@@ -114,7 +114,7 @@ public class PurQuotationSelectionController {
 
     @ApiOperation(value = "供应商报价选定", notes = "供应商报价选定")
     @GetMapping(value = "/purQuotationSelectionProductAlert")
-    @PermissionData(pageComponent="purchase/selectionQuotationForm/selectionQuotationFormList")
+    @PermissionData
     public Result<IPage<PurQuotationSelectionAlert>> purQuotationSelectionProductAlert(PurQuotationSelectionAlert quotationProject,
                                                                             @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                                             @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
@@ -136,7 +136,7 @@ public class PurQuotationSelectionController {
      */
     @ApiOperation(value = "供应商报价选定更新采购订单", notes = "供应商报价选定更新采购订单")
     @GetMapping(value = "/purQuotationSelectionProductBy")
-    @PermissionData(pageComponent="purchase/selectionQuotationForm/selectionQuotationFormList")
+    @PermissionData
     public Result<PurOrderPage> purQuotationSelectionProductBy(String id, String code, String project, HttpServletRequest req) {
 
         if(StringUtils.isBlank(id)){
@@ -724,6 +724,7 @@ public class PurQuotationSelectionController {
      */
     @RequiresPermissions("purCode:pur_quotation_selection:exportXls")
     @RequestMapping(value = "/exportXls")
+    @PermissionData(pageComponent="purchase/selectionQuotationForm/selectionQuotationFormList")
     public ModelAndView exportXls(HttpServletRequest request, PurQuotationSelection purQuotationSelection) {
         // Step.1 组装查询条件查询数据
         QueryWrapper<PurQuotationSelection> queryWrapper = QueryGenerator.initQueryWrapper(purQuotationSelection, request.getParameterMap());

+ 5 - 5
srm-module-code/src/main/java/org/jeecg/modules/saleCode/controller/SaleOrderController.java

@@ -211,7 +211,7 @@ public class SaleOrderController {
      */
     @ApiOperation(value = "销售订单弹框明细-佣金付款使用", notes = "销售订单弹框明细-佣金付款使用")
     @GetMapping(value = "/selectSaleOrderDetailCommissionPay")
-    @PermissionData(pageComponent = "saleCode/salesOrder/SaleOrderFormList")
+    @PermissionData
     public Result<IPage<SaleOrder>> selectSaleOrderDetailCommissionPay(SaleOrder saleOrder,
                                                                        @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                                        @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
@@ -234,7 +234,7 @@ public class SaleOrderController {
      */
     @ApiOperation(value = "销售订单弹框明细", notes = "销售订单弹框明细")
     @GetMapping(value = "/selectSaleOrderDetailAlert")
-    @PermissionData(pageComponent = "saleCode/salesOrder/SaleOrderFormList")
+    @PermissionData
     public Result<IPage<SaleOrderAlert>> selectContractDetailAlert(SaleOrderAlert saleInquiryForm,
                                                                    @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                                    @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
@@ -258,7 +258,7 @@ public class SaleOrderController {
      */
     @ApiOperation(value = "销售订单弹框明细 处理单", notes = "销售订单弹框明细 处理单")
     @GetMapping(value = "/selectSaleOrderDetailAfter")
-    @PermissionData(pageComponent = "saleCode/salesOrder/SaleOrderFormList")
+    @PermissionData
     public Result<IPage<SaleOrderAlert>> selectSaleOrderDetailAfter(SaleOrderAlert saleInquiryForm,
                                                                    @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                                    @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
@@ -282,7 +282,7 @@ public class SaleOrderController {
      */
     @ApiOperation(value = "销售订单弹框明细-采购订单使用", notes = "销售订单弹框明细-采购订单使用")
     @GetMapping(value = "/selectSaleOrderDetailAlertExistSup")
-    @PermissionData(pageComponent = "saleCode/salesOrder/SaleOrderFormList")
+    @PermissionData
     public Result<IPage<SaleOrderAlert>> selectSaleOrderDetailAlertExistSup(SaleOrderAlert saleInquiryForm,String after,
                                                                             @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                                             @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
@@ -361,7 +361,7 @@ public class SaleOrderController {
      */
     @ApiOperation(value = "销售订单弹框明细-发货通知单使用", notes = "销售订单弹框明细-发货通知单使用")
     @GetMapping(value = "/selectSaleOrderDetailAlertDelivery")
-    @PermissionData(pageComponent = "saleCode/salesOrder/SaleOrderFormList")
+    @PermissionData
     public Result<IPage<SaleOrderAlert>> selectSaleOrderDetailAlertDelivery(SaleOrderAlert saleInquiryForm,
                                                                             @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                                             @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,

+ 104 - 1
srm-module-code/src/main/java/org/jeecg/modules/saleCode/controller/SaleQuotationController.java

@@ -43,6 +43,7 @@ import org.jeecg.modules.cuspCode.service.ICuspCustomerProfileService;
 import org.jeecg.modules.cuspCode.service.ICuspSupplierProfileService;
 import org.jeecg.modules.purCode.entity.PurInquiryForm;
 import org.jeecg.modules.purCode.entity.PurInquiryFormProduct;
+import org.jeecg.modules.purCode.entity.PurQuotationSelection;
 import org.jeecg.modules.purCode.entity.PurQuotationSelectionProduct;
 import org.jeecg.modules.purCode.service.IPurInquiryFormProductService;
 import org.jeecg.modules.purCode.service.IPurQuotationSelectionProductService;
@@ -71,6 +72,7 @@ import org.jeecg.modules.saleCode.vo.SaleQuotationPage;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.core.env.Environment;
 import org.springframework.core.io.ClassPathResource;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.servlet.ModelAndView;
@@ -140,6 +142,9 @@ public class SaleQuotationController {
     @Autowired
     private ISysDepartService sysDepartService;
 
+    @Autowired
+    private Environment environment;
+
     @Value(value = "${jeecg.path.upload}")
     private String uploadpath;
     /**
@@ -464,16 +469,38 @@ public class SaleQuotationController {
             return Result.error("数据为空!");
         }
 
+        BigDecimal checkQuotaBig = new BigDecimal("8000");
+
+        List<String> listId = new ArrayList<>();
+
+        try {
+            String checkQuota = sysDictService.queryDescriptionByKey("check_quota_sale");
+            if(StringUtils.isNotBlank(checkQuota)){
+                checkQuotaBig = new BigDecimal(checkQuota);
+            }
+
+        }catch (Exception e){
+
+        }
+
         StringBuffer sb = new StringBuffer();
         for (SaleQuotation o : list) {
             // 1-已提交,0-未提交
             Integer submit = o.getStatus();
             String code = o.getBillCode();
 
-            if (submit != null && submit.equals(1)) {
+            if (submit != null && (submit.equals(1)||submit.equals(2))) {
                 sb.append("单据编码" + code).append("已提交,请勿再次提交;");
                 continue;
             }
+
+            BigDecimal totalAmountUsd = o.getSaleAmount() == null ? BigDecimal.ZERO : o.getSaleAmount();
+            BigDecimal exchangeRate = o.getExchangeRate() == null ? BigDecimal.ONE : o.getExchangeRate();
+            String id = o.getId();
+            if(totalAmountUsd.multiply(exchangeRate).compareTo(checkQuotaBig) >= 0 ){
+                listId.add(id);
+            }
+
         }
 
         if (StringUtils.isNotBlank(sb.toString())) {
@@ -494,9 +521,85 @@ public class SaleQuotationController {
             approverHeadService.submitApprove("sale_quotation","销售报价单",code,o.getId());
         }
 
+
+        if(StringUtils.isNotBlank(sysUser.getOrgCode()) &&
+                (sysUser.getUsername().equals("admin")||
+                        sysUser.getOrgCode().indexOf("A02A03") != -1)) {
+
+            if(listId.size() > 0){
+
+                String active = getActiveProfile();
+                if(StringUtils.isNotBlank(active) && (active.equals("prod") || active.equals("dev"))){
+
+                    QueryWrapper<SaleQuotation> queryWrapper2 = new QueryWrapper<>();
+                    queryWrapper2.in("id",listId);
+                    SaleQuotation ent2 = new SaleQuotation();
+//              提交(1是 0否 2待审核)
+                    ent2.setStatus(2);
+                    saleQuotationService.update(ent2, queryWrapper2);
+
+                    return Result.OK("提交成功(本单报价金额超过"+checkQuotaBig+"美金,需上级审批)!");
+                }
+
+            }
+
+        }
+
         return Result.OK("提交成功!");
     }
 
+
+
+    /**
+     * 审批
+     *
+     * @param ids
+     * @return
+     */
+    @AutoLog(value = "报价选定大额审批")
+    @ApiOperation(value = "报价选定大额审批-审批", notes = "报价选定大额审批-审批")
+    @GetMapping(value = "/approvalBatch")
+    public Result<String> approvalBatch(@RequestParam(name = "ids", required = true) String ids) {
+
+        QueryWrapper<SaleQuotation> queryWrapper = new QueryWrapper<>();
+        queryWrapper.in("id", Arrays.asList(ids.split(",")));
+
+        List<SaleQuotation> list = saleQuotationService.list(queryWrapper);
+        if (list.size() == 0) {
+            return Result.error("数据为空!");
+        }
+
+        StringBuffer sb = new StringBuffer();
+        for (SaleQuotation o : list) {
+            //提交(1-是 ,0-否 ,2-待审批)
+            Integer submit = o.getStatus();
+            String code = o.getBillCode();
+
+            if (submit != null && submit != null && !submit.equals(2)) {
+                sb.append("单据编码" + code).append("无需审批;");
+                continue;
+            }
+
+        }
+
+        if (StringUtils.isNotBlank(sb.toString())) {
+
+            return Result.error(sb.toString());
+        }
+        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        SaleQuotation ent = new SaleQuotation();
+        ent.setStatus(1);
+        ent.setApprovalBy(sysUser.getUsername());
+        ent.setApprovalTime(new Date());
+        saleQuotationService.update(ent, queryWrapper);
+
+        return Result.OK("审批成功!");
+    }
+
+    public String getActiveProfile() {
+        return environment.getProperty("spring.profiles.active");
+    }
+
     /**
      * 批量取消提交
      *

+ 8 - 1
srm-module-code/src/main/java/org/jeecg/modules/saleCode/entity/SaleQuotation.java

@@ -146,7 +146,7 @@ public class SaleQuotation implements Serializable {
 
     /**状态(1-已提交,0-未提交)*/
     @Excel(name = "提交状态(Submit Status)", width = 15,dicCode = "yes_or_no")
-    @ApiModelProperty(value = "状态(1-已提交,0-未提交)")
+    @ApiModelProperty(value = "状态(1-已提交,0-未提交,2待审核)")
     private Integer status;
     /**业务类型(busyness type)*/
 //	@Excel(name = "业务类型(busyness type)", width = 15)
@@ -214,6 +214,13 @@ public class SaleQuotation implements Serializable {
     private String deliveryDayHead;
 
 
+    //审批人
+    private String approvalBy;
+    /**审批时间*/
+    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "审批时间")
+    private Date approvalTime;
     //类型(正常报价,异常报价,拒绝报价)
     private String quotationType;