Commit 24dc594b by HlQ

[add]

1.添加合同项目互相绑定和解绑接口
2.添加项目日志相关接口
3.添加批量导入任务和任务导出接口
4.用户列表接口添加 userid 字段
[fix] 结算差异联调以及 bug 修改
1 parent 0bb04771
......@@ -2,8 +2,6 @@ package vion.controller;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.lang.Opt;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjUtil;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
......@@ -20,7 +18,7 @@ import vion.service.IRContractStoreService;
import vion.vo.ContractVO;
import java.util.List;
import java.util.stream.Collectors;
import java.util.Map;
/**
* 合同管理
......@@ -63,44 +61,26 @@ public class ContractController {
public String updateById(@PathVariable Long id, ContractDTO dto) {
return contractService.updateById(id, null, dto);
}
@PostMapping("/contract/store")
@SaCheckPermission(value = "contract:store:edit", orRole = "admin")
public String saveOrUpdateRContractStore(@RequestBody RContractStoreDTO dto) {
Assert.isFalse(ArrayUtil.isAllNotNull(dto.getStoreId(), dto.getContractId()), "合同id和项目id不能同时传值");
if (ObjUtil.isNotNull(dto.getContractId())) {
contractStoreService.lambdaUpdate()
.eq(RContractStore::getContractId, dto.getContractId())
.remove();
Opt.ofEmptyAble(dto.getStoreIds())
.ifPresent(storeIds -> {
List<RContractStore> contractStoreList = storeIds.stream()
.map(storeId -> {
RContractStore contractStore = new RContractStore();
contractStore.setContractId(dto.getContractId());
contractStore.setStoreId(storeId);
return contractStore;
}).collect(Collectors.toList());
contractStoreService.saveBatch(contractStoreList);
});
}
if (ObjUtil.isNotNull(dto.getStoreId())) {
contractStoreService.lambdaUpdate()
.eq(RContractStore::getStoreId, dto.getStoreId())
.remove();
Opt.ofEmptyAble(dto.getContractIds())
.ifPresent(contractIds -> {
List<RContractStore> contractStoreList = contractIds.stream()
.map(contractId -> {
RContractStore contractStore = new RContractStore();
contractStore.setContractId(contractId);
contractStore.setStoreId(dto.getStoreId());
return contractStore;
}).collect(Collectors.toList());
contractStoreService.saveBatch(contractStoreList);
});
}
return "成功";
@SaCheckPermission(value = "contract:store:save", orRole = "admin")
public String bindStore(@RequestBody RContractStoreDTO dto) {
Assert.notNull(dto.getContractId(), "合同id不能为空");
Assert.notNull(dto.getStoreId(), "项目id不能为空");
RContractStore contractStore = new RContractStore();
contractStore.setContractId(dto.getContractId());
contractStore.setStoreId(dto.getStoreId());
return contractStoreService.save(contractStore) ? "绑定成功" : "绑定失败";
}
@DeleteMapping("/contract/store")
@SaCheckPermission(value = "contract:store:remove", orRole = "admin")
public String unbindStore(@RequestBody RContractStoreDTO dto) {
Assert.notNull(dto.getContractId(), "合同id不能为空");
Assert.notNull(dto.getStoreId(), "项目id不能为空");
return contractStoreService.lambdaUpdate()
.eq(RContractStore::getContractId, dto.getContractId())
.eq(RContractStore::getStoreId, dto.getStoreId())
.remove() ? "解绑成功" : "解绑失败";
}
@GetMapping("/contract/store")
......@@ -120,34 +100,30 @@ public class ContractController {
@GetMapping("/contract/analyze")
@SaCheckPermission(value = "contract:analyze", orRole = "admin")
public Object analyze(ContractDTO dto) {
public Map<String, Object> analyze(ContractDTO dto) {
return contractService.analyze(dto);
}
@PostMapping("/contract/dispatch")
@SaCheckPermission(value = "contract:dispatch", orRole = "admin")
// todo 未分配权限
public String dispatch(@RequestBody RContractTeamDTO dto) {
return contractService.dispatch(dto);
}
@GetMapping("/contract/sale")
@SaCheckPermission(value = "contract:sale:list", orRole = "admin")
// todo 未分配权限
public Page<RContractUser> getSaleList(RContractUser dto) {
return contractService.getSaleList(dto);
}
@PostMapping("/contract/assignSale")
@SaCheckPermission(value = "contract:assignSale", orRole = "admin")
// todo 未分配权限
public String assignSale(@RequestBody RContractUser dto) {
return contractService.assignSale(dto);
}
@PostMapping("/contract/unbindSale")
@SaCheckPermission(value = "contract:unbindSale", orRole = "admin")
// todo 未分配权限
public String unbindSale(@RequestBody RContractUser dto) {
return contractService.unbindSale(dto);
}
......@@ -155,6 +131,7 @@ public class ContractController {
@PostMapping("/contractSync")
@SaCheckPermission(value = "contract:sync", orRole = "admin")
public String manualSyncContract() {
return contractRunner.contractSync() ? "成功" : "失败";
contractRunner.contractSync();
return "成功";
}
}
package vion.controller;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.core.lang.Opt;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import vion.dto.SettlementDiffDTO;
import vion.model.FileInfo;
import vion.service.IFileService;
import vion.service.ISettlementDiffService;
import vion.vo.SettlementDiffVO;
......@@ -19,9 +16,8 @@ import vion.vo.SettlementDiffVO;
public class SettlementDiffController {
private final ISettlementDiffService settlementDiffService;
private final IFileService fileService;
@GetMapping("/settlementDiff/{no}")
@GetMapping("/settlementDiff/list/{no}")
@SaCheckPermission(value = "settlementDiff:list", orRole = "admin")
public Page<SettlementDiffVO> list(@PathVariable String no, SettlementDiffDTO dto) {
return settlementDiffService.list(no, dto);
......@@ -34,13 +30,13 @@ public class SettlementDiffController {
@PostMapping("/settlementDiff")
@SaCheckPermission(value = "settlementDiff:save", orRole = "admin")
public String save(@RequestBody SettlementDiffDTO dto) {
public String save(SettlementDiffDTO dto) {
return settlementDiffService.save(dto);
}
@PostMapping("/settlementDiff/{id}")
@SaCheckPermission(value = "settlementDiff:edit", orRole = "admin")
public String update(@PathVariable Long id, @RequestBody SettlementDiffDTO dto) {
public String update(@PathVariable Long id, SettlementDiffDTO dto) {
dto.setId(id);
return settlementDiffService.update(id, dto);
}
......@@ -49,12 +45,7 @@ public class SettlementDiffController {
@SaCheckPermission(value = "settlementDiff:remove", orRole = "admin")
@Transactional(rollbackFor = Exception.class)
public String delById(@PathVariable Long id) {
Opt.ofEmptyAble(fileService.lambdaQuery()
.eq(FileInfo::getSourceId, id)
.eq(FileInfo::getType, 15)
.list())
.ifPresent(fileService::removeBatchByIds);
return settlementDiffService.removeById(id) ? "删除成功" : "删除失败";
return settlementDiffService.delById(id);
}
}
......@@ -92,12 +92,11 @@ public class StoreController {
@GetMapping("/store/manualCal")
@SaCheckPermission(value = "store:calMaintainStatus", orRole = "admin")
// todo 权限未加,前端未调用该接口
// todo 权限未加,前端未使用到该接口
public String manualCalMaintainStatus() {
return storeService.calMaintainStatus();
}
/*----------------------- todo 以下权限未加 ----------------------*/
@GetMapping("/store/user/{storeId}")
@SaCheckPermission(value = "store:user:list", orRole = "admin")
public List<RStoreUser> getUserList(@PathVariable Long storeId) {
......@@ -115,8 +114,10 @@ public class StoreController {
@GetMapping("/store/log/{storeId}")
@SaCheckPermission(value = "store:log:list", orRole = "admin")
public List<StoreLog> getLogList(@PathVariable Long storeId) {
return storeLogService.lambdaQuery().eq(StoreLog::getStoreId, storeId).list();
public Page<StoreLog> getLogList(@PathVariable Long storeId, StoreLog storeLog) {
storeLog.setStoreId(storeId);
return storeLogService.lambdaQuery(storeLog)
.page(Page.of(storeLog.getPageNum(), storeLog.getPageSize()));
}
@PostMapping("/store/log")
......@@ -125,6 +126,19 @@ public class StoreController {
return storeLogService.save(storeLog) ? "新增成功" : "新增失败";
}
@DeleteMapping("/store/log/{logId}")
@SaCheckPermission(value = "store:log:delete", orRole = "admin")
public String delLog(@PathVariable Long logId) {
return storeLogService.removeById(logId) ? "删除成功" : "删除失败";
}
@PostMapping("/store/log/{logId}")
@SaCheckPermission(value = "store:log:edit", orRole = "admin")
public String updateLog(@PathVariable Long logId, @RequestBody StoreLog storeLog) {
storeLog.setId(logId);
return storeLogService.updateById(storeLog) ? "更新成功" : "更新失败";
}
@GetMapping("/store/screen")
@SaCheckPermission(value = "store:screen", orRole = "admin")
public List<StoreVO> storeScreen() {
......
......@@ -76,14 +76,12 @@ public class TaskController {
@PostMapping("/task/batchIns")
@SaCheckPermission(value = "task:batchIns", orRole = "admin")
// todo 未加权限
public String batchIns(@RequestBody List<TaskDTO> data) {
return taskService.batchIns(data);
}
@GetMapping("/task/export")
@SaCheckPermission(value = "task:export", orRole = "admin")
// todo 未加权限
public void defaultBuild(TaskDTO data, HttpServletResponse response) {
UserVO user = (UserVO) StpUtil.getTokenSession().get("curLoginUser");
data.setPageSize(9999);
......
......@@ -56,7 +56,7 @@ public class UserController {
@GetMapping("/user/onlyName")
@SaCheckPermission(value = "user:listName", orRole = "admin")
public List<UserVO> getNameList(UserDTO dto) {
return converter.convert(userService.list(Wrappers.lambdaQuery(converter.convert(dto, new User())).select(User::getId, User::getUsername, User::getPreWorkOrder)), UserVO.class);
return converter.convert(userService.list(Wrappers.lambdaQuery(converter.convert(dto, new User())).select(User::getId, User::getUserid, User::getUsername, User::getPreWorkOrder)), UserVO.class);
}
@GetMapping("/user")
......
......@@ -38,7 +38,7 @@ public class ContractRunner {
private final RedisTemplate redisTemplate;
@Scheduled(cron = "0 0 * * * *")
public Boolean contractSync() {
public void contractSync() {
log.info("【开始】从crm系统同步合同信息");
Map<String, Contract> no2ContactMap = contractService.list().stream().collect(Collectors.toMap(Contract::getContractNo, Function.identity()));
Map<String, Integer> contractTypeMap = dictionaryService.lambdaQuery().eq(Dictionary::getType, "contract_type").list()
......@@ -105,17 +105,19 @@ public class ContractRunner {
}
} catch (SQLException e) {
log.error("合同信息同步失败:", e);
return false;
return;
}
if (CollUtil.isEmpty(insOrUpdContractList)) {
log.info("没有需要插入或更新的合同");
return true;
return;
}
insOrUpdContractList.forEach(v -> {
if (no2ContactMap.containsKey(v.getContractNo())) {
v.setId(no2ContactMap.get(v.getContractNo()).getId());
// 已有合同不更新状态
v.setStatus(null);
}
});
contractService.saveOrUpdateBatch(insOrUpdContractList, 500);
......@@ -213,7 +215,6 @@ public class ContractRunner {
log.info("【结束】从crm系统同步合同信息");
redisTemplate.opsForValue().set("contract:sync:time", DateUtil.formatDateTime(insOrUpdContractList.get(0).getOriginalModTime()));
return true;
}
@Scheduled(cron = "0 0 1 * * ?")
......
package vion.dto;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.Setter;
......@@ -10,6 +11,8 @@ import lombok.Setter;
@Getter
@Setter
public class BaseDTO {
private Integer pageNum = 1;
private Integer pageSize = 10;
@JsonIgnore
private transient Integer pageNum = 1;
@JsonIgnore
private transient Integer pageSize = 10;
}
package vion.model;
import com.baomidou.mybatisplus.annotation.*;
import io.github.linpeilie.annotations.AutoMapper;
import io.github.linpeilie.annotations.AutoMappers;
import io.github.linpeilie.annotations.*;
import lombok.Data;
import vion.dto.ContractDTO;
import vion.vo.ContractVO;
......@@ -70,12 +69,14 @@ public class Contract {
* 合同总金额
*/
@TableField(value = "total_amount")
@ReverseAutoMapping(targetClass = ContractDTO.class, ignore = true)
private BigDecimal totalAmount;
/**
* 合同已收金额
*/
@TableField(value = "paid_amount")
@ReverseAutoMapping(targetClass = ContractDTO.class, ignore = true)
private BigDecimal paidAmount;
/**
......@@ -83,12 +84,14 @@ public class Contract {
* 根据【合同进度】,由系统判断出应该收到的金额
*/
@TableField(value = "receivable_amount")
@ReverseAutoMapping(targetClass = ContractDTO.class, ignore = true)
private BigDecimal receivableAmount;
/**
* 合同未收金额:total-paid
*/
@TableField(value = "outstanding_amount")
@ReverseAutoMapping(targetClass = ContractDTO.class, ignore = true)
private BigDecimal outstandingAmount;
/**
......
......@@ -33,7 +33,7 @@ public class RContractUser extends BaseDTO {
* 用户id,用钉钉的userid
*/
@TableField(value = "user_id")
private Integer userId;
private String userId;
/**
* 用户名
......
......@@ -3,6 +3,8 @@ package vion.model;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import vion.dto.BaseDTO;
import java.util.Date;
......@@ -11,7 +13,7 @@ import java.util.Date;
*/
@Data
@TableName(value = "tbl_store_log")
public class StoreLog {
public class StoreLog extends BaseDTO {
@TableId(value = "id", type = IdType.AUTO)
private Long id;
......@@ -25,6 +27,7 @@ public class StoreLog {
* 日志日期
*/
@TableField(value = "log_date")
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date logDate;
......
......@@ -11,6 +11,8 @@ import vion.model.Contract;
import vion.model.RContractUser;
import vion.vo.ContractVO;
import java.util.Map;
/**
* @author HlQ
* @date 2023/11/29
......@@ -29,7 +31,7 @@ public interface IContractService extends MPJBaseService<Contract>{
JSONObject calAmount(ContractDTO dto);
Object analyze(ContractDTO dto);
Map<String, Object> analyze(ContractDTO dto);
String dispatch(@RequestBody RContractTeamDTO dto);
......
......@@ -2,6 +2,7 @@ package vion.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.base.MPJBaseService;
import org.springframework.web.bind.annotation.PathVariable;
import vion.dto.SettlementDiffDTO;
import vion.model.SettlementDiff;
import vion.vo.SettlementDiffVO;
......@@ -20,4 +21,6 @@ public interface ISettlementDiffService extends MPJBaseService<SettlementDiff> {
String update(Long id, SettlementDiffDTO dto);
String delById(@PathVariable Long id);
}
......@@ -53,7 +53,7 @@ public class ContractPaymentServiceImpl extends MPJBaseServiceImpl<ContractPayme
BigDecimal curAmount = NumberUtil.mul(totalAmount, sumRatio);
BigDecimal paidAmount = ObjUtil.isNull(dto.getPaidAmount()) ? existContract.getPaidAmount() : dto.getPaidAmount();
BigDecimal recAmount = NumberUtil.add(NumberUtil.sub(curAmount, paidAmount), diffAmount2);
BigDecimal outsideAmount = NumberUtil.add(NumberUtil.sub(totalAmount, paidAmount), NumberUtil.add(diffAmount1, diffAmount2));
BigDecimal outsideAmount = NumberUtil.sub(totalAmount, paidAmount);
dto.setReceivableAmount(recAmount);
dto.setOutstandingAmount(outsideAmount);
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!