|
@@ -0,0 +1,178 @@
|
|
|
|
+package com.jeeplus.test.cw.contractRegistration.service;
|
|
|
|
+
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
+import com.jeeplus.core.domain.BaseEntity;
|
|
|
|
+import com.jeeplus.sys.service.dto.UserDTO;
|
|
|
|
+import com.jeeplus.sys.utils.StringUtils;
|
|
|
|
+import com.jeeplus.sys.utils.UserUtils;
|
|
|
|
+import com.jeeplus.test.cw.contractRegistration.domain.ContractInfo;
|
|
|
|
+import com.jeeplus.test.cw.contractRegistration.mapper.ContractInfoMapper;
|
|
|
|
+import com.jeeplus.test.mould.service.SerialnumTplService;
|
|
|
|
+import com.jeeplus.test.oss.domain.WorkAttachment;
|
|
|
|
+import com.jeeplus.test.reimbursement.reimbursementType.domain.ReimbursementTypeInfo;
|
|
|
|
+import com.jeeplus.test.workContract.domain.WorkContractInfo;
|
|
|
|
+import com.jeeplus.test.workContract.service.dto.WorkAttachmentDto;
|
|
|
|
+import com.jeeplus.test.workContract.service.dto.WorkContractInfoDto;
|
|
|
|
+import org.flowable.editor.language.json.converter.util.CollectionUtils;
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
+
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
+import java.util.Date;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.UUID;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * @author: 王强
|
|
|
|
+ * @create: 2022-11-08 10:50
|
|
|
|
+ **/
|
|
|
|
+@Service
|
|
|
|
+public class ContractInfoService {
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private ContractInfoMapper mapper;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private SerialnumTplService serialnumTplService;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 根据id修改status
|
|
|
|
+ */
|
|
|
|
+ public void updateStatusById(ContractInfo info) {
|
|
|
|
+ mapper.updateStatusById(info.getId(), info.getStatus());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public IPage<ContractInfo> list(Page<ContractInfo> page, ContractInfo info, QueryWrapper<ContractInfo> wrapper) {
|
|
|
|
+// LambdaQueryWrapper<ContractInfo> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
+
|
|
|
|
+ //条件查询list
|
|
|
|
+ //1、合同编号
|
|
|
|
+ if (StringUtils.isNotEmpty(info.getContractNo())) {
|
|
|
|
+ wrapper.like("a.contract_no", info.getContractNo());
|
|
|
|
+ }
|
|
|
|
+ //2、合同名称
|
|
|
|
+ if (StringUtils.isNotEmpty(info.getContractName())) {
|
|
|
|
+ wrapper.like("a.contract_name", info.getContractName());
|
|
|
|
+ }
|
|
|
|
+ //3、合同金额(区间)
|
|
|
|
+ String[] contractAmounts = info.getContractAmounts();
|
|
|
|
+ if (contractAmounts != null) {
|
|
|
|
+ if (StringUtils.isNotEmpty(contractAmounts[0])) {
|
|
|
|
+ wrapper.ge("a.contract_amount",contractAmounts[0]);
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isNotEmpty(contractAmounts[1])) {
|
|
|
|
+ wrapper.le("a.contract_amount", contractAmounts[1]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //4、签约时间(区间)
|
|
|
|
+ String[] contractDates = info.getContractDates();
|
|
|
|
+ if (contractDates != null) {
|
|
|
|
+
|
|
|
|
+ wrapper.between("a.signing_date", contractDates[0], contractDates[1]);
|
|
|
|
+ }
|
|
|
|
+ //5、创建人
|
|
|
|
+ if (StringUtils.isNotEmpty(info.getContractName())) {
|
|
|
|
+ wrapper.like("a.contract_name", info.getContractName());
|
|
|
|
+ }
|
|
|
|
+ //6、所属部门
|
|
|
|
+ if (StringUtils.isNotEmpty(info.getDepartment())) {
|
|
|
|
+ wrapper.like("a.department", info.getDepartment());
|
|
|
|
+ }
|
|
|
|
+ //7、状态
|
|
|
|
+ if (StringUtils.isNotEmpty(info.getStatus())) {
|
|
|
|
+ wrapper.like("a.status", info.getStatus());
|
|
|
|
+ }
|
|
|
|
+ //8、归档状态
|
|
|
|
+ if (StringUtils.isNotEmpty(info.getFiledType())) {
|
|
|
|
+ wrapper.like("b.filed_type", info.getFiledType());
|
|
|
|
+ }
|
|
|
|
+ wrapper.eq("a.del_flag","0");
|
|
|
|
+ IPage<ContractInfo> pageList = mapper.findPageList(page, wrapper);
|
|
|
|
+
|
|
|
|
+ return pageList;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 合同登记查询
|
|
|
|
+ */
|
|
|
|
+ public ContractInfo findById(String id) {
|
|
|
|
+
|
|
|
|
+ ContractInfo dto = mapper.findById(id);
|
|
|
|
+ if (dto != null){
|
|
|
|
+ dto.setContractStatus("新创建");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return dto;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public String saveInfo(ContractInfo info) throws Exception {
|
|
|
|
+ if (StringUtils.isNotEmpty(info.getId())) {
|
|
|
|
+ ContractInfo contractInfo = mapper.selectById(info.getId());
|
|
|
|
+ if (contractInfo != null) {
|
|
|
|
+ info.setCreateBy(info.getCreateId());
|
|
|
|
+ return update(info);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return add(info);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 合同登记删除
|
|
|
|
+ */
|
|
|
|
+ public String removeById(String id) {
|
|
|
|
+ mapper.deleteById(id);
|
|
|
|
+ // 附件删除
|
|
|
|
+ return "删除完成!";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 合同登记修改
|
|
|
|
+ */
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ public String update(ContractInfo info) throws Exception{
|
|
|
|
+ //获取当前登录人信息
|
|
|
|
+ UserDTO userDTO = UserUtils.getCurrentUserDTO();
|
|
|
|
+ //合同编号生成
|
|
|
|
+// String serialNum = serialnumTplService.genSerialNum(userDTO.getCompanyDTO().getId(), WorkContractInfoDto.BIZ_CODE);
|
|
|
|
+ ContractInfo contractInfo = new ContractInfo();
|
|
|
|
+ BeanUtils.copyProperties(info, contractInfo);
|
|
|
|
+// info.setNo(serialNum);
|
|
|
|
+ contractInfo.setUpdateBy(userDTO.getId());
|
|
|
|
+ contractInfo.setUpdateDate(new Date());
|
|
|
|
+ int num = Integer.parseInt(contractInfo.getChangeNum()) + 1;
|
|
|
|
+ contractInfo.setChangeNum(num + "");
|
|
|
|
+ mapper.updateById(contractInfo);
|
|
|
|
+
|
|
|
|
+ return info.getId();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 合同登记新增
|
|
|
|
+ */
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ public String add(ContractInfo contractInfo) throws Exception{
|
|
|
|
+ //获取当前登录人信息
|
|
|
|
+ UserDTO userDTO = UserUtils.getCurrentUserDTO();
|
|
|
|
+ //合同编号生成
|
|
|
|
+ String serialNum = serialnumTplService.genSerialNum(userDTO.getCompanyDTO().getId(), ContractInfo.BIZ_CODE);
|
|
|
|
+ String id = UUID.randomUUID().toString().replace("-", "");
|
|
|
|
+ ContractInfo info = new ContractInfo();
|
|
|
|
+ BeanUtils.copyProperties(contractInfo, info);
|
|
|
|
+ info.setId(id);
|
|
|
|
+// info.setNo(serialNum);
|
|
|
|
+ info.setContractNo(serialNum);
|
|
|
|
+ info.setCreateBy(userDTO.getId());
|
|
|
|
+ info.setCreateDate(new Date());
|
|
|
|
+ info.setUpdateBy(userDTO.getId());
|
|
|
|
+
|
|
|
|
+ info.setUpdateDate(new Date());
|
|
|
|
+ mapper.insert(info);
|
|
|
|
+
|
|
|
|
+ return id;
|
|
|
|
+ }
|
|
|
|
+}
|