|
@@ -25,6 +25,7 @@ import java.io.*;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDate;
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
@@ -102,9 +103,14 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
|
|
|
}
|
|
|
List<Contract> contracts = contractMapper.selectContract(user.getCompanyId(), pageStart, pageSize, number, name , typeName , status, startDate,endDate);
|
|
|
List<Contract> total = contractMapper.selectContract(user.getCompanyId(), null, null, number, name, typeName, status, startDate, endDate);
|
|
|
+ //首先获取所有合同的Id
|
|
|
List<Integer> contractCollect = contracts.stream().map(c -> c.getId()).collect(Collectors.toList());
|
|
|
- List<ContractDocument> fileList = contractDocumentMapper.selectList(new QueryWrapper<ContractDocument>().in("contract_id", contractCollect));
|
|
|
- List<String> userCollect = fileList.stream().map(c -> c.getCreatorId()).collect(Collectors.toList());
|
|
|
+ contractCollect.add(-1);
|
|
|
+ //查询所有合同的所有附件
|
|
|
+ List<ContractDocument> fileList = contractDocumentMapper.selectList(new QueryWrapper<ContractDocument>().in("contract_id", contractCollect).eq("is_deleted",0));
|
|
|
+ //获取所有附件的上传者id
|
|
|
+ List<String> userCollect = fileList.stream().map(c -> c.getCreatorId()).distinct().collect(Collectors.toList());
|
|
|
+ userCollect.add("-1");
|
|
|
List<User> userList = userMapper.selectList(new QueryWrapper<User>().in("id", userCollect));
|
|
|
WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
|
|
|
for (ContractDocument contractDocument : fileList) {
|
|
@@ -120,12 +126,25 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
|
|
|
ArrayList<ContractPageVO> contractPageVOS = new ArrayList<>();
|
|
|
for (Contract contract : contracts) {
|
|
|
ContractPageVO contractPageVO = new ContractPageVO();
|
|
|
- contractPageVO.setContract(contract);
|
|
|
+ List<ContractDocument> files = new ArrayList<>();
|
|
|
+ contractPageVO.setId(contract.getId());
|
|
|
+ contractPageVO.setCompanyId(contract.getCompanyId());
|
|
|
+ contractPageVO.setCreatorId(contract.getCreatorId());
|
|
|
+ contractPageVO.setIndate(contract.getIndate());
|
|
|
+ contractPageVO.setNumber(contract.getNumber());
|
|
|
+ contractPageVO.setName(contract.getName());
|
|
|
+ contractPageVO.setStatus(contract.getStatus());
|
|
|
+ contractPageVO.setTypeId(contract.getTypeId());
|
|
|
+ contractPageVO.setTypeName(contract.getTypeName());
|
|
|
+ contractPageVO.setCheckerId(contract.getCheckerId());
|
|
|
+ contractPageVO.setRemarks(contract.getRemarks());
|
|
|
+ contractPageVO.setAmounts(contract.getAmounts());
|
|
|
for (ContractDocument contractDocument : fileList) {
|
|
|
- if (contractDocument.getContractId().equals(contractDocument.getId())){
|
|
|
- contractPageVO.getFiles().add(contractDocument);
|
|
|
+ if (contract.getId().equals(contractDocument.getContractId())){
|
|
|
+ files.add(contractDocument);
|
|
|
}
|
|
|
}
|
|
|
+ contractPageVO.setFiles(files);
|
|
|
contractPageVOS.add(contractPageVO);
|
|
|
}
|
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
@@ -135,6 +154,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
|
|
|
return httpRespMsg;
|
|
|
}catch (NullPointerException e) {
|
|
|
//httpRespMsg.setError("验证失败");
|
|
|
+ System.err.println(e);
|
|
|
httpRespMsg.setError(MessageUtils.message("access.verificationError"));
|
|
|
return httpRespMsg;
|
|
|
}
|
|
@@ -157,7 +177,8 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
|
|
|
User user = userMapper.selectById(request.getHeader("token"));
|
|
|
WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
|
|
|
HttpRespMsg contractPage = getContractPage(request, null, null, number, name, typeName, status, startDate, endDate);
|
|
|
- List<Contract> data = (List<Contract>) contractPage.data;
|
|
|
+ HashMap<String, Object> resultDate = (HashMap<String, Object>) contractPage.data;
|
|
|
+ List<ContractPageVO> data = (List<ContractPageVO>)resultDate.get("data");
|
|
|
List<String> headList = new ArrayList<String>();
|
|
|
// headList.add("合同编号");
|
|
|
// headList.add("合同名称");
|
|
@@ -175,7 +196,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
|
|
|
headList.add(MessageUtils.message("leave.task"));
|
|
|
ArrayList<List<String>> allList = new ArrayList<>();
|
|
|
allList.add(headList);
|
|
|
- for (Contract contract : data) {
|
|
|
+ for (ContractPageVO contract : data) {
|
|
|
ArrayList<String> item = new ArrayList<>();
|
|
|
item.add(contract.getNumber()==null?"":contract.getNumber());
|
|
|
item.add(contract.getName());
|
|
@@ -248,6 +269,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
|
|
|
contract.setCompanyId(user.getCompanyId());
|
|
|
contractMapper.insert(contract);
|
|
|
httpRespMsg.msg = MessageUtils.message("contract.addSuc");
|
|
|
+ httpRespMsg.data = contract.getId();
|
|
|
return httpRespMsg;
|
|
|
}
|
|
|
|
|
@@ -269,7 +291,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
|
|
|
}
|
|
|
//合同金额不可为负
|
|
|
if (contract.getAmounts()!=null && contract.getAmounts() < 0){
|
|
|
- httpRespMsg.msg = MessageUtils.message("Contract.amountNegative");
|
|
|
+ httpRespMsg.setError(MessageUtils.message("Contract.amountNegative"));
|
|
|
return httpRespMsg;
|
|
|
}
|
|
|
//合同编号不可重复
|
|
@@ -302,7 +324,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
|
|
|
String token = request.getHeader("TOKEN");
|
|
|
User user = userMapper.selectById(token);
|
|
|
WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
|
|
|
- Integer companyId = wxCorpInfo.getCompanyId();
|
|
|
+ Integer companyId = user.getCompanyId();
|
|
|
//然后处理文件
|
|
|
String fileName = multipartFile.getOriginalFilename();
|
|
|
File file = new File(fileName == null ? "file" : fileName);
|
|
@@ -333,11 +355,12 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
|
|
|
List<Contract> contractList = contractMapper.selectList(new QueryWrapper<Contract>().eq("company_id", companyId));
|
|
|
List<ContractType> typeList = contractTypeMapper.selectList(new QueryWrapper<ContractType>().eq("company_id", companyId));
|
|
|
ArrayList<Contract> saveContract = new ArrayList<>();
|
|
|
+ int dataIndex = 1;
|
|
|
for (int rowIndex = 1; rowIndex <= rowNum; rowIndex++) {
|
|
|
int cellIndex = 0;
|
|
|
- int dataIndex = 1;
|
|
|
Row row = sheet.getRow(rowIndex);
|
|
|
if (row == null) {
|
|
|
+ dataIndex++;
|
|
|
continue;
|
|
|
}
|
|
|
if (ExcelUtil.isRowEmpty(row)) {
|
|
@@ -345,24 +368,26 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
|
|
|
}
|
|
|
boolean NoExists = false;
|
|
|
boolean TypeExists = false;
|
|
|
- if (row.getCell(cellIndex) != null) {
|
|
|
- row.getCell(cellIndex).setCellType(CellType.STRING);
|
|
|
+ for (int i = 0; i < 5; i++) {
|
|
|
+ if (row.getCell(i) != null) {
|
|
|
+ row.getCell(i).setCellType(CellType.STRING);
|
|
|
+ }
|
|
|
}
|
|
|
if (row.getCell(1) == null) {
|
|
|
//msg.setError("第"+dataIndex+"行缺少合同名称");
|
|
|
- msg.setError(MessageUtils.message("",dataIndex));
|
|
|
+ msg.setError(MessageUtils.message("Contract.nameNullError",dataIndex));
|
|
|
return msg;
|
|
|
}
|
|
|
- String No = row.getCell(0).getStringCellValue().trim();
|
|
|
- String name = row.getCell(1).getStringCellValue().trim();
|
|
|
- String amounts = row.getCell(2).getStringCellValue().trim();
|
|
|
- String type = row.getCell(3).getStringCellValue().trim();
|
|
|
- String remarks = row.getCell(3).getStringCellValue().trim();
|
|
|
+ String No = row.getCell(0)==null?null:row.getCell(0).getStringCellValue();
|
|
|
+ String name = row.getCell(1)==null?null:row.getCell(1).getStringCellValue();
|
|
|
+ String amounts = row.getCell(2)==null?null:row.getCell(2).getStringCellValue();
|
|
|
+ String type = row.getCell(3)==null?null:row.getCell(3).getStringCellValue();
|
|
|
+ String remarks = row.getCell(4)==null?null:row.getCell(4).getStringCellValue();
|
|
|
Contract item = new Contract();
|
|
|
//检查合同编号是否存在
|
|
|
if (StringUtils.isNotBlank(No)){
|
|
|
for (Contract contract : contractList) {
|
|
|
- if (contract.getNumber().equals(No)){
|
|
|
+ if (No.equals(contract.getNumber())){
|
|
|
NoExists = true;
|
|
|
break;
|
|
|
}
|
|
@@ -375,17 +400,19 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
|
|
|
for (int i = 0; i < saveContract.size(); i++) {
|
|
|
if (saveContract.get(i).getNumber().equals(No)){
|
|
|
//msg.setError("第"+dataIndex+"行合同编号与第"第"+dataIndex+"行合同编号重复);
|
|
|
- msg.setError(MessageUtils.message("Contract.NoRepeat",dataIndex,i+1));
|
|
|
+ msg.setError(MessageUtils.message("Contract.NoRepeat",i+1,dataIndex));
|
|
|
return msg;
|
|
|
}
|
|
|
}
|
|
|
- item.setNumber(No);
|
|
|
+ item.setNumber(No.trim());
|
|
|
}
|
|
|
- //检查类型名称是否存在
|
|
|
+ //检查合同类型是否存在
|
|
|
+ Integer typeId = null;
|
|
|
if (StringUtils.isNotBlank(type)){
|
|
|
for (ContractType contractType : typeList) {
|
|
|
if (contractType.getTypeName().equals(type)){
|
|
|
TypeExists = true;
|
|
|
+ typeId = contractType.getId();
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -394,15 +421,25 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
|
|
|
msg.setError(MessageUtils.message("Contract.typeExists",dataIndex));
|
|
|
return msg;
|
|
|
}
|
|
|
- item.setName(name);
|
|
|
+ item.setTypeId(typeId);
|
|
|
}
|
|
|
+ item.setName(name.trim());
|
|
|
item.setCompanyId(companyId);
|
|
|
item.setCreatorId(user.getId());
|
|
|
item.setIndate(LocalDate.now());
|
|
|
item.setStatus(3);
|
|
|
- item.setAmounts(Integer.parseInt(amounts));
|
|
|
- item.setRemarks(remarks);
|
|
|
+ if (Double.parseDouble(amounts) <= 0 ){
|
|
|
+ //第{0}行金额不可为负数
|
|
|
+ msg.setError(MessageUtils.message("Contract.amountNegativeByCell",dataIndex));
|
|
|
+ return msg;
|
|
|
+ }else if (StringUtils.isNotBlank(amounts)){
|
|
|
+ item.setAmounts(Double.parseDouble(amounts));
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(remarks)){
|
|
|
+ item.setRemarks(remarks.trim());
|
|
|
+ }
|
|
|
saveContract.add(item);
|
|
|
+ dataIndex++;
|
|
|
}
|
|
|
if(saveContract.size()>0){
|
|
|
int i = 0;
|