Commit a421dc8c by HlQ

[add]

1.添加项目干系人和项目交付日志功能
2.设备返修和备件申请支持文件上传
3.工单管理模块的人员分析和项目分析添加人员查询字段
4.支持钉钉内部 H5 应用获取 token
5.巡检列表返回文件数量
[fix]
1.修改项目合并的 bug
2.合同同步 bug 修改
1 parent 8cb74aa8
Showing 36 changed files with 907 additions and 126 deletions
package vion.controller;
import cn.dev33.satoken.annotation.SaCheckPermission;
import lombok.RequiredArgsConstructor;
import org.dromara.hutool.core.array.ArrayUtil;
import org.dromara.hutool.core.lang.Assert;
import org.springframework.web.bind.annotation.*;
import vion.dto.DeliverLogDTO;
import vion.service.IDeliverLogService;
import vion.vo.DeliverLogVO;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/deliverLog")
public class DeliverLogController {
private final IDeliverLogService deliverLogService;
@GetMapping
@SaCheckPermission(value = "deliverLog:list", orRole = "admin")
public Map<String, TreeMap<String, List<DeliverLogVO>>> list(DeliverLogDTO dto) {
Assert.isTrue(ArrayUtil.isAllNotNull(dto.getLogDateStart(), dto.getLogDateEnd()), "查询时间范围不能为空");
return deliverLogService.list(dto);
}
@GetMapping("/{id}")
@SaCheckPermission(value = "deliverLog:query", orRole = "admin")
public DeliverLogVO getById(@PathVariable Long id) {
return deliverLogService.getById(id);
}
@PostMapping
@SaCheckPermission(value = "deliverLog:save", orRole = "admin")
public String save(@RequestBody List<DeliverLogDTO> deliverLogDTOList) {
return deliverLogService.save(deliverLogDTOList);
}
@PostMapping("/{id}")
@SaCheckPermission(value = "deliverLog:edit", orRole = "admin")
public String update(@PathVariable Long id, @RequestBody DeliverLogDTO dto) {
dto.setId(id);
return deliverLogService.update(dto);
}
@DeleteMapping("/{id}")
@SaCheckPermission(value = "deliverLog:remove", orRole = "admin")
public String remove(@PathVariable Long id) {
return deliverLogService.removeById(id) ? "删除成功" : "删除失败";
}
}
......@@ -46,7 +46,7 @@ public class RepairRecController {
@PostMapping("/{id}")
@SaCheckPermission(value = "repairRec:edit", orRole = "admin")
public String updById(@PathVariable Long id, @RequestBody RepairRecDTO dto) {
public String updById(@PathVariable Long id, RepairRecDTO dto) {
return repairRecService.updById(id, dto);
}
......@@ -56,4 +56,10 @@ public class RepairRecController {
return repairRecService.removeById(id) ? "删除成功" : "删除失败";
}
@GetMapping("/notify")
@SaCheckPermission(value = "repairRec:notify", orRole = "admin")
public String notify(Long id, String userid) {
return repairRecService.notify(id, userid) ? "钉钉提醒成功" : "钉钉提醒失败";
}
}
......@@ -60,7 +60,7 @@ public class SparePartController {
@PostMapping("/{id}")
@SaCheckPermission(value = "sparePart:edit", orRole = "admin")
public String updById(@PathVariable Long id, @RequestBody SparePartDTO dto) {
public String updById(@PathVariable Long id, SparePartDTO dto) {
return sparePartService.updById(id, dto);
}
......@@ -98,4 +98,10 @@ public class SparePartController {
}
}
@GetMapping("/notify")
@SaCheckPermission(value = "sparePart:notify", orRole = "admin")
public String notify(Long id, String userid) {
return sparePartService.notify(id, userid) ? "钉钉提醒成功" : "钉钉提醒失败";
}
}
......@@ -15,9 +15,8 @@ import org.dromara.hutool.core.util.ObjUtil;
import org.springframework.web.bind.annotation.*;
import vion.dto.StatusDTO;
import vion.dto.StoreDTO;
import vion.model.RStoreUser;
import vion.model.Store;
import vion.model.StoreLog;
import vion.model.*;
import vion.service.IRStoreConfederateService;
import vion.service.IRStoreUserService;
import vion.service.IStoreLogService;
import vion.service.IStoreService;
......@@ -37,9 +36,10 @@ public class StoreController {
private final IStoreService storeService;
private final IRStoreUserService storeUserService;
private final IStoreLogService storeLogService;
private final IRStoreConfederateService storeConfederateService;
private final Converter converter;
@GetMapping("/stores")
@PostMapping("/store")
@SaCheckPermission(value = "store:list", orRole = "admin")
public Page<StoreVO> getStoreList(StoreDTO data, @RequestBody(required = false) List<OrderItem> orderItemList) {
return storeService.getStoreList(data, orderItemList);
......@@ -190,4 +190,34 @@ public class StoreController {
return storeService.statState();
}
@GetMapping("/store/confederate")
@SaCheckPermission(value = "store:confederate:list", orRole = "admin")
public Page<RStoreConfederate> list(RStoreConfederate storeConfederate) {
return storeConfederateService.lambdaQuery(storeConfederate).page(Page.of(storeConfederate.getPageNum(), storeConfederate.getPageSize()));
}
@GetMapping("/store/confederate/{id}")
@SaCheckPermission(value = "store:confederate:query", orRole = "admin")
public RStoreConfederate getById(@PathVariable Long id) {
return storeConfederateService.getById(id);
}
@PostMapping("/store/confederate")
@SaCheckPermission(value = "store:confederate:save", orRole = "admin")
public String save(@RequestBody RStoreConfederate storeConfederate) {
return storeConfederateService.save(storeConfederate) ? "新增成功" : "新增失败";
}
@PostMapping("/store/confederate/{id}")
@SaCheckPermission(value = "store:confederate:edit", orRole = "admin")
public String update(@PathVariable Long id, @RequestBody RStoreConfederate storeConfederate) {
storeConfederate.setId(id);
return storeConfederateService.updateById(storeConfederate) ? "修改成功" : "修改失败";
}
@DeleteMapping("/store/confederate/{id}")
@SaCheckPermission(value = "store:confederate:remove", orRole = "admin")
public String remove(@PathVariable Long id) {
return storeConfederateService.removeById(id) ? "删除成功" : "删除失败";
}
}
......@@ -144,16 +144,17 @@ public class TaskController {
public List<Map<String, Object>> peopleAnalysis(@DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate,
@DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate,
Integer source,
Long userId) {
return taskService.peopleAnalysis(startDate, endDate, source, userId);
Long[] userIds) {
return taskService.peopleAnalysis(startDate, endDate, source, userIds);
}
@GetMapping("/task/proAnal")
@SaCheckPermission(value = "task:proAnal", orRole = "admin")
public List<Map<String, Object>> proAnalysis(@DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate,
@DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate,
Integer source) {
return taskService.proAnalysis(startDate, endDate, source);
Integer source,
Long[] userIds) {
return taskService.proAnalysis(startDate, endDate, source, userIds);
}
@GetMapping("/task/summaryAnal")
......
......@@ -103,6 +103,11 @@ public class UserController {
return dingMod.dingCallback(target, dto, res);
}
@GetMapping("/ding/getPlatformToken")
public Object getPlatformToken(String authCode) {
return dingMod.getPlatformToken(authCode);
}
@GetMapping("/logout")
public String logout() {
StpUtil.logout();
......
package vion.cron;
import cn.hutool.core.util.NumberUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.dromara.hutool.core.collection.CollUtil;
import org.dromara.hutool.core.collection.ListUtil;
import org.dromara.hutool.core.date.DateUtil;
import org.dromara.hutool.core.lang.Opt;
import org.dromara.hutool.core.math.NumberUtil;
import org.dromara.hutool.core.text.StrUtil;
import org.dromara.hutool.core.util.ObjUtil;
import org.dromara.hutool.crypto.SecureUtil;
......@@ -56,7 +56,7 @@ public class ContractRunner {
@Value("${xbongbong.corpid}")
private String corpid;
@Scheduled(cron = "0 0 * * * *")
// @Scheduled(cron = "0 0 * * * *")
@Transactional(rollbackFor = Exception.class)
public void contractSync() {
log.info("【开始】从crm系统同步合同信息");
......@@ -297,40 +297,74 @@ public class ContractRunner {
log.info("【结束】从crm系统同步合同信息");
}
// @Scheduled(cron = "0 0 * * * *")
@Scheduled(cron = "0 0 * * * *")
@Transactional(rollbackFor = Exception.class)
public void contractSync1() {
String modifyTime = Opt.ofNullable((String) redissonClient.getBucket(RedisKeyEnum.CONTRACT_SYNC_NEW_TIME.getVal()).get()).orElse("0");
Long modifyTime = Opt.ofNullable((Long) redissonClient.getBucket(RedisKeyEnum.CONTRACT_SYNC_NEW_TIME.getVal()).get()).orElse(0L);
// 只同步2024-05-07号(含)之后的合同
var json = JSONUtil.ofObj()
.set("sortMap", JSONUtil.ofObj()
.set("field", "updateTime")
.set("order", "desc"))
.set("sort", "desc"))
.set("conditions", JSONUtil.ofArray()
.put(JSONUtil.ofObj()
.set("attr", "date_3")
.set("symbol", "greaterequal")
.set("value", new String[]{"1715356800"}))
.put(JSONUtil.ofObj()
.set("attr", "updateTime")
.set("fieldType", "10015")
.set("symbol", "greatethan")
.set("value", new String[]{"1713324916"}))
.set("value", new String[]{String.valueOf(modifyTime / 1000)}))
)
.set("corpid", corpid)
.set("formId", 8429903);
.set("formId", 8429903)
.set("pageSize", 100);
var res = Request.of("https://proapi.xbongbong.com/pro/v2/api/contract/list")
.header("sign", SecureUtil.sha256(json.toString() + token))
.body(json.toString())
.method(Method.POST)
.send();
var jobj = JSONUtil.parseObj(res.bodyStr());
if (jobj.getInt("code") != 1) {
log.error("获取合同列表失败,错误原因:{}", jobj);
var jobO = JSONUtil.parseObj(res.bodyStr());
if (jobO.getInt("code") != 1) {
log.error("获取合同列表失败,错误原因:{}", jobO);
return;
}
var jsonArray = jobj.getJSONObject("result").getJSONArray("list");
var dataIdList = jsonArray.stream().map(v -> JSONUtil.parseObj(v).getInt("dataId")).toList();
if (CollUtil.isEmpty(dataIdList)) {
Integer cnt = jobO.getJSONObject("result").getInt("totalCount");
Integer page = jobO.getJSONObject("result").getInt("totalPage");
if (NumberUtil.equals(cnt, 0)) {
log.info("没有需要插入或更新的合同");
return;
}
var jsonArray = jobO.getJSONObject("result").getJSONArray("list");
var dataIdSet = jsonArray.stream().map(v -> JSONUtil.parseObj(v).getInt("dataId")).collect(Collectors.toSet());
for (int i = 2; i <= page; i++) {
var jsonR = JSONUtil.ofObj()
.set("sortMap", JSONUtil.ofObj()
.set("field", "updateTime")
.set("order", "desc"))
.set("conditions", JSONUtil.ofArray()
.put(JSONUtil.ofObj()
.set("attr", "updateTime")
.set("fieldType", "10015")
.set("symbol", "greatethan")
.set("value", new String[]{String.valueOf(modifyTime)}))
)
.set("corpid", corpid)
.set("formId", 8429903)
.set("page", i)
.set("pageSize", 100);
var resR = Request.of("https://proapi.xbongbong.com/pro/v2/api/contract/list")
.header("sign", SecureUtil.sha256(jsonR.toString() + token))
.body(json.toString())
.method(Method.POST)
.send();
var jobR = JSONUtil.parseObj(resR.bodyStr());
var jsonArrR = jobR.getJSONObject("result").getJSONArray("list");
var dataIdSetR = jsonArrR.stream().map(v -> JSONUtil.parseObj(v).getInt("dataId")).collect(Collectors.toSet());
dataIdSet.addAll(dataIdSetR);
}
Map<String, Integer> contractTypeMap = dictionaryService.lambdaQuery().eq(Dictionary::getType, "contract_type").list().stream().collect(Collectors.toMap(Dictionary::getValue, Dictionary::getKey));
......@@ -341,7 +375,7 @@ public class ContractRunner {
log.error("获取CRM产品信息为空");
return;
}
dataIdList.forEach(dataId -> {
dataIdSet.forEach(dataId -> {
var json1 = JSONUtil.ofObj()
.set("corpid", corpid)
.set("dataId", dataId);
......@@ -364,6 +398,11 @@ public class ContractRunner {
contract.setSignDate(DateUtil.date(jsonObj1.getLong("date_1") * 1000));
contract.setMaintainSdate(Opt.ofNullable(jsonObj1.getLong("date_4")).map(sec -> DateUtil.date(sec * 1000)).orElse(null));
contract.setMaintainEdate(Opt.ofNullable(jsonObj1.getLong("date_5")).map(sec -> DateUtil.date(sec * 1000)).orElse(null));
String warrantyPeriod = Opt.ofNullable(jsonObj1.getJSONObject("text_23")).map(wp -> wp.getStr("text")).orElse("");
if (StrUtil.isNotBlank(warrantyPeriod) && warrantyPeriod.contains("个月")) {
String substring = warrantyPeriod.substring(0, (warrantyPeriod.length() - 2));
contract.setWarrantyPeriod(Integer.parseInt(substring));
}
contract.setStatus(1);
contract.setTotalAmount(jsonObj1.getBigDecimal("num_1"));
contract.setPaidAmount(BigDecimal.ZERO);
......@@ -425,7 +464,7 @@ public class ContractRunner {
var contractProduct = new RContractProduct();
contractProduct.setContractNo(contract.getContractNo());
contractProduct.setProductName(crmPro.getStr("text_1"));
contractProduct.setProductCode(crmPro.getStr("text_17"));
contractProduct.setProductCode(crmPro.getStr("serialNo"));
contractProduct.setProductModel(crmPro.getStr("text_4"));
contractProduct.setNum(product.getInt("num_3"));
contractProduct.setTaxPrice(product.getBigDecimal("num_1"));
......@@ -437,8 +476,8 @@ public class ContractRunner {
contractProduct.setTotalPrice(product.getBigDecimal("num_5"));
productList.add(contractProduct);
});
contractProductService.saveBatch(productList);
});
contractProductService.saveBatch(productList);
Map<String, Contract> no2ContactMap = contractService.list().stream().collect(Collectors.toMap(Contract::getContractNo, Function.identity()));
......@@ -629,6 +668,5 @@ public class ContractRunner {
log.info("【开始】计算门店维保状态");
storeService.calMaintainStatus(ListUtil.empty());
log.info("【结束】计算门店维保状态");
}
}
package vion.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@Getter
@Setter
public class DeliverLogDTO extends BaseDTO {
private Long id;
/**
* 集团id
*/
private Long accountId;
/**
* 项目id
*/
private Long storeId;
/**
* 合同编号
*/
private String contractNo;
/**
* 日志人
*/
private Long userId;
/**
* 日志日期
*/
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date logDate;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date logDateStart;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date logDateEnd;
/**
* 干系人
*/
private Long confederateId;
/**
* 服务方式
*/
private Integer serviceType;
/**
* 耗时
*/
private Double logHour;
/**
* 工作内容
*/
private String content;
}
\ No newline at end of file
......@@ -86,6 +86,7 @@ public class RepairRecDTO extends BaseDTO {
* 发货日期
*/
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date shipDate;
/**
......
......@@ -81,6 +81,7 @@ public class SparePartDTO extends BaseDTO {
* 发货日期
*/
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date shipDate;
/**
......
......@@ -19,7 +19,8 @@ public class InterceptorConfig implements WebMvcConfigurer {
}))
.addPathPatterns("/api/**")
.excludePathPatterns("/api/dictionarys")
.excludePathPatterns("/api/upLoadFile", "/api/ding/callback/**", "/api/wechat/**", "/error")
.excludePathPatterns("/api/upLoadFile", "/api/ding/callback/**", "/api/ding/getPlatformToken", "/api" +
"/wechat/**", "/error")
.excludePathPatterns("/api/order/sign/*")
.excludePathPatterns("/api/form/sign/*")
.excludePathPatterns("/api/wechatCallback")
......
package vion.mapper;
import com.github.yulichang.base.MPJBaseMapper;
import vion.model.DeliverLog;
/**
* @author HlQ
* @date 2024/5/21
*/
public interface DeliverLogMapper extends MPJBaseMapper<DeliverLog> {
}
\ No newline at end of file
package vion.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import vion.model.RStoreConfederate;
/**
* @author HlQ
* @date 2024/5/21
*/
public interface RStoreConfederateMapper extends BaseMapper<RStoreConfederate> {
}
\ No newline at end of file
package vion.model;
import com.baomidou.mybatisplus.annotation.*;
import io.github.linpeilie.annotations.AutoMapper;
import io.github.linpeilie.annotations.AutoMappers;
import lombok.Data;
import vion.dto.DeliverLogDTO;
import vion.vo.DeliverLogVO;
import java.util.Date;
/**
* 项目交付人员日志
*/
@Data
@TableName(value = "tbl_deliver_log")
@AutoMappers({
@AutoMapper(target = DeliverLogVO.class),
@AutoMapper(target = DeliverLogDTO.class),
})
public class DeliverLog {
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 集团id
*/
@TableField(value = "account_id")
private Long accountId;
/**
* 项目id
*/
@TableField(value = "store_id")
private Long storeId;
/**
* 合同编号
*/
@TableField(value = "contract_no")
private String contractNo;
/**
* 日志人
*/
@TableField(value = "user_id")
private Long userId;
/**
* 日志日期
*/
@TableField(value = "log_date")
private Date logDate;
/**
* 干系人
*/
@TableField(value = "confederate_id")
private Long confederateId;
/**
* 服务方式
*/
@TableField(value = "service_type")
private Integer serviceType;
/**
* 耗时
*/
@TableField(value = "log_hour")
private Double logHour;
/**
* 工作内容
*/
@TableField(value = "content")
private String content;
/**
* 创建时间
*/
@TableField(value = "create_time", fill = FieldFill.INSERT)
private Date createTime;
/**
* 修改时间
*/
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
private Date updateTime;
}
\ No newline at end of file
......@@ -40,6 +40,7 @@ public class FileInfo {
/** 合同id */
private Long contractId;
/** 文件名称 */
@TableField(condition = SqlCondition.LIKE)
private String name;
/** 文件地址 */
private String url;
......
package vion.model;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import vion.dto.BaseDTO;
import java.util.Date;
/**
* 项目干系人
*/
@Data
@TableName(value = "r_store_confederate")
public class RStoreConfederate extends BaseDTO {
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 项目id
*/
@TableField(value = "store_id")
private Long storeId;
/**
* 职位
*/
@TableField(value = "\"position\"")
private String position;
/**
* 姓名
*/
@TableField(value = "\"name\"", condition = SqlCondition.LIKE)
private String name;
/**
* 备注
*/
@TableField(value = "remark")
private String remark;
/**
* 创建时间
*/
@TableField(value = "create_time", fill = FieldFill.INSERT)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
/**
* 修改时间
*/
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;
}
\ No newline at end of file
package vion.model;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.util.Date;
......@@ -28,8 +29,10 @@ public class RStoreTag {
private Long tagId;
@TableField(value = "create_time", fill = FieldFill.INSERT)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;
}
\ No newline at end of file
......@@ -36,11 +36,11 @@ public class Store {
*/
private String customerName;
/**
* 实施类型:0纯供货、1供货+安装、3续保、4维修
* 实施类型:1纯供货、2供货+安装、3续保、4维修
*/
private Integer implementType;
/**
* 项目状态:0待确认、1进行中、2已完成、3挂起
* 项目状态:1待确认、2进行中、3已完成、4挂起
*/
private Integer projectState;
/**
......
package vion.service;
import com.github.yulichang.base.MPJBaseService;
import vion.dto.DeliverLogDTO;
import vion.model.DeliverLog;
import vion.vo.DeliverLogVO;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
public interface IDeliverLogService extends MPJBaseService<DeliverLog> {
Map<String, TreeMap<String, List<DeliverLogVO>>> list(DeliverLogDTO dto);
DeliverLogVO getById(Long id);
String save(List<DeliverLogDTO> deliverLogDTOList);
String update(DeliverLogDTO dto);
}
package vion.service;
import vion.model.RStoreConfederate;
import com.baomidou.mybatisplus.extension.service.IService;
public interface IRStoreConfederateService extends IService<RStoreConfederate> {
}
......@@ -20,4 +20,7 @@ public interface IRepairRecService extends MPJBaseService<RepairRec> {
RepairRecVO getRepairRecDetail(Long id, String uuid);
String updById(Long id, RepairRecDTO dto);
Boolean notify(Long id, String userid);
}
......@@ -20,4 +20,6 @@ public interface ISparePartService extends MPJBaseService<SparePart> {
SparePartVO getSparePartDetail(Long id, String uuid);
String updById(Long id, SparePartDTO dto);
Boolean notify(Long id, String userid);
}
......@@ -28,7 +28,7 @@ public interface IStoreService extends MPJBaseService<Store> {
List<Map<String, Number>> fileDetail(@RequestParam List<Long> storeIdList);
boolean logNotify(Long id, String[] userIdStr);
Boolean logNotify(Long id, String[] userIdStr);
String addCron(Long storeId, String storeName, String cronStr, String userId);
......
......@@ -26,9 +26,9 @@ public interface ITaskService extends MPJBaseService<Task> {
String urgeTask(Long taskId, String remark);
List<Map<String, Object>> peopleAnalysis(Date startDate, Date endDate, Integer source, Long userId);
List<Map<String, Object>> peopleAnalysis(Date startDate, Date endDate, Integer source, Long[] userIds);
List<Map<String, Object>> proAnalysis(Date startDate, Date endDate, Integer source);
List<Map<String, Object>> proAnalysis(Date startDate, Date endDate, Integer source, Long[] userIds);
Map<String, Map<String, List<Task>>> summaryAnalysis(Date startDate, Date endDate, Integer source);
}
......@@ -58,7 +58,7 @@ public class ConstructionTeamServiceImpl extends MPJBaseServiceImpl<Construction
@Override
public Page<RContractTeamVO> list(RContractTeamDTO dto) {
MPJLambdaWrapper<RContractTeam> wrapper = new MPJLambdaWrapper<>(converter.convert(dto, RContractTeam.class))
var wrapper = new MPJLambdaWrapper<>(converter.convert(dto, RContractTeam.class))
.selectAll(RContractTeam.class)
.selectAs(Contract::getContractNo, RContractTeamVO::getContractNo)
.selectAs(Contract::getName, RContractTeamVO::getContractName)
......
......@@ -129,7 +129,7 @@ public class ContractServiceImpl extends MPJBaseServiceImpl<ContractMapper, Cont
Page<Contract> contractList = this.lambdaQuery(converter.convert(dto, Contract.class))
.select(Contract::getId, Contract::getName, Contract::getContractNo, Contract::getType, Contract::getSignDate, Contract::getWarrantyPeriod, Contract::getFinalDate, Contract::getStatus, Contract::getSaleName, Contract::getCustomerName, Contract::getMaintainSdate, Contract::getMaintainEdate)
.in(CollUtil.isNotEmpty(ids), Contract::getId, ids)
.in(ObjUtil.isNotNull(dto.getStoreId()), Contract::getId, ids)
.orderByDesc(Contract::getEntryTime)
.page(Page.of(dto.getPageNum(), dto.getPageSize()));
List<ContractVO> contractVOList = converter.convert(contractList.getRecords(), ContractVO.class);
......
package vion.service.impl;
import com.github.yulichang.base.MPJBaseServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import io.github.linpeilie.Converter;
import lombok.RequiredArgsConstructor;
import org.dromara.hutool.core.date.DateUtil;
import org.dromara.hutool.core.lang.Opt;
import org.dromara.hutool.core.text.StrUtil;
import org.dromara.hutool.json.JSONObject;
import org.dromara.hutool.json.JSONUtil;
import org.redisson.api.RedissonClient;
import org.springframework.stereotype.Service;
import vion.constant.RedisKeyEnum;
import vion.dto.DeliverLogDTO;
import vion.mapper.DeliverLogMapper;
import vion.model.*;
import vion.service.IDeliverLogService;
import vion.service.IRStoreConfederateService;
import vion.service.IStoreService;
import vion.third.DingMod;
import vion.vo.DeliverLogVO;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.function.Function;
import java.util.stream.Collectors;
@Service
@RequiredArgsConstructor
public class DeliverLogServiceImpl extends MPJBaseServiceImpl<DeliverLogMapper, DeliverLog> implements IDeliverLogService {
private final IStoreService storeService;
private final IRStoreConfederateService storeConfederateService;
private final RedissonClient redissonClient;
private final Converter converter;
private final DingMod dingMod;
@Override
public Map<String, TreeMap<String, List<DeliverLogVO>>> list(DeliverLogDTO dto) {
var wrapper = new MPJLambdaWrapper<>(converter.convert(dto, DeliverLog.class))
.selectAll(DeliverLog.class)
.selectAs(Store::getName, DeliverLogVO::getStoreName)
.selectAs(RStoreConfederate::getName, DeliverLogVO::getConfederateName)
.selectAs(User::getUsername, DeliverLogVO::getUserName)
.selectAs(Contract::getSaleName, DeliverLogVO::getContractSaleName)
.leftJoin(Store.class, Store::getId, DeliverLog::getStoreId)
.leftJoin(RStoreConfederate.class, RStoreConfederate::getId, DeliverLog::getConfederateId)
.leftJoin(User.class, User::getId, DeliverLog::getUserId)
.leftJoin(Contract.class, Contract::getContractNo, DeliverLog::getContractNo)
.between(DeliverLog::getLogDate, dto.getLogDateStart(), dto.getLogDateEnd());
var deliverLogList = this.selectJoinList(DeliverLogVO.class, wrapper);
return deliverLogList.stream().collect(Collectors.groupingBy(DeliverLogVO::getUserName,
Collectors.groupingBy(v -> DateUtil.formatDate(v.getLogDate()), () -> new TreeMap<String,
List<DeliverLogVO>>(Comparator.reverseOrder()), Collectors.toList())));
}
@Override
public DeliverLogVO getById(Long id) {
var wrapper = new MPJLambdaWrapper<DeliverLog>()
.selectAll(DeliverLog.class)
.selectAs(Store::getName, DeliverLogVO::getStoreName)
.selectAs(RStoreConfederate::getName, DeliverLogVO::getConfederateName)
.selectAs(User::getUsername, DeliverLogVO::getUserName)
.selectAs(Contract::getSaleName, DeliverLogVO::getContractSaleName)
.leftJoin(Store.class, Store::getId, DeliverLog::getStoreId)
.leftJoin(RStoreConfederate.class, RStoreConfederate::getId, DeliverLog::getConfederateId)
.leftJoin(User.class, User::getId, DeliverLog::getUserId)
.leftJoin(Contract.class, Contract::getContractNo, DeliverLog::getContractNo)
.eq(DeliverLog::getId, id)
.orderByDesc(DeliverLog::getUpdateTime);
return this.selectJoinOne(DeliverLogVO.class, wrapper);
}
@Override
public String save(List<DeliverLogDTO> deliverLogDTOList) {
var deliverLogList = converter.convert(deliverLogDTOList, DeliverLog.class);
var storeIdList = deliverLogList.stream().map(DeliverLog::getStoreId).toList();
var confederateIdList = deliverLogList.stream().map(DeliverLog::getConfederateId).toList();
var stores = storeService.listByIds(storeIdList);
var id2StoreMap = stores.stream().collect(Collectors.toMap(Store::getId, Function.identity()));
var confederateList = storeConfederateService.listByIds(confederateIdList);
var storeId2NameMap = confederateList.stream().collect(Collectors.toMap(RStoreConfederate::getId, RStoreConfederate::getName));
deliverLogList.forEach(deliverLog -> {
var storeId = deliverLog.getStoreId();
var store = id2StoreMap.get(storeId);
var confederateName = Opt.ofNullable(deliverLog.getConfederateId()).map(storeId2NameMap::get).orElse("暂无");
Opt.ofNullable(redissonClient.getBucket(RedisKeyEnum.DING_PREFIX.getVal() + RedisKeyEnum.USER_ID.getVal() + store.getSalesperson()).get())
.map(u -> (User) u)
.map(User::getUserid)
.ifPresent(userid -> dingMod.workMsg(buildMsg(userid, store.getName(), confederateName, deliverLog)));
});
return this.saveBatch(deliverLogList) ? "新增成功" : "新增失败";
}
@Override
public String update(DeliverLogDTO dto) {
var deliverLog = converter.convert(dto, DeliverLog.class);
var store = storeService.getById(dto.getStoreId());
var confederate = storeConfederateService.getById(dto.getConfederateId());
Opt.ofNullable(redissonClient.getBucket(RedisKeyEnum.DING_PREFIX.getVal() + RedisKeyEnum.USER_ID.getVal() + store.getSalesperson()).get())
.map(u -> (User) u)
.map(User::getUserid)
.ifPresent(userid -> dingMod.workMsg(buildMsg(userid, store.getName(),
Opt.ofNullable(confederate).map(RStoreConfederate::getName).orElse("暂无"),
deliverLog)));
return this.updateById(deliverLog) ? "修改成功" : "修改失败";
}
JSONObject buildMsg(String userid, String storeName, String confederateName, DeliverLog deliverLog) {
var jsonObj = JSONUtil.ofObj()
.set("agent_id", 2358374016L)
.set("userid_list", userid);
var msg = new JSONObject();
var content = new JSONObject();
content.set("title", "项目交付日志提醒")
.set("text", StrUtil.format("""
#### 项目:{}
#### 合同编号:{}
#### 日志提交人:{}
#### 干系人:{}
#### 工时:{}
#### 工作内容:{}
#### 发送时间:{}""", storeName,
Opt.ofBlankAble(deliverLog.getContractNo()).orElse("暂无"),
Opt.ofNullable(redissonClient.getBucket(RedisKeyEnum.DING_PREFIX.getVal() + RedisKeyEnum.USER_ID.getVal() + deliverLog.getUserId()).get()).map(u -> (User) u).map(User::getUsername).orElse("不存在该提交人"),
confederateName,
deliverLog.getLogHour(),
deliverLog.getContent(),
DateUtil.now()));
msg.set("msgtype", "markdown").set("markdown", content);
jsonObj.set("msg", msg);
return jsonObj;
}
}
package vion.service.impl;
import org.dromara.hutool.core.collection.CollUtil;
import org.dromara.hutool.core.collection.ListUtil;
import org.dromara.hutool.core.lang.Opt;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.base.MPJBaseServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import io.github.linpeilie.Converter;
import lombok.RequiredArgsConstructor;
import org.dromara.hutool.core.collection.CollUtil;
import org.dromara.hutool.core.collection.ListUtil;
import org.dromara.hutool.core.lang.Opt;
import org.springframework.stereotype.Service;
import vion.dto.InspectDTO;
import vion.mapper.InspectMapper;
import vion.model.Account;
import vion.model.Form;
import vion.model.Inspect;
import vion.model.Store;
import vion.model.*;
import vion.service.IFileService;
import vion.service.IFormService;
import vion.service.IInspectService;
import vion.vo.FormVO;
......@@ -30,6 +28,7 @@ public class InspectServiceImpl extends MPJBaseServiceImpl<InspectMapper, Inspec
private final IFormService formService;
private final Converter converter;
private final IFileService fileService;
@Override
public Page<InspectVO> getInspectList(InspectDTO data) {
......@@ -54,6 +53,18 @@ public class InspectServiceImpl extends MPJBaseServiceImpl<InspectMapper, Inspec
inspectVO.setFormList(inspectId2FormIdMap.getOrDefault(inspectVO.getId(), ListUtil.empty()));
});
});
Opt.ofEmptyAble(inspectVOPage.getRecords())
.map(l -> l.stream().map(InspectVO::getId).collect(Collectors.toList()))
.map(idList -> fileService.lambdaQuery().in(FileInfo::getSourceId, idList).eq(FileInfo::getSourceType, 4).list())
.filter(CollUtil::isNotEmpty)
.ifPresent(fileList -> {
Map<Long, Long> id2CntMap = fileList.stream().collect(Collectors.groupingBy(FileInfo::getSourceId
, Collectors.counting()));
inspectVOPage.getRecords().forEach(inspectVO -> {
inspectVO.setFileCount(id2CntMap.getOrDefault(inspectVO.getId(), 0L).intValue());
});
});
return inspectVOPage;
}
......
package vion.service.impl;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import vion.model.RStoreConfederate;
import vion.mapper.RStoreConfederateMapper;
import vion.service.IRStoreConfederateService;
@Service
public class RStoreConfederateServiceImpl extends ServiceImpl<RStoreConfederateMapper, RStoreConfederate> implements IRStoreConfederateService {
}
package vion.service.impl;
import cn.dev33.satoken.stp.StpUtil;
import org.dromara.hutool.core.array.ArrayUtil;
import org.dromara.hutool.core.date.DateUtil;
import org.dromara.hutool.core.io.file.FileNameUtil;
......@@ -14,6 +15,7 @@ import com.github.yulichang.base.MPJBaseServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import io.github.linpeilie.Converter;
import lombok.RequiredArgsConstructor;
import org.dromara.hutool.json.JSONUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import vion.dto.RepairRecDTO;
......@@ -21,7 +23,9 @@ import vion.mapper.RepairRecMapper;
import vion.model.*;
import vion.service.IFileService;
import vion.service.IRepairRecService;
import vion.third.DingMod;
import vion.vo.RepairRecVO;
import vion.vo.UserVO;
import java.io.File;
import java.io.IOException;
......@@ -38,6 +42,7 @@ import java.util.List;
public class RepairRecServiceImpl extends MPJBaseServiceImpl<RepairRecMapper, RepairRec> implements IRepairRecService {
private final IFileService fileService;
private final DingMod dingMod;
private final Converter converter;
@Value("${fileUrl:}")
......@@ -47,39 +52,9 @@ public class RepairRecServiceImpl extends MPJBaseServiceImpl<RepairRecMapper, Re
public Object frontSubmit(RepairRecDTO dto) {
dto.setUuid(IdUtil.nanoId());
RepairRec repairRec = converter.convert(dto, RepairRec.class);
if (this.save(repairRec)) {
Opt.ofNullable(dto.getFiles())
.ifPresent(fileList ->
Arrays.stream(fileList).forEach(infile -> {
//上传url地址
String orgName = infile.getOriginalFilename();
String mainName = FileNameUtil.mainName(orgName);
String fileExt = FileNameUtil.extName(orgName);
String filename = StrUtil.format("{}_{}.{}", mainName, DateUtil.format(new Date(), "yyyyMMdd_HHmmssSSS"), fileExt);
String path = fileUrl + FileUtil.FILE_SEPARATOR + "repairRec" + FileUtil.FILE_SEPARATOR + repairRec.getId() + FileUtil.FILE_SEPARATOR + filename;
File file = FileUtil.touch(path);
try {
infile.transferTo(file);
} catch (IOException e) {
log.error("保存文件出错", e);
}
FileInfo fileInfo = new FileInfo();
fileInfo.setStoreId(-1L);
fileInfo.setSourceId(repairRec.getId());
fileInfo.setSourceType(23);
fileInfo.setName(filename);
fileInfo.setUrl(path);
fileInfo.setType(fileExt);
fileInfo.setSha256(SecureUtil.sha256(file).toUpperCase());
fileInfo.setUploader(repairRec.getContact());
fileService.save(fileInfo);
}));
return MapUtil.<String, Long>builder()
return this.save(repairRec) ? MapUtil.<String, Long>builder()
.put("id", repairRec.getId())
.build();
}
return "提交失败";
.build() : "提交失败";
}
@Override
......@@ -113,6 +88,66 @@ public class RepairRecServiceImpl extends MPJBaseServiceImpl<RepairRecMapper, Re
@Override
public String updById(Long id, RepairRecDTO dto) {
return this.updateById(converter.convert(dto, RepairRec.class)) ? "更新成功" : "更新失败";
if (this.updateById(converter.convert(dto, RepairRec.class))) {
UserVO user = (UserVO) StpUtil.getTokenSession().get("curLoginUser");
Opt.ofNullable(dto.getFiles())
.ifPresent(fileList ->
Arrays.stream(fileList).forEach(infile -> {
//上传url地址
String orgName = infile.getOriginalFilename();
String mainName = FileNameUtil.mainName(orgName);
String fileExt = FileNameUtil.extName(orgName);
String filename = StrUtil.format("{}_{}.{}", mainName, DateUtil.format(new Date(), "yyyyMMdd_HHmmssSSS"), fileExt);
String path =
fileUrl + FileUtil.FILE_SEPARATOR + "repairRec" + FileUtil.FILE_SEPARATOR + id + FileUtil.FILE_SEPARATOR + filename;
File file = FileUtil.touch(path);
try {
infile.transferTo(file);
} catch (IOException e) {
log.error("保存文件出错", e);
}
FileInfo fileInfo = new FileInfo();
fileInfo.setStoreId(-1L);
fileInfo.setSourceId(id);
fileInfo.setSourceType(23);
fileInfo.setName(filename);
fileInfo.setUrl(path);
fileInfo.setType(fileExt);
fileInfo.setSha256(SecureUtil.sha256(file).toUpperCase());
fileInfo.setUploader(user.getUsername());
fileService.save(fileInfo);
}));
return "更新成功";
}
return "更新失败";
}
@Override
public Boolean notify(Long id, String userid) {
var repairRec = this.getById(id);
var jsonObj = JSONUtil.ofObj()
.set("agent_id", 2358374016L)
.set("userid_list", userid);
var msg = JSONUtil.ofObj();
var content = JSONUtil.ofObj().set("title", "备件已发货");
String text = StrUtil.format("""
### 返修设备已发货
### 项目名称:{}
### 快递单号:{}
### 发货日期:{}
### 发送时间:{}
""", repairRec.getProjectName(), Opt.ofBlankAble(repairRec.getTrackingNumber()).orElse("暂无"),
Opt.ofBlankAble(DateUtil.formatDate(repairRec.getShipDate())).orElse("暂无"), DateUtil.now());
content.set("text", text);
msg.set("msgtype", "markdown").set("markdown", content);
jsonObj.set("msg", msg);
var pushRes = dingMod.workMsg(jsonObj);
return StrUtil.containsIgnoreCase(pushRes, "ok");
}
}
package vion.service.impl;
import cn.dev33.satoken.stp.StpUtil;
import com.github.yulichang.base.MPJBaseServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import io.github.linpeilie.Converter;
import lombok.RequiredArgsConstructor;
import org.dromara.hutool.core.array.ArrayUtil;
import org.dromara.hutool.core.data.id.IdUtil;
import org.dromara.hutool.core.date.DateUtil;
import org.dromara.hutool.core.io.file.FileNameUtil;
import org.dromara.hutool.core.io.file.FileUtil;
import org.dromara.hutool.core.lang.Opt;
import org.dromara.hutool.core.map.MapUtil;
import org.dromara.hutool.core.data.id.IdUtil;
import org.dromara.hutool.core.util.ObjUtil;
import org.dromara.hutool.core.text.StrUtil;
import org.dromara.hutool.core.util.ObjUtil;
import org.dromara.hutool.crypto.SecureUtil;
import com.github.yulichang.base.MPJBaseServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import io.github.linpeilie.Converter;
import lombok.RequiredArgsConstructor;
import org.dromara.hutool.json.JSONUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import vion.dto.SparePartDTO;
......@@ -21,7 +23,9 @@ import vion.mapper.SparePartMapper;
import vion.model.*;
import vion.service.IFileService;
import vion.service.ISparePartService;
import vion.third.DingMod;
import vion.vo.SparePartVO;
import vion.vo.UserVO;
import java.io.File;
import java.io.IOException;
......@@ -38,6 +42,7 @@ import java.util.List;
public class SparePartServiceImpl extends MPJBaseServiceImpl<SparePartMapper, SparePart> implements ISparePartService {
private final IFileService fileService;
private final DingMod dingMod;
private final Converter converter;
@Value("${fileUrl:}")
......@@ -47,7 +52,40 @@ public class SparePartServiceImpl extends MPJBaseServiceImpl<SparePartMapper, Sp
public Object frontSubmit(SparePartDTO dto) {
dto.setUuid(IdUtil.nanoId());
SparePart sparePart = converter.convert(dto, SparePart.class);
if (this.save(sparePart)) {
return this.save(sparePart) ? MapUtil.<String, Long>builder()
.put("id", sparePart.getId())
.build() : "提交失败";
}
@Override
public List<SparePartVO> list(SparePartDTO dto) {
MPJLambdaWrapper<SparePart> wrapper = new MPJLambdaWrapper<>(converter.convert(dto, SparePart.class))
.selectAll(SparePart.class)
.selectAs(Contract::getName, SparePartVO::getContractName)
.selectCollection(RRepairDevice.class, SparePartVO::getRepairDeviceList)
.leftJoin(Contract.class, Contract::getId, SparePart::getContractId)
.leftJoin(RRepairDevice.class, on -> on.eq(RRepairDevice::getRId, SparePart::getId).eq(RRepairDevice::getRType, 1))
.between(SparePart::getCreateTime, dto.getCreateTimeStart(), dto.getCreateTimeEnd())
.between(ArrayUtil.isAllNotNull(dto.getShipDateStart(), dto.getShipDateEnd()), SparePart::getShipDate, dto.getShipDateStart(), dto.getShipDateEnd())
.orderByDesc(SparePart::getCreateTime);
return this.selectJoinList(SparePartVO.class, wrapper);
}
@Override
public SparePartVO getSparePartDetail(Long id, String uuid) {
MPJLambdaWrapper<SparePart> wrapper = new MPJLambdaWrapper<SparePart>()
.selectAll(SparePart.class)
.eq(ObjUtil.isNotEmpty(id), SparePart::getId, id)
.eq(StrUtil.isNotBlank(uuid), SparePart::getUuid, uuid)
.orderByDesc(PointInfo::getCreateTime);
return this.selectJoinOne(SparePartVO.class, wrapper);
}
@Override
public String updById(Long id, SparePartDTO dto) {
if (this.updateById(converter.convert(dto, SparePart.class))) {
UserVO user = (UserVO) StpUtil.getTokenSession().get("curLoginUser");
Opt.ofNullable(dto.getFiles())
.ifPresent(fileList ->
Arrays.stream(fileList).forEach(infile -> {
......@@ -56,7 +94,7 @@ public class SparePartServiceImpl extends MPJBaseServiceImpl<SparePartMapper, Sp
String mainName = FileNameUtil.mainName(orgName);
String fileExt = FileNameUtil.extName(orgName);
String filename = StrUtil.format("{}_{}.{}", mainName, DateUtil.format(new Date(), "yyyyMMdd_HHmmssSSS"), fileExt);
String path = fileUrl + FileUtil.FILE_SEPARATOR + "sparePart" + FileUtil.FILE_SEPARATOR + sparePart.getId() + FileUtil.FILE_SEPARATOR + filename;
String path = fileUrl + FileUtil.FILE_SEPARATOR + "sparePart" + FileUtil.FILE_SEPARATOR + id + FileUtil.FILE_SEPARATOR + filename;
File file = FileUtil.touch(path);
try {
infile.transferTo(file);
......@@ -66,49 +104,45 @@ public class SparePartServiceImpl extends MPJBaseServiceImpl<SparePartMapper, Sp
FileInfo fileInfo = new FileInfo();
fileInfo.setStoreId(-1L);
fileInfo.setSourceId(sparePart.getId());
fileInfo.setSourceId(id);
fileInfo.setSourceType(22);
fileInfo.setName(filename);
fileInfo.setUrl(path);
fileInfo.setType(fileExt);
fileInfo.setSha256(SecureUtil.sha256(file).toUpperCase());
fileInfo.setUploader(sparePart.getContact());
fileInfo.setUploader(user.getUsername());
fileService.save(fileInfo);
}));
return MapUtil.<String, Long>builder()
.put("id", sparePart.getId())
.build();
return "更新成功";
}
return "提交失败";
return "更新失败";
}
@Override
public List<SparePartVO> list(SparePartDTO dto) {
MPJLambdaWrapper<SparePart> wrapper = new MPJLambdaWrapper<>(converter.convert(dto, SparePart.class))
.selectAll(SparePart.class)
.selectAs(Contract::getName, SparePartVO::getContractName)
.selectCollection(RRepairDevice.class, SparePartVO::getRepairDeviceList)
.leftJoin(Contract.class, Contract::getId, SparePart::getContractId)
.leftJoin(RRepairDevice.class, on -> on.eq(RRepairDevice::getRId, SparePart::getId).eq(RRepairDevice::getRType, 1))
.between(SparePart::getCreateTime, dto.getCreateTimeStart(), dto.getCreateTimeEnd())
.between(ArrayUtil.isAllNotNull(dto.getShipDateStart(), dto.getShipDateEnd()), SparePart::getShipDate, dto.getShipDateStart(), dto.getShipDateEnd())
.orderByDesc(SparePart::getCreateTime);
return this.selectJoinList(SparePartVO.class, wrapper);
}
public Boolean notify(Long id, String userid) {
var sparePart = this.getById(id);
@Override
public SparePartVO getSparePartDetail(Long id, String uuid) {
MPJLambdaWrapper<SparePart> wrapper = new MPJLambdaWrapper<SparePart>()
.selectAll(PointInfo.class)
.eq(ObjUtil.isNotEmpty(id), SparePart::getId, id)
.eq(StrUtil.isNotBlank(uuid), SparePart::getUuid, uuid)
.orderByDesc(PointInfo::getCreateTime);
return this.selectJoinOne(SparePartVO.class, wrapper);
}
var jsonObj = JSONUtil.ofObj()
.set("agent_id", 2358374016L)
.set("userid_list", userid);
@Override
public String updById(Long id, SparePartDTO dto) {
return this.updateById(converter.convert(dto, SparePart.class)) ? "更新成功" : "更新失败";
var msg = JSONUtil.ofObj();
var content = JSONUtil.ofObj().set("title", "备件已发货");
String text = StrUtil.format("""
### 备件已发货
### 项目名称:{}
### 快递单号:{}
### 发货日期:{}
### 发送时间:{}
""", sparePart.getProjectName(), Opt.ofBlankAble(sparePart.getTrackingNumber()).orElse("暂无"),
Opt.ofBlankAble(DateUtil.formatDate(sparePart.getShipDate())).orElse("暂无"), DateUtil.now());
content.set("text", text);
msg.set("msgtype", "markdown").set("markdown", content);
jsonObj.set("msg", msg);
var pushRes = dingMod.workMsg(jsonObj);
return StrUtil.containsIgnoreCase(pushRes, "ok");
}
}
......@@ -116,7 +116,7 @@ public class StoreServiceImpl extends MPJBaseServiceImpl<StoreMapper, Store> imp
.map(l -> fileService.lambdaQuery()
.in(FileInfo::getSourceId, l)
.in(FileInfo::getStoreId, l)
.in(FileInfo::getSourceType, 1, 24, 25, 26, 27)
.in(FileInfo::getSourceType, 1, 24, 25, 26, 27, 28)
.list())
.map(fileList -> fileList.stream().collect(Collectors.groupingBy(FileInfo::getStoreId, Collectors.counting())))
.orElse(MapUtil.empty());
......@@ -345,7 +345,7 @@ public class StoreServiceImpl extends MPJBaseServiceImpl<StoreMapper, Store> imp
@Override
public List<StoreVO> storeScreen() {
MPJLambdaWrapper<Store> wrapper = new MPJLambdaWrapper<Store>()
.select(Store::getId, Store::getName, Store::getTaskDetail, Store::getFinishDate, Store::getPercentage, Store::getStuckPoint, Store::getIsImportant)
.select(Store::getId, Store::getName, Store::getTaskDetail, Store::getPlanFinishDate, Store::getPercentage, Store::getStuckPoint, Store::getIsImportant)
.selectCollection(User.class, StoreVO::getUserNameList, map -> map.result(User::getUsername))
.leftJoin(RStoreUser.class, on -> on.eq(RStoreUser::getStoreId, Store::getId).eq(RStoreUser::getIsMain, 1))
.leftJoin(User.class, User::getId, RStoreUser::getUserId)
......@@ -377,9 +377,10 @@ public class StoreServiceImpl extends MPJBaseServiceImpl<StoreMapper, Store> imp
});
// 工单相关合并
taskMapper.update(new Task(), Wrappers.lambdaUpdate(Task.class).set(Task::getStoreId, sourceId).eq(Task::getStoreId, targetId));
taskMapper.update(new Task(), Wrappers.lambdaUpdate(Task.class).set(Task::getStoreId, sourceId).set(Task::getAccountId, store.getAccountId()).eq(Task::getStoreId, targetId));
taskTempService.lambdaUpdate().set(TaskTemp::getStoreId, sourceId).eq(TaskTemp::getStoreId, targetId).update();
fileService.lambdaUpdate().set(FileInfo::getStoreId, sourceId).eq(FileInfo::getStoreId, targetId).eq(FileInfo::getSourceType, 3).update();
// 所有 targetId 的文件 转移到 sourceId
fileService.lambdaUpdate().set(FileInfo::getStoreId, sourceId).eq(FileInfo::getStoreId, targetId).update();
faultLogService.lambdaUpdate().set(FaultLog::getStoreId, sourceId).eq(FaultLog::getStoreId, targetId).update();
formService.lambdaUpdate().set(Form::getStoreId, sourceId).set(Form::getAccountId, store.getAccountId()).eq(Form::getStoreId, targetId).update(new Form());
inspectService.lambdaUpdate().set(Inspect::getStoreId, sourceId).set(Inspect::getAccountId, store.getAccountId()).eq(Inspect::getStoreId, targetId).update(new Inspect());
......@@ -426,7 +427,7 @@ public class StoreServiceImpl extends MPJBaseServiceImpl<StoreMapper, Store> imp
}
@Override
public boolean logNotify(Long id, String[] userIdStr) {
public Boolean logNotify(Long id, String[] userIdStr) {
MPJLambdaWrapper<Store> wrapper = new MPJLambdaWrapper<Store>()
.select(Store::getName, Store::getBotToken)
.selectCollection(StoreLog.class, StoreVO::getStoreLog)
......@@ -474,7 +475,6 @@ public class StoreServiceImpl extends MPJBaseServiceImpl<StoreMapper, Store> imp
.set("msgtype", "markdown")
.set("markdown", markdown)
.setOpt("at", atObj);
System.out.println(body);
var pushRes = dingMod.robotPush(storeVO.getBotToken(), body.toString());
return StrUtil.containsIgnoreCase(pushRes, "ok");
}
......@@ -531,7 +531,7 @@ public class StoreServiceImpl extends MPJBaseServiceImpl<StoreMapper, Store> imp
@Override
public Map<Integer, Long> statState() {
var storeList = this.lambdaQuery().eq(Store::getProjectState, 1).list();
var storeList = this.lambdaQuery().eq(Store::getProjectState, 2).list();
return storeList.stream().collect(Collectors.groupingBy(Store::getProjectStage, Collectors.counting()));
}
......
......@@ -431,12 +431,12 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
}
@Override
public List<Map<String, Object>> peopleAnalysis(Date startDate, Date endDate, Integer source, Long userId) {
public List<Map<String, Object>> peopleAnalysis(Date startDate, Date endDate, Integer source, Long[] userIds) {
List<Task> taskList = this.lambdaQuery()
.between(ArrayUtil.isAllNotNull(startDate, endDate), Task::getRepairTime, startDate, endDate)
.isNotNull(ObjUtil.equals(source, 1), Task::getTaskTempId)
.isNull(ObjUtil.equals(source, 2), Task::getTaskTempId)
.eq(ObjUtil.isNotNull(userId), Task::getActiveUser, userId)
.in(ArrayUtil.isNotEmpty(userIds), Task::getActiveUser, userIds)
.list();
List<Store> storeList = storeService.list();
Map<Long, String> id2UsernameMap = userService.list().stream().collect(Collectors.toMap(User::getId, User::getUsername));
......@@ -469,11 +469,12 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
}
@Override
public List<Map<String, Object>> proAnalysis(Date startDate, Date endDate, Integer source) {
public List<Map<String, Object>> proAnalysis(Date startDate, Date endDate, Integer source, Long[] userIds) {
List<Task> taskList = this.lambdaQuery()
.between(ArrayUtil.isAllNotNull(startDate, endDate), Task::getRepairTime, startDate, endDate)
.isNotNull(ObjUtil.equals(source, 1), Task::getTaskTempId)
.isNull(ObjUtil.equals(source, 2), Task::getTaskTempId)
.in(ArrayUtil.isNotEmpty(userIds), Task::getActiveUser, userIds)
.list();
List<Store> storeList = storeService.list();
Map<Long, String> id2UsernameMap = userService.list().stream().collect(Collectors.toMap(User::getId, User::getUsername));
......
......@@ -241,10 +241,13 @@ public class DingMod {
UserVO userVO = converter.convert(user, UserVO.class);
// 禁用用户或离职用户禁止登录系统
if (userVO.getStatus() == 1 || userVO.getEmployeeStatus() == 5) {
return "该用户禁止登录系统,请联系管理员!";
return "用户已禁用禁止登录系统,请联系管理员!";
}
Long id = userVO.getId();
setRolesAndPerms(id, userVO);
if (CollUtil.isEmpty(userVO.getRoleVOList())) {
return "用户未分配角色,请联系管理员!";
}
StpUtil.login(id);
String token = StpUtil.getTokenValue();
......@@ -273,6 +276,9 @@ public class DingMod {
Long id = userVO.getId();
setRolesAndPerms(id, userVO);
if (CollUtil.isEmpty(userVO.getRoleVOList())) {
return "用户未分配角色,请联系管理员!";
}
StpUtil.login(id);
String token = StpUtil.getTokenValue();
......@@ -301,6 +307,50 @@ public class DingMod {
return "钉钉回调异常,请联系相关人员";
}
/**
* 钉钉工作台应用获取应用程序token
*
* @param authCode 授权码
* @return java.lang.Object
*/
public Object getPlatformToken(String authCode) {
var accessTokenStr = HttpUtil.get(StrUtil.format("https://oapi.dingtalk.com/gettoken?appkey={}&appsecret={}",
appKey, appSecret));
if (!StrUtil.contains(accessTokenStr, "access_token")) {
log.error("获取钉钉access_token失败:{}", accessTokenStr);
return "获取钉钉access_token失败";
}
var accessToken = JSONUtil.parseObj(accessTokenStr).getStr("access_token");
var userInfoStr = HttpUtil.post("https://oapi.dingtalk.com/topapi/v2/user/getuserinfo?access_token=" + accessToken,
JSONUtil.ofObj().set("code", authCode));
if (!StrUtil.contains(userInfoStr, "\"errmsg\":\"ok\"")) {
log.error("获取钉钉用户信息失败:{}", userInfoStr);
return "获取钉钉用户信息失败";
}
var userid = JSONUtil.parseObj(userInfoStr).getJSONObject("result").getStr("userid");
User user = userService.lambdaQuery()
.select(User::getId, User::getUserid, User::getUsername, User::getPhone, User::getStatus, User::getEmployeeStatus)
.eq(User::getUserid, userid).one();
UserVO userVO = converter.convert(user, UserVO.class);
// 禁用用户或离职用户禁止登录系统
if (userVO.getStatus() == 1 || userVO.getEmployeeStatus() == 5) {
return "用户已禁用禁止登录系统,请联系管理员!";
}
Long id = userVO.getId();
setRolesAndPerms(id, userVO);
if (CollUtil.isEmpty(userVO.getRoleVOList())) {
return "用户未分配角色,请联系管理员!";
}
StpUtil.login(id);
String token = StpUtil.getTokenValue();
userVO.setToken(token);
StpUtil.getTokenSession().set("curLoginUser", userVO);
return userVO;
}
private void setRolesAndPerms(Long id, UserVO userVO) {
List<RUserRole> userRoleList = userRoleService.lambdaQuery().eq(RUserRole::getUserId, id).list();
List<RRoleResource> roleResourceList = Opt.ofEmptyAble(userRoleList)
......
package vion.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import java.util.Date;
@Getter
@Setter
public class DeliverLogVO {
private Long id;
/**
* 集团id
*/
private Long accountId;
/**
* 项目id
*/
private Long storeId;
private String storeName;
/**
* 合同编号
*/
private String contractNo;
private String contractSaleName;
/**
* 日志人
*/
private Long userId;
private String userName;
/**
* 日志日期
*/
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date logDate;
/**
* 干系人
*/
private Long confederateId;
private String confederateName;
/**
* 服务方式
*/
private Integer serviceType;
/**
* 耗时
*/
private Double logHour;
/**
* 工作内容
*/
private String content;
/**
* 创建时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
/**
* 修改时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;
}
\ No newline at end of file
......@@ -51,4 +51,5 @@ public class InspectVO {
private String accountName;
private String storeName;
private List<FormVO> formList;
private Integer fileCount;
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!