|
|
@@ -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查询
|
|
|
*
|