Commit b3cd91f9 by HlQ

[add]

1.添加施工管理
2.添加重点项目看板功能
3.添加合同关联多个销售功能
1 parent 162bb820
Showing 66 changed files with 1672 additions and 98 deletions
package vion.controller;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import vion.dto.ConstructionTeamDTO;
import vion.dto.RContractTeamDTO;
import vion.service.IConstructionTeamService;
import vion.vo.ConstructionTeamVO;
import vion.vo.RContractTeamVO;
/**
* 施工队管理
*/
@RestController
@RequestMapping("/api")
@RequiredArgsConstructor
public class ConstructionTeamController {
private final IConstructionTeamService constructionTeamService;
@GetMapping("/constructionTeam")
@SaCheckPermission(value = "constructionTeam:list", orRole = "admin")
public Page<ConstructionTeamVO> list(ConstructionTeamDTO dto) {
return constructionTeamService.list(dto);
}
@GetMapping("/constructionTeam/{id}")
@SaCheckPermission(value = "constructionTeam:query", orRole = "admin")
public ConstructionTeamVO getVOById(@PathVariable Long id) {
return constructionTeamService.getVOById(id);
}
@PostMapping("/constructionTeam")
@SaCheckPermission(value = "constructionTeam:save", orRole = "admin")
public Object save(@RequestBody ConstructionTeamDTO dto) {
return constructionTeamService.save(dto);
}
@PostMapping("/constructionTeam/{id}")
@SaCheckPermission(value = "constructionTeam:edit", orRole = "admin")
public String update(@PathVariable Long id, @RequestBody ConstructionTeamDTO dto) {
dto.setId(id);
return constructionTeamService.updateById(dto);
}
@DeleteMapping("/constructionTeam/{id}")
@SaCheckPermission(value = "constructionTeam:remove", orRole = "admin")
public String delById(@PathVariable Long id) {
return constructionTeamService.removeById(id) ? "删除成功" : "删除失败";
}
@GetMapping("/contractTeam")
@SaCheckPermission(value = "contract:team:list", orRole = "admin")
public Page<RContractTeamVO> list(RContractTeamDTO dto) {
return constructionTeamService.list(dto);
}
@PostMapping("/contractTeam/{id}")
@SaCheckPermission(value = "contract:team:assign", orRole = "admin")
public String assignTeam(@PathVariable Long id, @RequestBody RContractTeamDTO dto) {
dto.setId(id);
return constructionTeamService.assignTeam(dto);
}
@DeleteMapping("/contractTeam/{id}")
@SaCheckPermission(value = "contract:team:remove", orRole = "admin")
public String delContractTeamById(@PathVariable Long id) {
return constructionTeamService.delContractTeamById(id);
}
}
......@@ -12,7 +12,9 @@ import org.springframework.web.bind.annotation.*;
import vion.cron.ContractRunner;
import vion.dto.ContractDTO;
import vion.dto.RContractStoreDTO;
import vion.dto.RContractTeamDTO;
import vion.model.RContractStore;
import vion.model.RContractUser;
import vion.service.IContractService;
import vion.service.IRContractStoreService;
import vion.vo.ContractVO;
......@@ -29,8 +31,8 @@ import java.util.stream.Collectors;
public class ContractController {
private final IContractService contractService;
private final ContractRunner contractRunner;
private final IRContractStoreService contractStoreService;
private final ContractRunner contractRunner;
@GetMapping("/contract")
@SaCheckPermission(value = "contract:list", orRole = "admin")
......@@ -122,6 +124,27 @@ public class ContractController {
return contractService.analyze(dto);
}
@PostMapping("/contract/dispatch")
@SaCheckPermission(value = "contract:dispatch", orRole = "admin")
// todo 未分配权限
public String dispatch(@RequestBody RContractTeamDTO dto) {
return contractService.dispatch(dto);
}
@PostMapping("/contract/assignSale")
@SaCheckPermission(value = "contract:assignSale", orRole = "admin")
// todo 未分配权限
public String assignSale(@RequestBody RContractUser dto) {
return contractService.assignSale(dto);
}
@DeleteMapping("/contract/unbindSale/{id}")
@SaCheckPermission(value = "contract:unbindSale", orRole = "admin")
// todo 未分配权限
public String unbindSale(@PathVariable Long id) {
return contractService.unbindSale(id);
}
@PostMapping("/contractSync")
@SaCheckPermission(value = "contract:sync", orRole = "admin")
public String manualSyncContract() {
......
......@@ -29,7 +29,7 @@ public class DeliveryRecordController {
@GetMapping("/deliveryRecord/{id}")
@SaCheckPermission(value = "deliveryRecord:query", orRole = "admin")
public DeliveryRecordVO getById(@PathVariable Long id) {
return converter.convert(deliveryRecordService.getById(id), new DeliveryRecordVO());
return converter.convert(deliveryRecordService.getById(id), DeliveryRecordVO.class);
}
@PostMapping("/deliveryRecord")
......
......@@ -26,7 +26,7 @@ public class DictionaryController {
@GetMapping("/dictionarys")
@SaCheckPermission(value = "dict:list", orRole = "admin")
public Page<Dictionary> getDictionaryList(DictionaryDTO data) {
return dictionaryService.lambdaQuery(converter.convert(data, new Dictionary()))
return dictionaryService.lambdaQuery(converter.convert(data, Dictionary.class))
.page(Page.of(data.getPageNum(), data.getPageSize()));
}
......@@ -39,14 +39,14 @@ public class DictionaryController {
@PostMapping("/dictionary")
@SaCheckPermission(value = "dict:editAndSave", orRole = "admin")
public String saveOrUpdateDictionary(@RequestBody DictionaryDTO data) {
Dictionary dictionary = converter.convert(data, new Dictionary());
Dictionary dictionary = converter.convert(data, Dictionary.class);
return dictionaryService.saveOrUpdate(dictionary) ? "成功" : "失败";
}
@GetMapping("/dictionaryTypes")
@SaCheckPermission(value = "dict:type:list", orRole = "admin")
public Page<DictionaryType> getDictionaryTypeList(DictionaryTypeDTO data) {
return dictionaryTypeService.lambdaQuery(converter.convert(data, new DictionaryType()))
return dictionaryTypeService.lambdaQuery(converter.convert(data, DictionaryType.class))
.page(Page.of(data.getPageNum(), data.getPageSize()));
}
......@@ -59,7 +59,7 @@ public class DictionaryController {
@PostMapping("/dictionaryType")
@SaCheckPermission(value = "dict:type:editAndSave", orRole = "admin")
public String saveOrUpdateDictionaryType(@RequestBody DictionaryTypeDTO data) {
DictionaryType dictionaryType = converter.convert(data, new DictionaryType());
DictionaryType dictionaryType = converter.convert(data, DictionaryType.class);
return dictionaryTypeService.saveOrUpdate(dictionaryType) ? "成功" : "失败";
}
}
......@@ -37,7 +37,7 @@ public class InspectController {
@PostMapping("/inspects")
@SaCheckPermission(value = "inspect:editAndSave", orRole = "admin")
public String saveOrUpdate(@RequestBody InspectDTO data) {
Inspect inspect = converter.convert(data, new Inspect());
Inspect inspect = converter.convert(data, Inspect.class);
return inspectService.saveOrUpdate(inspect) ? "成功" : "失败";
}
......
......@@ -31,7 +31,7 @@ public class InvoiceController {
@GetMapping("/invoice/{id}")
@SaCheckPermission(value = "invoice:query", orRole = "admin")
public InvoiceVO getById(@PathVariable Long id) {
return converter.convert(invoiceService.getById(id), new InvoiceVO());
return converter.convert(invoiceService.getById(id), InvoiceVO.class);
}
@PostMapping("/invoice")
......
......@@ -31,7 +31,7 @@ public class PaymentController {
@GetMapping("/payment/{id}")
@SaCheckPermission(value = "payment:query", orRole = "admin")
public PaymentVO getById(@PathVariable Long id) {
return converter.convert(paymentService.getById(id), new PaymentVO());
return converter.convert(paymentService.getById(id), PaymentVO.class);
}
@PostMapping("/payment")
......
......@@ -41,20 +41,20 @@ public class ResourceController {
@SaCheckPermission(value = "resource:query", orRole = "admin")
public ResourceVO getRoleById(@PathVariable Long id) {
Resource resource = resourceService.getById(id);
return converter.convert(resource, new ResourceVO());
return converter.convert(resource, ResourceVO.class);
}
@PostMapping("/resource")
@SaCheckPermission(value = "resource:save", orRole = "admin")
private String save(@RequestBody ResourceDTO dto) {
Resource resource = converter.convert(dto, new Resource());
Resource resource = converter.convert(dto, Resource.class);
return resourceService.save(resource) ? "创建成功" : "创建失败";
}
@PostMapping("/resource/{id}")
@SaCheckPermission(value = "resource:edit", orRole = "admin")
private String update(@PathVariable Long id, @RequestBody RoleDTO dto) {
Resource resource = converter.convert(dto, new Resource());
Resource resource = converter.convert(dto, Resource.class);
resource.setId(id);
return resourceService.updateById(resource) ? "更新成功" : "更新失败";
}
......
......@@ -44,7 +44,7 @@ public class RoleController {
@SaCheckPermission(value = "role:query", orRole = "admin")
public RoleVO getRoleById(@PathVariable Long id) {
Role role = roleService.getById(id);
return converter.convert(role, new RoleVO());
return converter.convert(role, RoleVO.class);
}
@PostMapping("/role")
......@@ -53,7 +53,7 @@ public class RoleController {
if (StrUtil.equals(dto.getCode(), "admin")) {
return "管理员角色编码[admin]已存在,不允许再次创建";
}
Role role = converter.convert(dto, new Role());
Role role = converter.convert(dto, Role.class);
return roleService.save(role) ? "创建成功" : "创建失败";
}
......@@ -63,7 +63,7 @@ public class RoleController {
if (id == 1) {
return "管理员角色不允许修改";
}
Role role = converter.convert(dto, new Role());
Role role = converter.convert(dto, Role.class);
role.setId(id);
return roleService.updateById(role) ? "更新成功" : "更新失败";
}
......
......@@ -51,7 +51,7 @@ public class ServiceOrderController {
private Object save(@RequestBody ServiceOrderDTO serviceOrderDTO) {
Long count = serviceOrderService.lambdaQuery().eq(ServiceOrder::getTaskId, serviceOrderDTO.getTaskId()).count();
Assert.isFalse(count > 0, "该工单已存在服务单,不能重复创建!");
ServiceOrder serviceOrder = converter.convert(serviceOrderDTO, new ServiceOrder());
ServiceOrder serviceOrder = converter.convert(serviceOrderDTO, ServiceOrder.class);
serviceOrder.setUnid(IdUtil.nanoId());
return serviceOrderService.save(serviceOrder) ? serviceOrder.getId() : "创建失败";
}
......@@ -59,7 +59,7 @@ public class ServiceOrderController {
@PostMapping("/order/{id}")
@SaCheckPermission(value = "order:edit", orRole = "admin")
private String update(@PathVariable Long id, @RequestBody ServiceOrderDTO serviceOrderDTO) {
ServiceOrder serviceOrder = converter.convert(serviceOrderDTO, new ServiceOrder());
ServiceOrder serviceOrder = converter.convert(serviceOrderDTO, ServiceOrder.class);
serviceOrder.setId(id);
return serviceOrderService.updateById(serviceOrder) ? "更新成功" : "更新失败";
}
......@@ -76,7 +76,7 @@ public class ServiceOrderController {
List<Dictionary> dictionaryList = dictionaryService.lambdaQuery().eq(Dictionary::getType, "service_type").list();
Map<Integer, String> serviceTypeMap = dictionaryList.stream().collect(Collectors.toMap(Dictionary::getKey, Dictionary::getValue));
ServiceOrder order = serviceOrderService.lambdaQuery().eq(ServiceOrder::getUnid, unid).one();
ServiceOrderVO vo = converter.convert(order, new ServiceOrderVO());
ServiceOrderVO vo = converter.convert(order, ServiceOrderVO.class);
vo.setServiceType(serviceTypeMap.get(order.getServiceType()));
return vo;
}
......@@ -90,7 +90,7 @@ public class ServiceOrderController {
*/
@PostMapping("/order/sign/{unid}")
public String updateByUnid(@PathVariable String unid, @RequestBody ServiceOrderDTO serviceOrderDTO) {
ServiceOrder serviceOrder = converter.convert(serviceOrderDTO, new ServiceOrder());
ServiceOrder serviceOrder = converter.convert(serviceOrderDTO, ServiceOrder.class);
return serviceOrderService.lambdaUpdate().eq(ServiceOrder::getUnid, unid).update(serviceOrder) ? "提交成功" : "提交失败";
}
......
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;
@RestController
@RequestMapping("/api")
@RequiredArgsConstructor
public class SettlementDiffController {
private final ISettlementDiffService settlementDiffService;
private final IFileService fileService;
@GetMapping("/settlementDiff/{no}")
@SaCheckPermission(value = "settlementDiff:list", orRole = "admin")
public Page<SettlementDiffVO> list(@PathVariable String no, SettlementDiffDTO dto) {
return settlementDiffService.list(no, dto);
}
@GetMapping("/settlementDiff/{id}")
public SettlementDiffVO getVOById(@PathVariable Long id) {
return settlementDiffService.getVOById(id);
}
@PostMapping("/settlementDiff")
@SaCheckPermission(value = "settlementDiff:save", orRole = "admin")
public String save(@RequestBody SettlementDiffDTO dto) {
return settlementDiffService.save(dto);
}
@PostMapping("/settlementDiff/{id}")
@SaCheckPermission(value = "settlementDiff:edit", orRole = "admin")
public String update(@PathVariable Long id, @RequestBody SettlementDiffDTO dto) {
dto.setId(id);
return settlementDiffService.update(id, dto);
}
@DeleteMapping("/settlementDiff/{id}")
@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) ? "删除成功" : "删除失败";
}
}
......@@ -2,6 +2,7 @@ package vion.controller;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.lang.Opt;
import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
......@@ -11,11 +12,16 @@ import lombok.extern.slf4j.Slf4j;
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.service.IRStoreUserService;
import vion.service.IStoreLogService;
import vion.service.IStoreService;
import vion.vo.StoreVO;
import vion.vo.UserVO;
import java.util.Arrays;
import java.util.List;
@RestController
......@@ -25,6 +31,8 @@ import java.util.List;
public class StoreController {
private final IStoreService storeService;
private final IRStoreUserService storeUserService;
private final IStoreLogService storeLogService;
private final Converter converter;
......@@ -77,7 +85,7 @@ public class StoreController {
@PostMapping("/store/bindContract")
@SaCheckPermission(value = "store:bindContract", orRole = "admin")
public String setMasterContract(@RequestBody StoreDTO dto) {
return storeService.updateById(converter.convert(dto, new Store())) ? "绑定主合同成功" : "绑定主合同失败";
return storeService.updateById(converter.convert(dto, Store.class)) ? "绑定主合同成功" : "绑定主合同失败";
}
@GetMapping("/store/manualCal")
......@@ -86,4 +94,39 @@ public class StoreController {
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) {
return storeUserService.lambdaQuery().eq(RStoreUser::getStoreId, storeId).list();
}
@PostMapping("/store/assignUser")
@SaCheckPermission(value = "store:assignUser", orRole = "admin")
public String assignUser(@RequestBody RStoreUser storeUser) {
storeUserService.lambdaUpdate().eq(RStoreUser::getStoreId, storeUser.getStoreId()).remove();
Opt.ofNullable(storeUser.getStoreUsers())
.ifPresent(su -> storeUserService.saveBatch(Arrays.asList(su)));
return "成功";
}
@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();
}
@PostMapping("/store/log")
@SaCheckPermission(value = "store:log:save", orRole = "admin")
public String saveLog(@RequestBody StoreLog storeLog) {
return storeLogService.save(storeLog) ? "新增成功" : "新增失败";
}
@GetMapping("/store/screen")
@SaCheckPermission(value = "store:screen", orRole = "admin")
public List<StoreVO> storeScreen() {
return storeService.storeScreen();
}
}
......@@ -60,7 +60,7 @@ public class TaskTempController {
@PostMapping("/taskTemp/{id}")
@SaCheckPermission(value = "taskTemp:edit", orRole = "admin")
public String upd(@PathVariable(name = "id") Long id, TaskTempDTO data) {
TaskTemp taskTemp = converter.convert(data, new TaskTemp());
TaskTemp taskTemp = converter.convert(data, TaskTemp.class);
taskTemp.setId(id);
return taskTempService.updateById(taskTemp) ? "更新成功" : "更新失败";
}
......
......@@ -12,10 +12,7 @@ import org.springframework.stereotype.Component;
import vion.model.Contract;
import vion.model.ContractPayment;
import vion.model.Dictionary;
import vion.service.IContractPaymentService;
import vion.service.IContractService;
import vion.service.IDictionaryService;
import vion.service.IStoreService;
import vion.service.*;
import java.math.BigDecimal;
import java.sql.*;
......@@ -129,7 +126,6 @@ public class ContractRunner {
// 合同付款比例
List<ContractPayment> contractPaymentList = new ArrayList<>();
for (Contract contract : insOrUpdContractList) {
// 签订
ContractPayment contractSignPayment = new ContractPayment();
contractSignPayment.setId(contractId2PaymentMap.getOrDefault(contract.getId(), new HashMap<>()).get(1));
......@@ -203,8 +199,8 @@ public class ContractRunner {
contractMaintainPayment3.setPaymentDate(contract.getMaintainDate3());
contractPaymentList.add(contractMaintainPayment3);
}
contractPaymentService.saveOrUpdateBatch(contractPaymentList);
insOrUpdContractList.forEach(c -> {
String contractNo = c.getContractNo();
Contract exist = contractService.lambdaQuery().eq(Contract::getContractNo, contractNo).one();
......
package vion.cron;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Opt;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
......@@ -15,6 +16,7 @@ import vion.service.IUserService;
import vion.third.DingMod;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author HlQ
......@@ -34,10 +36,11 @@ public class TaskRunner {
log.info("开始推送未完成工单");
List<Task> taskList = taskService.list(Wrappers.<Task>lambdaQuery().notIn(Task::getStatus, 3, 5));
// todo 需要异步发送吗?
taskList.forEach(task -> {
Long activeUser = task.getActiveUser();
User user = userService.lambdaQuery().eq(User::getId, activeUser).one();
dingMod.sendMessage(buildMsg(user));
Opt.ofEmptyAble(taskList)
.map(l -> l.stream().map(Task::getActiveUser).collect(Collectors.toSet()))
.ifPresent(userIds -> {
List<User> userList = userService.list(Wrappers.<User>lambdaQuery().in(User::getId, userIds));
userList.forEach(user -> dingMod.sendMessage(buildMsg(user)));
});
log.info("推送未完成工单完成");
}
......
package vion.dto;
import lombok.Data;
@Data
public class ConstructionTeamDTO extends BaseDTO {
private Long id;
/**
* 施工队名称
*/
private String name;
/**
* 城市
*/
private String city;
}
\ No newline at end of file
......@@ -5,6 +5,7 @@ import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.multipart.MultipartFile;
import java.math.BigDecimal;
import java.util.Date;
@Getter
......@@ -38,6 +39,11 @@ public class ContractDTO extends BaseDTO {
private String saleName;
/**
* 合同甲方名称
*/
private String customerName;
/**
* 备注
*/
private String remark;
......@@ -73,4 +79,33 @@ public class ContractDTO extends BaseDTO {
*/
private int switchFlag;
/** 产品线属性 */
private Integer productLine;
/**
* 合同总金额
*/
private BigDecimal totalAmount;
/**
* 合同已收金额
*/
private BigDecimal paidAmount;
/**
* 合同应收金额:
* 根据【合同进度】,由系统判断出应该收到的金额
*/
private BigDecimal receivableAmount;
/**
* 合同未收金额:total-paid
*/
private BigDecimal outstandingAmount;
private BigDecimal amount;
/** 操作符 > < = */
private String operator;
}
\ No newline at end of file
package vion.dto;
import lombok.Getter;
import lombok.Setter;
import java.util.Date;
@Getter
@Setter
public class RContractTeamDTO extends BaseDTO {
private Long id;
/**
* 合同id
*/
private Long contractId;
private String contractNo;
private String ContractName;
/**
* 施工队id
*/
private Long ctId;
/**
* 负责人
*/
private String principal;
/**
* 电话号码
*/
private String phone;
/**
* 分配日期
*/
private Date assignDate;
/**
* 完成日期
*/
private Date finishDate;
/**
* 施工状态
*/
private Integer status;
/**
* 申请人
*/
private Integer applicant;
/**
* 申请人名字
*/
private String applicantName;
/**
* 备注
*/
private String remark;
}
\ No newline at end of file
package vion.dto;
import lombok.Getter;
import lombok.Setter;
import org.springframework.web.multipart.MultipartFile;
import java.math.BigDecimal;
@Getter
@Setter
public class SettlementDiffDTO extends BaseDTO {
private Long id;
/**
* 合同id
*/
private Long contractId;
/**
* 合同号
*/
private String contractNo;
/**
* 差异类型
*/
private Integer diffType;
/**
* 结算差异
*/
private BigDecimal settlementDiff;
/**
* 冲抵项
*/
private Integer offsetItem;
/**
* 操作人
*/
private Long operator;
private MultipartFile[] files;
}
\ No newline at end of file
package vion.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;
......@@ -43,4 +44,17 @@ public class StoreDTO extends BaseDTO {
private Long masterContract;
/** 维保状态 */
private String maintainStatus;
/** 产品线属性 */
private Integer productLine;
/** 是否重点项目 0:不是 1:是 */
private Integer isImportant;
/** 任务详情 */
private String taskDetail;
/** 预计完成日期 */
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date finishDate;
/** 完成百分比 */
private Double percentage;
/** 当前卡点 */
private String stuckPoint;
}
......@@ -62,4 +62,6 @@ public class TaskDTO extends BaseDTO {
private Date enddate;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date curDate;
/** 工时 */
private Double manHour;
}
package vion.mapper;
import com.github.yulichang.base.MPJBaseMapper;
import vion.model.ConstructionTeam;
/**
* @author HlQ
* @date 2023/12/26
*/
public interface ConstructionTeamMapper extends MPJBaseMapper<ConstructionTeam> {
}
\ No newline at end of file
package vion.mapper;
import com.github.yulichang.base.MPJBaseMapper;
import vion.model.RContractTeam;
/**
* @author HlQ
* @date 2023/12/26
*/
public interface RContractTeamMapper extends MPJBaseMapper<RContractTeam> {
}
\ No newline at end of file
package vion.mapper;
import com.github.yulichang.base.MPJBaseMapper;
import vion.model.RContractUser;
/**
* @author HlQ
* @date 2023/12/28
*/
public interface RContractUserMapper extends MPJBaseMapper<RContractUser> {
}
\ No newline at end of file
package vion.mapper;
import com.github.yulichang.base.MPJBaseMapper;
import vion.model.RStoreUser;
/**
* @author HlQ
* @date 2023/12/27
*/
public interface RStoreUserMapper extends MPJBaseMapper<RStoreUser> {
}
\ No newline at end of file
package vion.mapper;
import com.github.yulichang.base.MPJBaseMapper;
import vion.model.SettlementDiff;
/**
* @author HlQ
* @date 2023/12/26
*/
public interface SettlementDiffMapper extends MPJBaseMapper<SettlementDiff> {
}
\ No newline at end of file
package vion.mapper;
import com.github.yulichang.base.MPJBaseMapper;
import vion.model.StoreLog;
/**
* @author HlQ
* @date 2023/12/27
*/
public interface StoreLogMapper extends MPJBaseMapper<StoreLog> {
}
\ 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.ConstructionTeamDTO;
import vion.vo.ConstructionTeamVO;
import java.util.Date;
/**
* 施工队信息表
*/
@Data
@TableName(value = "tbl_construction_team")
@AutoMappers({
@AutoMapper(target = ConstructionTeamVO.class),
@AutoMapper(target = ConstructionTeamDTO.class),
})
public class ConstructionTeam {
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 施工队名称
*/
@TableField(value = "\"name\"")
private String name;
/**
* 城市
*/
@TableField(value = "city")
private String city;
@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
......@@ -100,7 +100,7 @@ public class Contract {
/**
* 合同甲方名称
*/
@TableField(value = "customer_name")
@TableField(value = "customer_name", condition = SqlCondition.LIKE)
private String customerName;
/**
......
......@@ -30,4 +30,6 @@ public class FaultLog {
private Date createTime;
/** 备注 */
private String remark;
/** 工时 */
private Double manHour;
}
......@@ -26,8 +26,9 @@ public class FileInfo {
private String type;
/**
* 文件来源
* 1项目、2工单预处理,3工单操作,4巡检,5合同,6发货记录,
* 7签订,8到货,9系统初验,10项目终验,11质保,12第一笔维保款,13第二笔维保款,14第三笔维保款
* <br>1项目、2工单预处理,3工单操作,4巡检,5合同,6发货记录,</br>
* <br>7签订,8到货,9系统初验,10项目终验,11质保,12第一笔维保款,13第二笔维保款,14第三笔维保款</br>
* <br>15结算差异</br>
*/
private Integer sourceType;
/** 文件来源id */
......
package vion.model;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.github.linpeilie.annotations.AutoMapper;
import io.github.linpeilie.annotations.AutoMappers;
import lombok.Data;
import vion.dto.RContractTeamDTO;
import vion.vo.RContractTeamVO;
import java.util.Date;
/**
* 合同与施工队关联表
*/
@Data
@TableName(value = "r_contract_team")
@AutoMappers({
@AutoMapper(target = RContractTeamVO.class),
@AutoMapper(target = RContractTeamDTO.class),
})
public class RContractTeam {
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 合同id
*/
@TableField(value = "contract_id")
private Long contractId;
/**
* 施工队id
*/
@TableField(value = "ct_id")
private Long ctId;
/**
* 负责人
*/
@TableField(value = "principal")
private String principal;
/**
* 电话号码
*/
@TableField(value = "phone")
private String phone;
/**
* 分配日期
*/
@TableField(value = "assign_date")
private Date assignDate;
/**
* 完成日期
*/
@TableField(value = "finish_date")
private Date finishDate;
/**
* 施工状态
*/
@TableField(value = "\"status\"")
private Integer status;
/**
* 申请人
*/
@TableField(value = "applicant")
private Integer applicant;
/**
* 申请人名字
*/
@TableField(value = "applicant_name")
private String applicantName;
/**
* 备注
*/
@TableField(value = "remark")
private String remark;
@TableField(value = "create_time")
private Date createTime;
@TableField(value = "update_time")
private Date updateTime;
}
\ No newline at end of file
package vion.model;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.util.Date;
import lombok.Data;
/**
* @author HlQ
* @date 2023/12/28
*/
/**
* 合同与用户关联表(用户指的是销售)
*/
@Data
@TableName(value = "r_contract_user")
public class RContractUser {
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 合同id
*/
@TableField(value = "contract_id")
private Long contractId;
/**
* 合同号
*/
@TableField(value = "contract_no")
private String contractNo;
/**
* 用户id,用钉钉的userid
*/
@TableField(value = "user_id")
private Integer userId;
/**
* 用户名
*/
@TableField(value = "username")
private String username;
/**
* 备注
*/
@TableField(value = "remark")
private String remark;
/**
* 录入日期
*/
@TableField(value = "enter_date")
private Date enterDate;
@TableField(value = "create_time")
private Date createTime;
}
\ 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;
/**
* @author HlQ
* @date 2023/12/27
*/
/**
* 项目与用户关联表
*/
@Data
@TableName(value = "r_store_user")
public class RStoreUser {
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 项目id
*/
@TableField(value = "store_id")
private Long storeId;
/**
* 用户id
*/
@TableField(value = "user_id")
private Long userId;
/**
* 是否负责人 0:否 1:是
*/
@TableField(value = "is_main")
@OrderBy(sort = 1)
private Integer isMain;
@TableField(value = "create_time", fill = FieldFill.INSERT)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@OrderBy
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;
@TableField(exist = false)
private RStoreUser[] storeUsers;
}
\ 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.SettlementDiffDTO;
import vion.vo.SettlementDiffVO;
import java.math.BigDecimal;
import java.util.Date;
/**
* @author HlQ
* @date 2023/12/26
*/
@Data
@TableName(value = "tbl_settlement_diff")
@AutoMappers({
@AutoMapper(target = SettlementDiffVO.class),
@AutoMapper(target = SettlementDiffDTO.class),
})
public class SettlementDiff {
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 合同id
*/
@TableField(value = "contract_id")
private Long contractId;
/**
* 合同号
*/
@TableField(value = "contract_no")
private String contractNo;
/**
* 差异类型
*/
@TableField(value = "diff_type")
private Integer diffType;
/**
* 结算差异
*/
@TableField(value = "settlement_diff")
private BigDecimal settlementDiff;
/**
* 冲抵项
*/
@TableField(value = "offset_item")
private Integer offsetItem;
/**
* 操作人
*/
@TableField(value = "\"operator\"")
private Long operator;
/**
* 创建时间
*/
@TableField(value = "create_time", fill = FieldFill.INSERT)
private Date createTime;
}
\ No newline at end of file
......@@ -61,4 +61,23 @@ public class Store {
/** 维保状态 */
private String maintainStatus;
/** 产品线属性 */
private Integer productLine;
/** 是否重点项目 0:不是 1:是 */
private Integer isImportant;
/** 任务详情 */
private String taskDetail;
/** 预计完成日期 */
private Date finishDate;
/** 完成百分比 */
private Double percentage;
/** 当前卡点 */
private String stuckPoint;
}
package vion.model;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.util.Date;
/**
* 项目日志表
*/
@Data
@TableName(value = "tbl_store_log")
public class StoreLog {
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 项目id
*/
@TableField(value = "store_id")
private Long storeId;
/**
* 备注
*/
@TableField(value = "remark")
private String remark;
@TableField(value = "create_time", fill = FieldFill.INSERT)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@OrderBy
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.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.base.MPJBaseService;
import vion.dto.ConstructionTeamDTO;
import vion.dto.RContractTeamDTO;
import vion.model.ConstructionTeam;
import vion.vo.ConstructionTeamVO;
import vion.vo.RContractTeamVO;
/**
* @author HlQ
* @date 2023/12/26
*/
public interface IConstructionTeamService extends MPJBaseService<ConstructionTeam> {
Page<ConstructionTeamVO> list(ConstructionTeamDTO dto);
ConstructionTeamVO getVOById(Long id);
Object save(ConstructionTeamDTO dto);
String updateById(ConstructionTeamDTO dto);
Page<RContractTeamVO> list(RContractTeamDTO dto);
String assignTeam(RContractTeamDTO dto);
String delContractTeamById(Long id);
}
......@@ -4,8 +4,11 @@ import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.base.MPJBaseService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import vion.dto.ContractDTO;
import vion.dto.RContractTeamDTO;
import vion.model.Contract;
import vion.model.RContractUser;
import vion.vo.ContractVO;
/**
......@@ -28,4 +31,10 @@ public interface IContractService extends MPJBaseService<Contract>{
Object analyze(ContractDTO dto);
String dispatch(@RequestBody RContractTeamDTO dto);
String assignSale(RContractUser contractUser);
String unbindSale(Long id);
}
\ No newline at end of file
package vion.service;
import com.github.yulichang.base.MPJBaseService;
import vion.model.RContractTeam;
/**
* @author HlQ
* @date 2023/12/26
*/
public interface IRContractTeamService extends MPJBaseService<RContractTeam> {
}
package vion.service;
import com.github.yulichang.base.MPJBaseService;
import vion.model.RContractUser;
/**
* @author HlQ
* @date 2023/12/28
*/
public interface IRContractUserService extends MPJBaseService<RContractUser> {
}
package vion.service;
import com.github.yulichang.base.MPJBaseService;
import vion.model.RStoreUser;
/**
* @author HlQ
* @date 2023/12/27
*/
public interface IRStoreUserService extends MPJBaseService<RStoreUser> {
}
package vion.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.base.MPJBaseService;
import vion.dto.SettlementDiffDTO;
import vion.model.SettlementDiff;
import vion.vo.SettlementDiffVO;
/**
* @author HlQ
* @date 2023/12/25
*/
public interface ISettlementDiffService extends MPJBaseService<SettlementDiff> {
Page<SettlementDiffVO> list(String no, SettlementDiffDTO dto);
SettlementDiffVO getVOById(Long id);
String save(SettlementDiffDTO dto);
String update(Long id, SettlementDiffDTO dto);
}
package vion.service;
import com.github.yulichang.base.MPJBaseService;
import vion.model.StoreLog;
/**
* @author HlQ
* @date 2023/12/27
*/
public interface IStoreLogService extends MPJBaseService<StoreLog> {
}
......@@ -7,6 +7,8 @@ import vion.dto.StoreDTO;
import vion.model.Store;
import vion.vo.StoreVO;
import java.util.List;
public interface IStoreService extends MPJBaseService<Store> {
Page<StoreVO> getStoreList(StoreDTO data);
......@@ -15,4 +17,6 @@ public interface IStoreService extends MPJBaseService<Store> {
String calMaintainStatus();
List<StoreVO> storeScreen();
}
package vion.service.impl;
import cn.hutool.core.util.StrUtil;
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.springframework.stereotype.Service;
import vion.dto.ConstructionTeamDTO;
import vion.dto.RContractTeamDTO;
import vion.mapper.ConstructionTeamMapper;
import vion.model.ConstructionTeam;
import vion.model.Contract;
import vion.model.RContractTeam;
import vion.service.IConstructionTeamService;
import vion.service.IRContractTeamService;
import vion.vo.ConstructionTeamVO;
import vion.vo.RContractTeamVO;
import java.util.List;
/**
* @author HlQ
* @date 2023/12/26
*/
@Service
@RequiredArgsConstructor
public class ConstructionTeamServiceImpl extends MPJBaseServiceImpl<ConstructionTeamMapper, ConstructionTeam> implements IConstructionTeamService {
private final IRContractTeamService contractTeamService;
private final Converter converter;
@Override
public Page<ConstructionTeamVO> list(ConstructionTeamDTO dto) {
Page<ConstructionTeam> constructionTeamList = this.lambdaQuery(converter.convert(dto, ConstructionTeam.class))
.page(Page.of(dto.getPageNum(), dto.getPageSize()));
List<ConstructionTeamVO> voList = converter.convert(constructionTeamList.getRecords(), ConstructionTeamVO.class);
return Page.<ConstructionTeamVO>of(constructionTeamList.getCurrent(), constructionTeamList.getSize(), constructionTeamList.getTotal()).setRecords(voList);
}
@Override
public ConstructionTeamVO getVOById(Long id) {
return converter.convert(this.getById(id), ConstructionTeamVO.class);
}
@Override
public Object save(ConstructionTeamDTO dto) {
ConstructionTeam constructionTeam = converter.convert(dto, ConstructionTeam.class);
return this.save(constructionTeam) ? constructionTeam.getId() : "新增失败";
}
@Override
public String updateById(ConstructionTeamDTO dto) {
ConstructionTeam constructionTeam = converter.convert(dto, ConstructionTeam.class);
return this.updateById(constructionTeam) ? "更新成功" : "更新失败";
}
@Override
public Page<RContractTeamVO> list(RContractTeamDTO dto) {
MPJLambdaWrapper<RContractTeam> wrapper = new MPJLambdaWrapper<>(converter.convert(dto, RContractTeam.class))
.selectAll(RContractTeam.class)
.selectAs(Contract::getContractNo, RContractTeamVO::getContractNo)
.selectAs(Contract::getName, RContractTeamVO::getContractName)
.selectAs(ConstructionTeam::getName, RContractTeamVO::getTeamName)
.leftJoin(Contract.class, Contract::getId, RContractTeam::getContractId)
.leftJoin(ConstructionTeam.class, ConstructionTeam::getId, RContractTeam::getCtId)
.like(StrUtil.isNotBlank(dto.getContractNo()), Contract::getContractNo, dto.getContractNo())
.like(StrUtil.isNotBlank(dto.getContractName()), Contract::getName, dto.getContractName())
.orderByAsc(RContractTeam::getStatus)
.orderByDesc(RContractTeam::getCreateTime);
return contractTeamService.selectJoinListPage(Page.of(dto.getPageNum(), dto.getPageSize()), RContractTeamVO.class, wrapper);
}
@Override
public String assignTeam(RContractTeamDTO dto) {
RContractTeam rContractTeam = converter.convert(dto, RContractTeam.class);
return contractTeamService.updateById(rContractTeam) ? "分配施工队成功。" : "分配施工队失败";
}
@Override
public String delContractTeamById(Long id) {
return contractTeamService.removeById(id) ? "删除成功" : "删除失败";
}
}
......@@ -2,12 +2,15 @@ package vion.service.impl;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.yulichang.base.MPJBaseServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import vion.mapper.ContractPaymentMapper;
import vion.mapper.SettlementDiffMapper;
import vion.model.Contract;
import vion.model.ContractPayment;
import vion.model.SettlementDiff;
import vion.service.IContractPaymentService;
import java.math.BigDecimal;
......@@ -23,6 +26,8 @@ import java.util.stream.Collectors;
@RequiredArgsConstructor
public class ContractPaymentServiceImpl extends MPJBaseServiceImpl<ContractPaymentMapper, ContractPayment> implements IContractPaymentService {
private final SettlementDiffMapper settlementDiffMapper;
/**
* 当合同状态变化或者应收款变化时,重新计算款项
*
......@@ -32,6 +37,11 @@ public class ContractPaymentServiceImpl extends MPJBaseServiceImpl<ContractPayme
@Override
public void calMoney(Contract existContract, Contract dto) {
List<ContractPayment> contractPaymentList = this.lambdaQuery().eq(ContractPayment::getContractId, existContract.getId()).list();
List<SettlementDiff> diffList = settlementDiffMapper.selectList(Wrappers.<SettlementDiff>lambdaQuery().eq(SettlementDiff::getContractId, existContract.getId()));
BigDecimal diffAmount1 = diffList.stream().filter(diff -> diff.getOffsetItem() == 1).map(SettlementDiff::getSettlementDiff).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal diffAmount2 = diffList.stream().filter(diff -> diff.getOffsetItem() == 2).map(SettlementDiff::getSettlementDiff).reduce(BigDecimal.ZERO, BigDecimal::add);
Map<Integer, BigDecimal> type2RatioMap = contractPaymentList.stream().collect(Collectors.toMap(ContractPayment::getPaymentType, ContractPayment::getPaymentRatio));
Integer status = dto.getStatus() == null ? existContract.getStatus() : dto.getStatus();
BigDecimal sumRatio = new BigDecimal(0);
......@@ -39,11 +49,11 @@ public class ContractPaymentServiceImpl extends MPJBaseServiceImpl<ContractPayme
BigDecimal ratio = type2RatioMap.get(i);
sumRatio = NumberUtil.add(ratio, sumRatio);
}
BigDecimal totalAmount = existContract.getTotalAmount();
BigDecimal totalAmount = NumberUtil.add(existContract.getTotalAmount(), diffAmount1);
BigDecimal curAmount = NumberUtil.mul(totalAmount, sumRatio);
BigDecimal paidAmount = ObjUtil.isNull(dto.getPaidAmount()) ? existContract.getPaidAmount() : dto.getPaidAmount();
BigDecimal recAmount = NumberUtil.sub(curAmount, paidAmount);
BigDecimal outsideAmount = NumberUtil.sub(totalAmount, paidAmount);
BigDecimal recAmount = NumberUtil.add(NumberUtil.sub(curAmount, paidAmount), diffAmount2);
BigDecimal outsideAmount = NumberUtil.add(NumberUtil.sub(totalAmount, paidAmount), NumberUtil.add(diffAmount1, diffAmount2));
dto.setReceivableAmount(recAmount);
dto.setOutstandingAmount(outsideAmount);
}
......
......@@ -12,9 +12,11 @@ import cn.hutool.core.lang.Opt;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.*;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.toolkit.Db;
import com.github.yulichang.base.MPJBaseServiceImpl;
......@@ -25,9 +27,11 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import vion.dto.ContractDTO;
import vion.dto.RContractTeamDTO;
import vion.mapper.ContractMapper;
import vion.model.*;
import vion.service.*;
import vion.third.DingMod;
import vion.vo.*;
import java.io.File;
......@@ -49,6 +53,9 @@ public class ContractServiceImpl extends MPJBaseServiceImpl<ContractMapper, Cont
private final IContractPaymentService contractPaymentService;
private final IRContractStoreService contractStoreService;
private final IContractLogService contractLogService;
private final IRContractTeamService contractTeamService;
private final IRContractUserService contractUserService;
private final DingMod dingMod;
private final Converter converter;
@Value("${fileUrl:}")
......@@ -56,40 +63,84 @@ public class ContractServiceImpl extends MPJBaseServiceImpl<ContractMapper, Cont
@Override
public Page<ContractVO> list(ContractDTO dto) {
Contract contract = converter.convert(dto, new Contract());
Contract contract = converter.convert(dto, Contract.class);
List<Long> contractIdList = new ArrayList<>();
if (dto.getSwitchFlag() == 1) {
contractIdList = contractStoreService.listObjs(Wrappers.<RContractStore>lambdaQuery()
.select(RContractStore::getContractId), o -> Long.valueOf(o.toString()));
}
List<Long> contractIdList = dto.getSwitchFlag() == 1 ?
contractStoreService.listObjs(Wrappers.<RContractStore>lambdaQuery()
.select(RContractStore::getContractId), o -> Long.valueOf(o.toString()))
: ListUtil.empty();
List<Long> relatedContractIdList = Opt.ofNullable(dto.getProductLine())
.map(pl -> Db.listObjs(Wrappers.lambdaQuery(Store.class).eq(Store::getProductLine, pl), Store::getId))
.map(storeIds -> contractStoreService.listObjs(Wrappers.<RContractStore>lambdaQuery().select(RContractStore::getContractId).in(RContractStore::getStoreId, storeIds), o -> Long.valueOf(o.toString())))
.orElse(ListUtil.empty());
UserVO userVO = (UserVO) StpUtil.getTokenSession().get("curLoginUser");
String saleName = Opt.ofEmptyAble(userVO.getRoleVOList())
.map(l -> l.stream().map(RoleVO::getCode).collect(Collectors.toList()))
.map(roleCodeList -> {
if (!roleCodeList.contains("admin") && !roleCodeList.contains("shangwu") && !roleCodeList.contains("caiwu")) {
Set<String> roleCodeList = Opt.ofEmptyAble(userVO.getRoleVOList())
.map(l -> l.stream().map(RoleVO::getCode).collect(Collectors.toSet()))
.orElse(CollUtil.newHashSet());
String saleName = Opt.ofEmptyAble(roleCodeList)
.map(rc -> {
if (!rc.contains("admin") && !rc.contains("shangwu") && !rc.contains("caiwu")) {
return userVO.getUsername();
} else {
return "";
}
}).orElse("未知");
Page<Contract> contractList = this.lambdaQuery(contract)
// 防止特殊情况出现
Assert.notEquals(saleName, "未知", "当前用户角色不详,请联系管理员");
// todo r_contract_user关联表查当前人(数据权限)所有合同id
MPJLambdaWrapper<Contract> wrapper = new MPJLambdaWrapper<>(contract)
.selectAll(Contract.class)
.leftJoin(RContractUser.class, RContractUser::getContractId, Contract::getId)
.between(ArrayUtil.isAllNotNull(dto.getSignDateStart(), dto.getSignDateEnd()), Contract::getSignDate, dto.getSignDateStart(), dto.getSignDateEnd())
.notIn(CollUtil.isNotEmpty(contractIdList), Contract::getId, contractIdList)
.in(CollUtil.isNotEmpty(relatedContractIdList), Contract::getId, relatedContractIdList)
.eq(StrUtil.isNotBlank(saleName), Contract::getSaleName, saleName)
.orderByDesc(Contract::getEntryTime)
.page(Page.of(dto.getPageNum(), dto.getPageSize()));
.or()
.eq(StrUtil.isNotBlank(saleName), Contract::getSaleName, saleName)
.orderByDesc(Contract::getEntryTime);
if (StrUtil.isNotBlank(dto.getOperator()) && ObjUtil.isNotNull(dto.getAmount())) {
String ope = dto.getOperator();
if (">".equals(ope)) {
wrapper.gt(getCol(dto), dto.getAmount());
} else if ("<".equals(ope)) {
wrapper.lt(getCol(dto), dto.getAmount());
} else {
wrapper.eq(getCol(dto), dto.getAmount());
}
}
Page<Contract> contractList = this.page(Page.of(dto.getPageNum(), dto.getPageSize()), wrapper);
List<ContractVO> contractVOList = converter.convert(contractList.getRecords(), ContractVO.class);
if (!roleCodeList.contains("admin") && !roleCodeList.contains("xiaoshou") && !roleCodeList.contains("caiwu")) {
contractVOList.forEach(vo -> {
vo.setTotalAmount(null);
vo.setPaidAmount(null);
vo.setReceivableAmount(null);
vo.setOutstandingAmount(null);
vo.setInvoiceAmount(null);
});
}
// 查出合同关联的项目名
completeStoreName(contractVOList);
return Page.<ContractVO>of(contractList.getCurrent(), contractList.getSize(), contractList.getTotal()).setRecords(contractVOList);
}
private SFunction<Contract, Object> getCol(ContractDTO dto) {
if (dto.getTotalAmount() != null) {
return Contract::getTotalAmount;
} else if (dto.getPaidAmount() != null) {
return Contract::getPaidAmount;
} else if (dto.getReceivableAmount() != null) {
return Contract::getReceivableAmount;
} else {
return Contract::getOutstandingAmount;
}
}
@Override
public Page<ContractVO> listPart(ContractDTO dto) {
Contract contract = converter.convert(dto, new Contract());
Contract contract = converter.convert(dto, Contract.class);
List<Long> ids = Opt.ofNullable(dto.getStoreId())
.map(storeId -> contractStoreService.listObjs(Wrappers.<RContractStore>lambdaQuery().select(RContractStore::getContractId).eq(RContractStore::getStoreId, dto.getStoreId()), o -> Long.valueOf(o.toString())))
......@@ -129,12 +180,24 @@ public class ContractServiceImpl extends MPJBaseServiceImpl<ContractMapper, Cont
@Override
public ContractVO getVOById(Long id) {
UserVO userVO = (UserVO) StpUtil.getTokenSession().get("curLoginUser");
Set<String> roleCodeList = Opt.ofEmptyAble(userVO.getRoleVOList())
.map(l -> l.stream().map(RoleVO::getCode).collect(Collectors.toSet()))
.orElse(CollUtil.newHashSet());
MPJLambdaWrapper<Contract> wrapper = new MPJLambdaWrapper<Contract>()
.selectAll(Contract.class)
.selectCollection(ContractLog.class, ContractVO::getContractLogs)
.leftJoin(ContractLog.class, ContractLog::getContractNo, Contract::getContractNo)
.eq(Contract::getId, id);
return this.selectJoinOne(ContractVO.class, wrapper);
ContractVO contractVO = this.selectJoinOne(ContractVO.class, wrapper);
if (!roleCodeList.contains("admin") && !roleCodeList.contains("xiaoshou") && !roleCodeList.contains("caiwu")) {
contractVO.setTotalAmount(null);
contractVO.setPaidAmount(null);
contractVO.setReceivableAmount(null);
contractVO.setOutstandingAmount(null);
contractVO.setInvoiceAmount(null);
}
return contractVO;
}
@Override
......@@ -143,7 +206,7 @@ public class ContractServiceImpl extends MPJBaseServiceImpl<ContractMapper, Cont
.select(Contract::getId, Contract::getName, Contract::getContractNo, Contract::getType, Contract::getSignDate, Contract::getWarrantyPeriod, Contract::getFinalDate, Contract::getStatus, Contract::getSaleName, Contract::getCustomerName)
.eq(Contract::getContractNo, no)
.one();
ContractVO contractVO = converter.convert(contract, new ContractVO());
ContractVO contractVO = converter.convert(contract, ContractVO.class);
Assert.notNull(contractVO, "合同不存在");
MPJLambdaWrapper<RContractStore> wrapper = new MPJLambdaWrapper<RContractStore>()
.select(Store::getId, Store::getName)
......@@ -167,7 +230,7 @@ public class ContractServiceImpl extends MPJBaseServiceImpl<ContractMapper, Cont
// todo 如果当前合同进度在要修改的进度前,此时不能修改合同进度。e.g 当前合同进度是项目验收,此时传参过来到货,那么不能修改
Contract contract = converter.convert(dto, new Contract());
Contract contract = converter.convert(dto, Contract.class);
Long contractId = existContract.getId();
contract.setId(contractId);
contractPaymentService.calMoney(existContract, contract);
......@@ -212,7 +275,8 @@ public class ContractServiceImpl extends MPJBaseServiceImpl<ContractMapper, Cont
String orgName = infile.getOriginalFilename();
String mainName = FileUtil.mainName(orgName);
String fileExt = FileUtil.extName(orgName);
String filename = StrUtil.format("{}_{}.{}", mainName, DateUtil.format(new Date(), "yyyyMMdd_HHmmss"), fileExt);;
String filename = StrUtil.format("{}_{}.{}", mainName, DateUtil.format(new Date(), "yyyyMMdd_HHmmss"), fileExt);
;
String path = fileUrl + FileUtil.FILE_SEPARATOR + "contract" + FileUtil.FILE_SEPARATOR + contract.getId() + FileUtil.FILE_SEPARATOR + filename;
File file = FileUtil.touch(path);
try {
......@@ -242,20 +306,19 @@ public class ContractServiceImpl extends MPJBaseServiceImpl<ContractMapper, Cont
@Override
public JSONObject calAmount(ContractDTO dto) {
UserVO userVO = (UserVO) StpUtil.getTokenSession().get("curLoginUser");
String saleName = Opt.ofEmptyAble(userVO.getRoleVOList())
.map(l -> l.stream().map(RoleVO::getCode).collect(Collectors.toList()))
.map(roleCodeList -> {
if (!roleCodeList.contains("admin") && !roleCodeList.contains("shangwu") && !roleCodeList.contains("caiwu")) {
Set<String> roleCodeList = Opt.ofEmptyAble(userVO.getRoleVOList())
.map(l -> l.stream().map(RoleVO::getCode).collect(Collectors.toSet()))
.orElse(CollUtil.newHashSet());
String saleName = Opt.ofEmptyAble(roleCodeList)
.map(rc -> {
if (!rc.contains("admin") && !rc.contains("shangwu") && !rc.contains("caiwu")) {
return userVO.getUsername();
} else {
return "";
}
}).orElse("未知");
List<Contract> contracts = this.list(Wrappers.lambdaQuery(converter.convert(dto, Contract.class))
.eq(StrUtil.isNotBlank(saleName), Contract::getSaleName, saleName)
.between(ArrayUtil.isAllNotNull(dto.getSignDateStart(), dto.getSignDateEnd()), Contract::getSignDate, dto.getSignDateStart(), dto.getSignDateEnd())
);
// 防止特殊情况出现
Assert.notEquals(saleName, "未知", "当前用户角色不详,请联系管理员");
JSONObject obj = JSONUtil.createObj()
.set("totalAmount", 0)
......@@ -263,6 +326,16 @@ public class ContractServiceImpl extends MPJBaseServiceImpl<ContractMapper, Cont
.set("recAmount", 0)
.set("outAmount", 0)
.set("invoiceAmount", 0);
if (!roleCodeList.contains("admin") && !roleCodeList.contains("xiaoshou") && !roleCodeList.contains("caiwu")) {
return obj;
}
List<Contract> contracts = this.list(Wrappers.lambdaQuery(converter.convert(dto, Contract.class))
.eq(StrUtil.isNotBlank(saleName), Contract::getSaleName, saleName)
.between(ArrayUtil.isAllNotNull(dto.getSignDateStart(), dto.getSignDateEnd()), Contract::getSignDate, dto.getSignDateStart(), dto.getSignDateEnd())
);
Opt.ofEmptyAble(contracts)
.ifPresent(list -> {
BigDecimal totalAmount = list.stream().map(Contract::getTotalAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
......@@ -348,4 +421,53 @@ public class ContractServiceImpl extends MPJBaseServiceImpl<ContractMapper, Cont
int[] transToStartEnd = PageUtil.transToStartEnd(dto.getPageNum() - 1, dto.getPageSize());
return Page.<FinancialAgeVO>of(dto.getPageNum(), dto.getPageSize(), financialAgeVOList.size()).setRecords(CollUtil.sub(financialAgeVOList, transToStartEnd[0], transToStartEnd[1]));
}
@Override
public String dispatch(RContractTeamDTO dto) {
RContractTeam rContractTeam = converter.convert(dto, RContractTeam.class);
if (contractTeamService.save(rContractTeam)) {
// todo 推送钉钉消息到王平川,要支持可配置吗?
Contract contract = this.getById(dto.getContractId());
dingMod.sendMessage(buildMsg("01005444040832705136", contract, dto.getApplicantName()));
return "派工成功,待分配施工队。";
}
return "派工失败";
}
@Override
public String assignSale(RContractUser contractUser) {
return contractUserService.save(contractUser) ? "分配成功" : "分配失败";
}
@Override
public String unbindSale(Long id) {
return contractUserService.removeById(id) ? "解绑成功" : "解绑失败";
}
JSONObject buildMsg(String userid, Contract contract, String applicantName) {
JSONObject jsonObj = new JSONObject();
jsonObj.set("agent_id", 2358374016L);
jsonObj.set("userid_list", userid);
JSONObject msg = new JSONObject();
JSONObject content = new JSONObject();
content.set("title", "合同施工申请,请及时处理哦~_~");
String markdown = StrUtil.format("#### 合同编号: **{}**" +
" \n #### 合同名称:**{}**" +
" \n #### 申请人:{}" +
" \n #### 发送时间:{}",
contract.getContractNo(), contract.getName(), applicantName, DateUtil.now());
content.set("markdown", markdown);
content.set("btn_orientation", "1");
JSONArray jsonArray = new JSONArray();
// todo 暂无查看详情,需前端提供一个页面
// jsonArray.add(new JSONObject().set("title", "查看详情").set("action_url", "https://oapi.dingtalk.com/connect/oauth2/sns_authorize?appid=dingkrzwks0jpi2di3uo&response_type=code&scope=snsapi_auth&state=STATE&redirect_uri=https%3A%2F%2Fyunwei.vionyun.com%3A8443%2Fyunwei%2Fapi%2Fding%2Fcallback%2Finside%3FtaskTempId%3D" + taskTemp.getId()));
content.set("btn_json_list", jsonArray);
msg.set("msgtype", "action_card");
msg.set("action_card", content);
jsonObj.set("msg", msg);
return jsonObj;
}
}
\ No newline at end of file
......@@ -23,14 +23,12 @@ import vion.service.IContractService;
import vion.service.IDeliveryRecordService;
import vion.service.IFileService;
import vion.vo.DeliveryRecordVO;
import vion.vo.RoleVO;
import vion.vo.UserVO;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.Date;
import java.util.stream.Collectors;
/**
* @author HlQ
......@@ -49,23 +47,11 @@ public class DeliveryRecordServiceImpl extends MPJBaseServiceImpl<DeliveryRecord
@Override
public Page<DeliveryRecordVO> list(DeliveryRecordDTO dto) {
UserVO userVO = (UserVO) StpUtil.getTokenSession().get("curLoginUser");
String saleName = Opt.ofEmptyAble(userVO.getRoleVOList())
.map(l -> l.stream().map(RoleVO::getCode).collect(Collectors.toList()))
.map(roleCodeList -> {
if (!roleCodeList.contains("admin") && !roleCodeList.contains("shangwu") && !roleCodeList.contains("caiwu")) {
return userVO.getUsername();
} else {
return "";
}
}).orElse("未知");
MPJLambdaWrapper<DeliveryRecord> wrapper = new MPJLambdaWrapper<>(converter.convert(dto, new DeliveryRecord()))
MPJLambdaWrapper<DeliveryRecord> wrapper = new MPJLambdaWrapper<>(converter.convert(dto, DeliveryRecord.class))
.selectAll(DeliveryRecord.class)
.selectAs(Contract::getName, DeliveryRecordVO::getContractName)
.selectAs(Contract::getCustomerName, DeliveryRecordVO::getCustomerName)
.leftJoin(Contract.class, Contract::getContractNo, DeliveryRecord::getContractNo)
.eq(StrUtil.isNotBlank(saleName), Contract::getSaleName, saleName)
.like(StrUtil.isNotBlank(dto.getContractName()), Contract::getName, dto.getContractName())
.like(StrUtil.isNotBlank(dto.getCustomerName()), Contract::getCustomerName, dto.getCustomerName())
.orderByDesc(DeliveryRecord::getCreateTime);
......@@ -74,7 +60,7 @@ public class DeliveryRecordServiceImpl extends MPJBaseServiceImpl<DeliveryRecord
@Override
public String save(DeliveryRecordDTO dto) {
DeliveryRecord record = converter.convert(dto, new DeliveryRecord());
DeliveryRecord record = converter.convert(dto, DeliveryRecord.class);
if (this.save(record)) {
ContractDTO contractDTO = new ContractDTO();
contractDTO.setStatus(2);
......@@ -118,7 +104,7 @@ public class DeliveryRecordServiceImpl extends MPJBaseServiceImpl<DeliveryRecord
@Override
public String updateById(DeliveryRecordDTO dto) {
DeliveryRecord record = converter.convert(dto, new DeliveryRecord());
DeliveryRecord record = converter.convert(dto, DeliveryRecord.class);
if (this.updateById(record)) {
DeliveryRecord deliveryRecord = this.getById(dto.getId());
Opt.ofNullable(dto.getFiles())
......
package vion.service.impl;
import com.github.yulichang.base.MPJBaseServiceImpl;
import org.springframework.stereotype.Service;
import vion.mapper.RContractTeamMapper;
import vion.model.RContractTeam;
import vion.service.IRContractTeamService;
/**
* @author HlQ
* @date 2023/12/26
*/
@Service
public class RContractTeamServiceImpl extends MPJBaseServiceImpl<RContractTeamMapper, RContractTeam> implements IRContractTeamService {
}
package vion.service.impl;
import com.github.yulichang.base.MPJBaseServiceImpl;
import org.springframework.stereotype.Service;
import vion.mapper.RContractUserMapper;
import vion.model.RContractUser;
import vion.service.IRContractUserService;
/**
* @author HlQ
* @date 2023/12/28
*/
@Service
public class RContractUserServiceImpl extends MPJBaseServiceImpl<RContractUserMapper, RContractUser> implements IRContractUserService {
}
package vion.service.impl;
import com.github.yulichang.base.MPJBaseServiceImpl;
import org.springframework.stereotype.Service;
import vion.mapper.RStoreUserMapper;
import vion.model.RStoreUser;
import vion.service.IRStoreUserService;
/**
* @author HlQ
* @date 2023/12/27
*/
@Service
public class RStoreUserServiceImpl extends MPJBaseServiceImpl<RStoreUserMapper, RStoreUser> implements IRStoreUserService {
}
......@@ -35,7 +35,7 @@ public class ResourceServiceImpl extends MPJBaseServiceImpl<ResourceMapper, Reso
@Override
public Page<ResourceVO> list(ResourceDTO dto) {
Page<Resource> resourcePage = this
.lambdaQuery(converter.convert(dto, new Resource()))
.lambdaQuery(converter.convert(dto, Resource.class))
.page(Page.of(dto.getPageNum(), dto.getPageSize()));
List<ResourceVO> resourceVOList = converter.convert(resourcePage.getRecords(), ResourceVO.class);
return Page.<ResourceVO>of(resourcePage.getCurrent(), resourcePage.getSize(), resourcePage.getTotal()).setRecords(resourceVOList);
......
......@@ -26,7 +26,7 @@ public class RoleServiceImpl extends MPJBaseServiceImpl<RoleMapper, Role> implem
@Override
public Page<RoleVO> list(RoleDTO dto) {
Page<Role> rolePage = this
.lambdaQuery(converter.convert(dto, new Role()))
.lambdaQuery(converter.convert(dto, Role.class))
.between(dto.getStartDate() != null && dto.getEndDate() != null, Role::getCreateTime, dto.getStartDate(), dto.getEndDate())
.page(Page.of(dto.getPageNum(), dto.getPageSize()));
List<RoleVO> roleVOList = converter.convert(rolePage.getRecords(), RoleVO.class);
......
......@@ -53,7 +53,7 @@ public class ServiceOrderServiceImpl extends MPJBaseServiceImpl<ServiceOrderMapp
@Override
public Page<ServiceOrderVO> getServiceOrderList(ServiceOrderDTO data) {
ServiceOrder serviceOrder = converter.convert(data, new ServiceOrder());
ServiceOrder serviceOrder = converter.convert(data, ServiceOrder.class);
List<Long> taskIds = Opt.ofNullable(data.getStoreId())
.map(storeId -> Db.listObjs(Wrappers.lambdaQuery(Task.class).eq(Task::getStoreId, storeId), Task::getId))
......
package vion.service.impl;
import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.lang.Opt;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.base.MPJBaseServiceImpl;
import io.github.linpeilie.Converter;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import vion.dto.SettlementDiffDTO;
import vion.mapper.SettlementDiffMapper;
import vion.model.Contract;
import vion.model.FileInfo;
import vion.model.SettlementDiff;
import vion.service.IContractPaymentService;
import vion.service.IContractService;
import vion.service.IFileService;
import vion.service.ISettlementDiffService;
import vion.vo.SettlementDiffVO;
import vion.vo.UserVO;
import java.io.File;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
/**
* @author HlQ
* @date 2023/12/25
*/
@Service
@RequiredArgsConstructor
public class SettlementDiffServiceImpl extends MPJBaseServiceImpl<SettlementDiffMapper, SettlementDiff> implements ISettlementDiffService {
private final IContractService contractService;
private final IContractPaymentService contractPaymentService;
private final IFileService fileService;
private final Converter converter;
@Value("${fileUrl:}")
private String fileUrl;
@Override
public Page<SettlementDiffVO> list(String no, SettlementDiffDTO dto) {
Page<SettlementDiff> diffPage = this.lambdaQuery(converter.convert(dto, SettlementDiff.class))
.eq(SettlementDiff::getContractNo, no)
.page(Page.of(dto.getPageNum(), dto.getPageSize()));
List<SettlementDiffVO> voList = converter.convert(diffPage.getRecords(), SettlementDiffVO.class);
return Page.<SettlementDiffVO>of(diffPage.getCurrent(), diffPage.getSize(), diffPage.getTotal()).setRecords(voList);
}
@Override
public SettlementDiffVO getVOById(Long id) {
return converter.convert(this.getById(id), SettlementDiffVO.class);
}
@Override
@Transactional(rollbackFor = Exception.class)
public String save(SettlementDiffDTO dto) {
SettlementDiff settlementDiff = converter.convert(dto, SettlementDiff.class);
if (this.save(settlementDiff)) {
BigDecimal diffAmount = settlementDiff.getSettlementDiff();
// 余额 = 总合同额 - 已收 + 差异
// 应收 = 总合同额 * 比例 + 差异 (冲抵项为应收)
// = (总合同额 + 差异) * 比例 (冲抵项为合同额)
Contract existContract = contractService.lambdaQuery().eq(Contract::getContractNo, settlementDiff.getContractNo()).one();
if (settlementDiff.getOffsetItem() == 1) {
existContract.setTotalAmount(NumberUtil.add(existContract.getTotalAmount(), diffAmount));
Contract contractDto = new Contract();
contractDto.setId(existContract.getId());
contractPaymentService.calMoney(existContract, contractDto);
contractService.updateById(contractDto);
} else if (settlementDiff.getOffsetItem() == 2) {
Contract contractDto = new Contract();
contractDto.setId(existContract.getId());
contractDto.setReceivableAmount(NumberUtil.add(existContract.getReceivableAmount(), diffAmount));
contractDto.setOutstandingAmount(NumberUtil.add(existContract.getOutstandingAmount(), diffAmount));
contractService.updateById(contractDto);
}
Opt.ofNullable(dto.getFiles())
.ifPresent(fileList -> {
UserVO userVO = (UserVO) StpUtil.getTokenSession().get("curLoginUser");
Arrays.stream(fileList).forEach(infile -> {
String orgName = infile.getOriginalFilename();
String mainName = FileUtil.mainName(orgName);
String fileExt = FileUtil.extName(orgName);
String filename = StrUtil.format("{}_{}.{}", mainName, DateUtil.format(new Date(), "yyyyMMdd_HHmmss"), fileExt);;
String path = fileUrl + FileUtil.FILE_SEPARATOR + "settlementDiff" + FileUtil.FILE_SEPARATOR + dto.getContractNo() + 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(0L);
fileInfo.setSourceId(settlementDiff.getId());
fileInfo.setContractId(dto.getContractId());
fileInfo.setSourceType(15);
fileInfo.setName(filename);
fileInfo.setUrl(path);
fileInfo.setType(FileUtil.extName(file));
fileInfo.setSha256(SecureUtil.sha256(file).toUpperCase());
fileInfo.setUploader(userVO.getUsername());
fileService.save(fileInfo);
});
});
return "新增成功";
}
return "新增失败";
}
@Override
@Transactional(rollbackFor = Exception.class)
public String update(Long id, SettlementDiffDTO dto) {
SettlementDiff settlementDiff = converter.convert(dto, SettlementDiff.class);
if (this.updateById(settlementDiff)) {
SettlementDiff existDiff = this.getById(id);
BigDecimal diffAmount = existDiff.getSettlementDiff();
// 余额 = 总合同额 - 已收 + 差异
// 应收 = 总合同额 * 比例 + 差异 (冲抵项为应收)
// = (总合同额 + 差异) * 比例 (冲抵项为合同额)
Contract existContract = contractService.lambdaQuery().eq(Contract::getContractNo, existDiff.getContractNo()).one();
if (existDiff.getOffsetItem() == 1) {
existContract.setTotalAmount(NumberUtil.add(existContract.getTotalAmount(), diffAmount));
Contract contractDto = new Contract();
contractDto.setId(existContract.getId());
contractPaymentService.calMoney(existContract, contractDto);
contractService.updateById(contractDto);
} else if (existDiff.getOffsetItem() == 2) {
Contract contractDto = new Contract();
contractDto.setId(existContract.getId());
contractDto.setReceivableAmount(NumberUtil.add(existContract.getReceivableAmount(), diffAmount));
contractDto.setOutstandingAmount(NumberUtil.add(existContract.getOutstandingAmount(), diffAmount));
contractService.updateById(contractDto);
}
Opt.ofNullable(dto.getFiles())
.ifPresent(fileList -> {
UserVO userVO = (UserVO) StpUtil.getTokenSession().get("curLoginUser");
Arrays.stream(fileList).forEach(infile -> {
String orgName = infile.getOriginalFilename();
String mainName = FileUtil.mainName(orgName);
String fileExt = FileUtil.extName(orgName);
String filename = StrUtil.format("{}_{}.{}", mainName, DateUtil.format(new Date(), "yyyyMMdd_HHmmss"), fileExt);;
String path = fileUrl + FileUtil.FILE_SEPARATOR + "settlementDiff" + FileUtil.FILE_SEPARATOR + dto.getContractNo() + 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(0L);
fileInfo.setSourceId(id);
fileInfo.setContractId(dto.getContractId());
fileInfo.setSourceType(15);
fileInfo.setName(filename);
fileInfo.setUrl(path);
fileInfo.setType(FileUtil.extName(file));
fileInfo.setSha256(SecureUtil.sha256(file).toUpperCase());
fileInfo.setUploader(userVO.getUsername());
fileService.save(fileInfo);
});
});
return "更新成功";
}
return "更新失败";
}
}
package vion.service.impl;
import com.github.yulichang.base.MPJBaseServiceImpl;
import org.springframework.stereotype.Service;
import vion.mapper.StoreLogMapper;
import vion.model.StoreLog;
import vion.service.IStoreLogService;
/**
* @author HlQ
* @date 2023/12/27
*/
@Service
public class StoreLogServiceImpl extends MPJBaseServiceImpl<StoreLogMapper, StoreLog> implements IStoreLogService {
}
......@@ -14,6 +14,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.toolkit.Db;
import com.github.yulichang.base.MPJBaseServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import io.github.linpeilie.Converter;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
......@@ -52,7 +53,7 @@ public class StoreServiceImpl extends MPJBaseServiceImpl<StoreMapper, Store> imp
@Override
public Page<StoreVO> getStoreList(StoreDTO data) {
Store store = converter.convert(data, new Store());
Store store = converter.convert(data, Store.class);
Page<Store> storeList = this.lambdaQuery(store)
.page(Page.of(data.getPageNum(), data.getPageSize()));
// todo 缓存
......@@ -91,7 +92,7 @@ public class StoreServiceImpl extends MPJBaseServiceImpl<StoreMapper, Store> imp
List<StoreVO> storeVOList = new ArrayList<>();
storeList.getRecords().forEach(item -> {
StoreVO storeVO = converter.convert(item, new StoreVO());
StoreVO storeVO = converter.convert(item, StoreVO.class);
storeVO.setAccountName(accountList.stream().filter(v -> v.getId().equals(item.getAccountId())).map(Account::getName).findFirst().orElse("--"));
storeVO.setFileNum(store2CntMap.getOrDefault(item.getId(), 0L));
......@@ -99,7 +100,7 @@ public class StoreServiceImpl extends MPJBaseServiceImpl<StoreMapper, Store> imp
List<RContractStore> contractStores = storeIdMap.get(storeId);
storeVO.setContractCount(Opt.ofEmptyAble(contractStores).map(List::size).orElse(0));
Contract masterContract = id2ContractMap.getOrDefault(item.getMasterContract(), null);
storeVO.setMainContract(Opt.ofNullable(masterContract).map(c -> converter.convert(c, new ContractVO())).orElse(null));
storeVO.setMainContract(Opt.ofNullable(masterContract).map(c -> converter.convert(c, ContractVO.class)).orElse(null));
// 补充服务单
if (store2TaskIdMap.containsKey(item.getId())) {
......@@ -210,4 +211,18 @@ public class StoreServiceImpl extends MPJBaseServiceImpl<StoreMapper, Store> imp
this.updateBatchById(updStoreList);
return "计算成功";
}
@Override
public List<StoreVO> storeScreen() {
MPJLambdaWrapper<Store> wrapper = new MPJLambdaWrapper<Store>()
.select(Store::getTaskDetail, Store::getFinishDate, Store::getPercentage, Store::getStuckPoint, Store::getIsImportant)
.selectCollection(RStoreUser.class, StoreVO::getStoreUserList)
.selectCollection(StoreLog.class, StoreVO::getStoreLog)
.leftJoin(RStoreUser.class, on -> on.eq(RStoreUser::getStoreId, Store::getId).eq(RStoreUser::getIsMain, 1))
.leftJoin(StoreLog.class, StoreLog::getStoreId, Store::getId)
.eq(Store::getIsImportant, 1)
.orderByAsc(Store::getFinishDate)
.orderByDesc(StoreLog::getCreateTime);
return this.selectJoinList(StoreVO.class, wrapper);
}
}
......@@ -87,7 +87,7 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
})
.ifPresent(logs -> taskIdSet.addAll(logs.stream().map(FaultLog::getTaskId).collect(Collectors.toSet())));
MPJLambdaWrapper<Task> wrapper = new MPJLambdaWrapper<>(converter.convert(data, new Task()))
MPJLambdaWrapper<Task> wrapper = new MPJLambdaWrapper<>(converter.convert(data, Task.class))
.selectAll(Task.class)
.selectAs(Store::getName, TaskVO::getStoreName)
.selectAs(Account::getName, TaskVO::getAccountName)
......@@ -139,7 +139,7 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
.set(TaskTemp::getOperator, data.getActiveUser())
.set(TaskTemp::getStoreId, data.getStoreId())
.eq(TaskTemp::getId, data.getTaskTempId())
.update();
.update(new TaskTemp());
}
if (data.getId() == null) {
......@@ -175,6 +175,7 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
faultLog.setStoreId(task.getStoreId());
faultLog.setOperator(user.getId());
faultLog.setRemark(task.getRemark());
faultLog.setManHour(data.getManHour());
if (task.getStatus() == 2) {
faultLog.setContent("工单正在处理中");
}
......
......@@ -52,7 +52,7 @@ public class TaskTempServiceImpl extends MPJBaseServiceImpl<TaskTempMapper, Task
@Override
public Page<TaskTempVO> getTaskTempList(TaskTempDTO data) {
Page<TaskTemp> taskTempPage = this
.lambdaQuery(converter.convert(data, new TaskTemp()))
.lambdaQuery(converter.convert(data, TaskTemp.class))
.between(data.getStartdate() != null && data.getEnddate() != null, TaskTemp::getRepairTime, data.getStartdate(), data.getEnddate())
.page(Page.of(data.getPageNum(), data.getPageSize()));
List<TaskTempVO> taskTempVOList = converter.convert(taskTempPage.getRecords(), TaskTempVO.class);
......
......@@ -39,7 +39,7 @@ public class UserServiceImpl extends MPJBaseServiceImpl<UserMapper, User> implem
@Override
public Page<UserVO> getUserList(UserDTO dto) {
MPJLambdaWrapper<User> wrapper = new MPJLambdaWrapper<>(converter.convert(dto, new User()))
MPJLambdaWrapper<User> wrapper = new MPJLambdaWrapper<>(converter.convert(dto, User.class))
.selectAll(User.class)
.select(Dept::getDeptName)
.leftJoin(Dept.class, Dept::getDeptId, User::getDeptId)
......
......@@ -161,11 +161,9 @@ public class DingMod {
List<Long> deptIdList = ListUtil.toList(1L);
int idx = 0;
while (idx < deptIdList.size()) {
JSONObject paramJson = new JSONObject();
// 2:试用期 3:正式 5:待离职 -1:无状态
Long value = deptIdList.get(idx++);
paramJson.set("dept_id", value);
String res = HttpUtil.post("https://oapi.dingtalk.com/topapi/v2/department/listsub?access_token=" + accessToken, paramJson.toString());
String res = HttpUtil.post("https://oapi.dingtalk.com/topapi/v2/department/listsub?access_token=" + accessToken, JSONUtil.createObj().set("dept_id", value).toString());
JSONObject jsonObject = JSONUtil.parseObj(res);
if (StrUtil.equals("ok", jsonObject.getStr("errmsg"))) {
JSONArray resArr = jsonObject.getJSONArray("result");
......@@ -175,10 +173,10 @@ public class DingMod {
JSONObject jsonObj = JSONUtil.parseObj(o);
Long deptId = jsonObj.getLong("dept_id");
dept.setDeptId(deptId);
deptIdList.add(deptId);
dept.setParentId(jsonObj.getLong("parent_id"));
dept.setDeptName(jsonObj.getStr("name"));
deptService.saveOrUpdate(dept, Wrappers.<Dept>lambdaUpdate().eq(Dept::getDeptId, deptId));
deptIdList.add(deptId);
}
}
}
......@@ -232,7 +230,7 @@ public class DingMod {
}
String userid = useridObj.getJSONObject("result").getStr("userid");
User user = userService.lambdaQuery().select(User::getId, User::getUserid, User::getUsername, User::getPhone, User::getStatus).eq(User::getUserid, userid).one();
UserVO userVO = converter.convert(user, new UserVO());
UserVO userVO = converter.convert(user, UserVO.class);
if (userVO.getStatus() == 1) {
return "该用户禁止登录系统,请联系管理员!";
}
......@@ -262,7 +260,7 @@ public class DingMod {
}
String userid = useridObj.getJSONObject("result").getStr("userid");
User user = userService.lambdaQuery().select(User::getId, User::getUserid, User::getUsername, User::getPhone, User::getStatus).eq(User::getUserid, userid).one();
UserVO userVO = converter.convert(user, new UserVO());
UserVO userVO = converter.convert(user, UserVO.class);
Long id = userVO.getId();
setRolesAndPerms(id, userVO);
......
package vion.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import java.util.Date;
@Getter
@Setter
public class ConstructionTeamVO {
private Long id;
/**
* 施工队名称
*/
private String name;
/**
* 城市
*/
private String city;
@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
package vion.vo;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import java.util.Date;
@Getter
@Setter
public class RContractTeamVO {
private Long id;
/**
* 合同id
*/
private Long contractId;
/** 合同编号 */
private String contractNo;
/** 合同名称 */
private String contractName;
/**
* 施工队id
*/
private Long ctId;
/** 施工队名称 */
private String teamName;
/**
* 负责人
*/
private String principal;
/**
* 电话号码
*/
private String phone;
/**
* 分配日期
*/
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date assignDate;
/**
* 完成日期
*/
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date finishDate;
/**
* 施工状态
*/
private Integer status;
/**
* 申请人
*/
private Integer applicant;
/**
* 申请人名字
*/
@TableField(value = "applicant_name")
private String applicantName;
/**
* 备注
*/
private String remark;
@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
package vion.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import java.math.BigDecimal;
import java.util.Date;
@Getter
@Setter
public class SettlementDiffVO {
private Long id;
/**
* 合同id
*/
private Long contractId;
/**
* 合同号
*/
private String contractNo;
/**
* 差异类型
*/
private Integer diffType;
/**
* 结算差异
*/
private BigDecimal settlementDiff;
/**
* 冲抵项
*/
private Integer offsetItem;
/**
* 操作人
*/
private Long operator;
/**
* 创建时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
}
\ No newline at end of file
......@@ -2,8 +2,11 @@ package vion.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import vion.model.RStoreUser;
import vion.model.StoreLog;
import java.util.Date;
import java.util.List;
@Data
public class StoreVO {
......@@ -39,6 +42,23 @@ public class StoreVO {
private Long fileNum;
/** 维保状态(在保、脱保、--) */
private String maintainStatus;
/** 产品线属性 */
private Integer productLine;
/** 是否重点项目 0:不是 1:是 */
private Integer isImportant;
/** 任务详情 */
private String taskDetail;
/** 预计完成日期 */
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date finishDate;
/** 完成百分比 */
private Double percentage;
/** 当前卡点 */
private String stuckPoint;
private List<RStoreUser> storeUserList;
private List<StoreLog> storeLog;
/**
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!