1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
package pwc.taxtech.atms.service.impl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.dao.ProjectStatusManageMapper;
import pwc.taxtech.atms.dto.FieldsMapper;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.taxadmin.ProjectImportSubStatusDto;
import pwc.taxtech.atms.dto.taxadmin.ProjectStatusManageDto;
import pwc.taxtech.atms.entity.ProjectStatusManage;
import pwc.taxtech.atms.entity.ProjectStatusManageExample;
import pwc.taxtech.atms.service.ProjectStatusManageService;
import java.util.Date;
import java.util.List;
import java.util.UUID;
@Service
public class ProjectStatusManageServiceImpl implements ProjectStatusManageService {
private static final int FIRST_OR_DFAULT = 0;
private static Logger LOGGER = LoggerFactory.getLogger(ProjectStatusManageServiceImpl.class);
@Autowired
ProjectStatusManageMapper projectStatusManageMapper;
@Override
public OperationResultDto<ProjectStatusManageDto> setProjectStatus(String projectId, Integer periodId, Integer status, String creatorId) {
try {
ProjectStatusManageExample example = new ProjectStatusManageExample();
example.createCriteria().andProjectIdEqualTo(projectId).andPeriodIdEqualTo(periodId);
List<ProjectStatusManage> psmList = projectStatusManageMapper.selectByExample(example);
ProjectStatusManage psm = null;
if (psmList != null && !psmList.isEmpty()) {
psm = psmList.get(FIRST_OR_DFAULT);
psm.setStatus(status);
psm.setUpdateTime(new Date());
projectStatusManageMapper.updateByPrimaryKey(psm);
} else {
psm = new ProjectStatusManage();
psm.setId(UUID.randomUUID().toString());
psm.setProjectId(projectId);
psm.setPeriodId(periodId);
psm.setStatus(status);
psm.setCreatorId(creatorId);
psm.setCreateTime(new Date());
psm.setUpdateTime(new Date());
projectStatusManageMapper.insert(psm);
}
OperationResultDto<ProjectStatusManageDto> ord = new OperationResultDto<>();
ord.setResult(true);
ord.setResultMsg("");
ProjectStatusManageDto dto = new ProjectStatusManageDto();
try {
FieldsMapper.map(psm, dto);
} catch (Exception e) {
e.printStackTrace();
LOGGER.warn("cast filed some error", e);
}
ord.setData(dto);
return ord;
} catch (Exception e) {
LOGGER.error("ProjectStatusManageService,SetProjectStatus(string dbName, int periodId)发生错误: {}", e.getMessage());
OperationResultDto<ProjectStatusManageDto> ord = new OperationResultDto<>();
ord.setResult(false);
ord.setResultMsg(e.getMessage());
ord.setData(null);
return ord;
}
}
@Override
public OperationResultDto<ProjectStatusManageDto> getProjectStatus(String projectId, Integer periodId) {
try {
ProjectStatusManageExample example = new ProjectStatusManageExample();
example.createCriteria().andPeriodIdEqualTo(periodId);
List<ProjectStatusManage> psmList = projectStatusManageMapper.selectByExample(example);
if (psmList != null && !psmList.isEmpty()) {
ProjectStatusManage first = psmList.get(FIRST_OR_DFAULT);
ProjectStatusManageDto dto = new ProjectStatusManageDto();
try {
FieldsMapper.map(first, dto);
} catch (Exception e) {
e.printStackTrace();
LOGGER.warn("field map some error");
}
ProjectImportSubStatusDto ssd = new ProjectImportSubStatusDto();//TODO:should query status from db (neo)
ssd.setAdjustImport(false);
ssd.setCustomInvoiceImport(false);
ssd.setEntryImport(false);
ssd.setErpImport(false);
ssd.setInputInvoiceImport(false);
ssd.setOutputInvoiceImport(false);
ssd.setTbImport(false);
ssd.setVoucherMapImport(false);
dto.setImportSubStatus(ssd);
OperationResultDto resultDto = new OperationResultDto();
resultDto.setResult(true);
resultDto.setResultMsg("");
resultDto.setData(dto);
return resultDto;
} else {
throw new Exception("数据库" + projectId + "状态信息为NULL");
}
} catch (Exception e) {
OperationResultDto resultDto = new OperationResultDto();
resultDto.setResult(false);
resultDto.setResultMsg(e.getMessage());
resultDto.setData(null);
return resultDto;
}
}
}