|
@@ -76,7 +76,8 @@ public class ContractService extends ServiceImpl<ContractsMapper, Contracts> {
|
|
|
* @description 保存项目信息
|
|
|
* @date 2020/1/14 4:30 下午
|
|
|
*/
|
|
|
- public Project saveProject(Contracts contracts, ContractsExtend extend, Project project) {
|
|
|
+ public Project saveProject(Contracts contracts, ContractsExtend extend) {
|
|
|
+ Project project = new Project();
|
|
|
project.setProjectName(extend.getProjectName());
|
|
|
project.setAddress(extend.getProjectAddress());
|
|
|
project.setNum(contracts.getLiftNum());
|
|
@@ -95,20 +96,22 @@ public class ContractService extends ServiceImpl<ContractsMapper, Contracts> {
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public RestResponse add(ContractsExtend extend) {
|
|
|
Contracts contracts = extend.getContracts();
|
|
|
- Project project = new Project();
|
|
|
- contracts.setProjectId(project.getId());
|
|
|
- if (ObjectUtil.isEmpty(extend.getProjectId())) {
|
|
|
+ Long projectId = extend.getProjectId();
|
|
|
+ Project info;
|
|
|
+ if (ObjectUtil.isEmpty(projectId)) {
|
|
|
//插入项目信息
|
|
|
- Project info = saveProject(contracts, extend, project);
|
|
|
+ info = saveProject(contracts, extend);
|
|
|
if (ObjectUtil.isEmpty(info)) {
|
|
|
return RestResponse.fail(MessageUtils.get("msg.add.fail"));
|
|
|
}
|
|
|
+ contracts.setProjectId(info.getId());
|
|
|
}
|
|
|
if (ObjectUtil.isEmpty(contracts.getCode())) {
|
|
|
//按当前日期时间戳自动生成合同编号
|
|
|
String contractCode = DateUtils.generateCode();
|
|
|
contracts.setCode("HT" + contractCode);
|
|
|
}
|
|
|
+ contracts.setProjectId(projectId);
|
|
|
//插入合同信息
|
|
|
int result = contractsMapper.insert(contracts);
|
|
|
if (result < 0) {
|