SysIfpugService.java 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050
  1. package com.idea.ifpug.service;
  2. import cn.hutool.core.bean.BeanUtil;
  3. import cn.hutool.core.util.ReflectUtil;
  4. import cn.hutool.crypto.SecureUtil;
  5. import cn.hutool.json.JSONArray;
  6. import cn.hutool.json.JSONObject;
  7. import com.alibaba.excel.ExcelWriter;
  8. import cn.hutool.poi.excel.ExcelReader;
  9. import cn.hutool.poi.excel.ExcelUtil;
  10. import com.alibaba.excel.write.metadata.WriteSheet;
  11. import com.alibaba.excel.write.metadata.fill.FillConfig;
  12. import com.github.pagehelper.PageInfo;
  13. import com.idea.ifpug.excel.TestExcel;
  14. import com.idea.ifpug.model.*;
  15. import com.idea.ifpug.utils.IfpugDataUtils;
  16. import com.idea.ifpug.vo.ExcelResultModel;
  17. import com.rockstar.common.conf.V2Config;
  18. import com.rockstar.frame.model.extend.DateTrans;
  19. import com.rockstar.frame.model.extend.Tablepar;
  20. import com.rockstar.util.StringUtils;
  21. import org.springframework.beans.factory.annotation.Autowired;
  22. import org.springframework.stereotype.Service;
  23. import org.springframework.web.multipart.MultipartFile;
  24. import javax.servlet.http.HttpServletResponse;
  25. import java.io.IOException;
  26. import java.io.InputStream;
  27. import java.io.OutputStream;
  28. import java.math.BigDecimal;
  29. import java.util.*;
  30. @Service
  31. public class SysIfpugService {
  32. @Autowired
  33. private SysIfpugResultService resultService;
  34. @Autowired
  35. private SysIfpugTcfService tcfService;
  36. @Autowired
  37. private SysIfpugFpsService fpsService;
  38. @Autowired
  39. private SysIfpugIlfsService ilfsService;
  40. @Autowired
  41. private SysIfpugEifsService eifsService;
  42. @Autowired
  43. private SysIfpugEisService eisService;
  44. @Autowired
  45. private SysIfpugEosService eosService;
  46. @Autowired
  47. private SysIfpugEqsService eqsService;
  48. public PageInfo<SysIfpugResult> historyList(Tablepar tablepar, SysIfpugResult model, DateTrans dt) {
  49. return resultService.list(tablepar, model, dt);
  50. }
  51. public Object getResultDesc(String id) {
  52. Map<String, Object> resultMap = new HashMap<>();
  53. SysIfpugResult result = resultService.selectByPrimaryKey(id);
  54. resultMap.put("result", result);
  55. // TCF
  56. SysIfpugTcfExample tcfExample = new SysIfpugTcfExample();
  57. tcfExample.createCriteria().andResultIdEqualTo(id);
  58. List<SysIfpugTcf> tcfList = tcfService.selectByExample(tcfExample);
  59. resultMap.put("tcf", tcfList.size()>0?tcfList.get(0):null);
  60. // FPS
  61. SysIfpugFpsExample fpsExample = new SysIfpugFpsExample();
  62. fpsExample.setOrderByClause("sort asc");
  63. fpsExample.createCriteria().andResultIdEqualTo(id);
  64. List<SysIfpugFps> fpsList = fpsService.selectByExample(fpsExample);
  65. resultMap.put("fps", fpsList);
  66. // ILFS
  67. SysIfpugIlfsExample ilfsExample = new SysIfpugIlfsExample();
  68. ilfsExample.createCriteria().andResultIdEqualTo(id);
  69. List<SysIfpugIlfs> ilfsList = ilfsService.selectByExample(ilfsExample);
  70. resultMap.put("ilfs", ilfsList);
  71. // EIFS
  72. SysIfpugEifsExample eifsExample = new SysIfpugEifsExample();
  73. eifsExample.createCriteria().andResultIdEqualTo(id);
  74. List<SysIfpugEifs> eifsList = eifsService.selectByExample(eifsExample);
  75. resultMap.put("eifs", eifsList);
  76. // EIS
  77. SysIfpugEisExample eisExample = new SysIfpugEisExample();
  78. eisExample.createCriteria().andResultIdEqualTo(id);
  79. List<SysIfpugEis> eisList = eisService.selectByExample(eisExample);
  80. resultMap.put("eis", eisList);
  81. // EOS
  82. SysIfpugEosExample eosExample = new SysIfpugEosExample();
  83. eosExample.createCriteria().andResultIdEqualTo(id);
  84. List<SysIfpugEos> eosList = eosService.selectByExample(eosExample);
  85. resultMap.put("eos", eosList);
  86. // EQS
  87. SysIfpugEqsExample eqsExample = new SysIfpugEqsExample();
  88. eqsExample.createCriteria().andResultIdEqualTo(id);
  89. List<SysIfpugEqs> eqsList = eqsService.selectByExample(eqsExample);
  90. resultMap.put("eqs", eqsList);
  91. return resultMap;
  92. }
  93. public void saveResult(JSONObject json){
  94. SysIfpugResult record = new SysIfpugResult();
  95. JSONObject info = json.getJSONObject("info");
  96. record.setId(info.getStr("id"));
  97. record.setProjectDesc(info.getStr("projectDesc"));
  98. record.setCustomerName(info.getStr("customerName"));
  99. record.setProjectName(info.getStr("projectName"));
  100. record.setProjectCode(info.getStr("projectCode"));
  101. record.setCalculateUser(info.getStr("calculateUser"));
  102. record.setCalculateDate(info.getDate("calculateDate"));
  103. JSONArray array = json.getJSONArray("list");
  104. for (JSONObject jsonObject : array.toArray(new JSONObject[]{})) {
  105. String title = jsonObject.getStr("param");
  106. String value = jsonObject.getStr("value");
  107. if("未调整功能点计数(UFC)".equals(title)){
  108. record.setUfc(value);
  109. }else if("技术复杂度因子(TCF)".equals(title)){
  110. record.setTcf(value);
  111. }else if("调整后功能点计数(AFP)".equals(title)){
  112. record.setAfp(value);
  113. }else if("项目生产率(PE)".equals(title)){
  114. record.setPe(value);
  115. }else if("项目所需工时".equals(title)){
  116. record.setWorkTime(value);
  117. }else if("工时价格".equals(title)){
  118. record.setWorkPrice(new BigDecimal(value));
  119. }else if("项目成本".equals(title)){
  120. record.setProjectCost(new BigDecimal(value));
  121. }
  122. }
  123. record.setCreateTime(new Date());
  124. resultService.insertSelective(record);
  125. }
  126. public SysIfpugResult getResult(String id){
  127. return resultService.selectByPrimaryKey(id);
  128. }
  129. public void saveTcf(SysIfpugTcf result){
  130. tcfService.insertSelective(result);
  131. }
  132. public SysIfpugTcf getTcf(String id){
  133. return tcfService.selectByPrimaryKey(id);
  134. }
  135. public void saveFps(JSONObject json){
  136. String resultId = json.getStr("id");
  137. JSONArray array = json.getJSONArray("list");
  138. // for (JSONObject jsonObject : array.toList(JSONObject.class)) {
  139. for (JSONObject jsonObject : array.toArray(new JSONObject[]{})) {
  140. SysIfpugFps fps = new SysIfpugFps();
  141. fps.setResultId(resultId);
  142. fps.setFpType(jsonObject.getStr("fpType"));
  143. fps.setCommplex(jsonObject.getStr("commplex"));
  144. fps.setNum(jsonObject.getStr("num"));
  145. fps.setWeights(jsonObject.getStr("weights"));
  146. fps.setFps(jsonObject.getStr("fps"));
  147. fps.setFp(jsonObject.getStr("fp"));
  148. fpsService.insertSelective(fps);
  149. }
  150. }
  151. public SysIfpugFps getFps(String id){
  152. return fpsService.selectByPrimaryKey(id);
  153. }
  154. public void saveIlfs(JSONObject json){
  155. String resultId = json.getStr("id");
  156. JSONArray array = json.getJSONArray("list");
  157. for (JSONObject jsonObject : array.toArray(new JSONObject[]{})) {
  158. SysIfpugIlfs sysIfpugIlfs = jsonObject.toBean(SysIfpugIlfs.class);
  159. sysIfpugIlfs.setResultId(resultId);
  160. ilfsService.insertSelective(sysIfpugIlfs);
  161. }
  162. // for (SysIfpugIlfs sysIfpugIlfs : array.toList(SysIfpugIlfs.class)) {
  163. // sysIfpugIlfs.setResultId(resultId);
  164. // ilfsService.insertSelective(sysIfpugIlfs);
  165. // }
  166. }
  167. public SysIfpugIlfs getIlfs(String id){
  168. return ilfsService.selectByPrimaryKey(id);
  169. }
  170. public void saveEifs(JSONObject json){
  171. String resultId = json.getStr("id");
  172. JSONArray array = json.getJSONArray("list");
  173. // for (SysIfpugEifs sysIfpugEifs : array.toList(SysIfpugEifs.class)) {
  174. for (JSONObject jsonObject : array.toArray(new JSONObject[]{})) {
  175. SysIfpugEifs sysIfpugEifs = jsonObject.toBean(SysIfpugEifs.class);
  176. sysIfpugEifs.setResultId(resultId);
  177. eifsService.insertSelective(sysIfpugEifs);
  178. }
  179. }
  180. public SysIfpugEifs getEifs(String id){
  181. return eifsService.selectByPrimaryKey(id);
  182. }
  183. public void saveEis(JSONObject json){
  184. String resultId = json.getStr("id");
  185. JSONArray array = json.getJSONArray("list");
  186. // for (SysIfpugEis sysIfpugEifs : array.toList(SysIfpugEis.class)) {
  187. for (JSONObject jsonObject : array.toArray(new JSONObject[]{})) {
  188. SysIfpugEis sysIfpugEifs = jsonObject.toBean(SysIfpugEis.class);
  189. sysIfpugEifs.setResultId(resultId);
  190. eisService.insertSelective(sysIfpugEifs);
  191. }
  192. }
  193. public SysIfpugEis getEis(String id){
  194. return eisService.selectByPrimaryKey(id);
  195. }
  196. public void saveEos(JSONObject json){
  197. String resultId = json.getStr("id");
  198. JSONArray array = json.getJSONArray("list");
  199. // for (SysIfpugEos sysIfpugEos : array.toList(SysIfpugEos.class)) {
  200. for (JSONObject jsonObject : array.toArray(new JSONObject[]{})) {
  201. SysIfpugEos sysIfpugEos = jsonObject.toBean(SysIfpugEos.class);
  202. sysIfpugEos.setResultId(resultId);
  203. eosService.insertSelective(sysIfpugEos);
  204. }
  205. }
  206. public SysIfpugEos getEos(String id){
  207. return eosService.selectByPrimaryKey(id);
  208. }
  209. public void saveEqs(JSONObject json){
  210. String resultId = json.getStr("id");
  211. JSONArray array = json.getJSONArray("list");
  212. // for (SysIfpugEqs sysIfpugEqs : array.toList(SysIfpugEqs.class)) {
  213. for (JSONObject jsonObject : array.toArray(new JSONObject[]{})) {
  214. SysIfpugEqs sysIfpugEqs = jsonObject.toBean(SysIfpugEqs.class);
  215. sysIfpugEqs.setResultId(resultId);
  216. eqsService.insertSelective(sysIfpugEqs);
  217. }
  218. }
  219. public SysIfpugEqs getEqs(String id){
  220. return eqsService.selectByPrimaryKey(id);
  221. }
  222. private List<List<Object>> readFile(MultipartFile file) throws IOException{
  223. ExcelReader reader = ExcelUtil.getReader(file.getInputStream());
  224. List<List<Object>> readAll = reader.read();
  225. return readAll;
  226. }
  227. // 读取ILFS文件
  228. public List<SysIfpugIlfs> readIlfsFile(MultipartFile file) throws IOException {
  229. List<List<Object>> readAll = readFile(file);
  230. List<SysIfpugIlfs> ifpugList = new ArrayList<>();
  231. for (int i = 0; i < readAll.size(); i++) {
  232. if(i < 4)
  233. continue;
  234. SysIfpugIlfs ilfs = new SysIfpugIlfs();
  235. ilfs.setFileName(readAll.get(i).get(1).toString());
  236. ilfs.setDet(readAll.get(i).get(2).toString());
  237. ilfs.setRet(readAll.get(i).get(3).toString());
  238. ilfs.setDi(readAll.get(i).get(4).toString());
  239. ilfs.setZhong(readAll.get(i).get(5).toString());
  240. ilfs.setGao(readAll.get(i).get(6).toString());
  241. ilfs.setRemark(readAll.get(i).get(7).toString());
  242. ifpugList.add(ilfs);
  243. }
  244. return ifpugList;
  245. }
  246. // 读取EIFS文件
  247. public List<SysIfpugEifs> readEifsFile(MultipartFile file) throws IOException {
  248. List<List<Object>> readAll = readFile(file);
  249. List<SysIfpugEifs> ifpugList = new ArrayList<>();
  250. for (int i = 0; i < readAll.size(); i++) {
  251. if(i < 4)
  252. continue;
  253. SysIfpugEifs eifs = new SysIfpugEifs();
  254. eifs.setFileName(readAll.get(i).get(1).toString());
  255. eifs.setDet(readAll.get(i).get(2).toString());
  256. eifs.setRet(readAll.get(i).get(3).toString());
  257. eifs.setDi(readAll.get(i).get(4).toString());
  258. eifs.setZhong(readAll.get(i).get(5).toString());
  259. eifs.setGao(readAll.get(i).get(6).toString());
  260. eifs.setRemark(readAll.get(i).get(7).toString());
  261. ifpugList.add(eifs);
  262. }
  263. return ifpugList;
  264. }
  265. // 读取EIS文件
  266. public List<SysIfpugEis> readEisFile(MultipartFile file) throws IOException {
  267. List<List<Object>> readAll = readFile(file);
  268. List<SysIfpugEis> ifpugList = new ArrayList<>();
  269. for (int i = 0; i < readAll.size(); i++) {
  270. if(i < 4)
  271. continue;
  272. SysIfpugEis eis = new SysIfpugEis();
  273. eis.setInputName(readAll.get(i).get(1).toString());
  274. eis.setDet(readAll.get(i).get(2).toString());
  275. eis.setFtr(readAll.get(i).get(3).toString());
  276. eis.setDi(readAll.get(i).get(4).toString());
  277. eis.setZhong(readAll.get(i).get(5).toString());
  278. eis.setGao(readAll.get(i).get(6).toString());
  279. eis.setRemark(readAll.get(i).get(7).toString());
  280. ifpugList.add(eis);
  281. }
  282. return ifpugList;
  283. }
  284. // 读取EOS文件
  285. public List<SysIfpugEos> readEosFile(MultipartFile file) throws IOException {
  286. List<List<Object>> readAll = readFile(file);
  287. List<SysIfpugEos> ifpugList = new ArrayList<>();
  288. for (int i = 0; i < readAll.size(); i++) {
  289. if(i < 4)
  290. continue;
  291. SysIfpugEos eos = new SysIfpugEos();
  292. eos.setOutputName(readAll.get(i).get(1).toString());
  293. eos.setDet(readAll.get(i).get(2).toString());
  294. eos.setFtr(readAll.get(i).get(3).toString());
  295. eos.setDi(readAll.get(i).get(4).toString());
  296. eos.setZhong(readAll.get(i).get(5).toString());
  297. eos.setGao(readAll.get(i).get(6).toString());
  298. eos.setRemark(readAll.get(i).get(7).toString());
  299. ifpugList.add(eos);
  300. }
  301. return ifpugList;
  302. }
  303. // 读取EQS文件
  304. public List<SysIfpugEqs> readEqsFile(MultipartFile file) throws IOException {
  305. List<List<Object>> readAll = readFile(file);
  306. List<SysIfpugEqs> ifpugList = new ArrayList<>();
  307. for (int i = 0; i < readAll.size(); i++) {
  308. if(i < 4)
  309. continue;
  310. SysIfpugEqs eqs = new SysIfpugEqs();
  311. eqs.setSeachName(readAll.get(i).get(1).toString());
  312. eqs.setInputDet(readAll.get(i).get(2).toString());
  313. eqs.setInputFtr(readAll.get(i).get(3).toString());
  314. eqs.setInputFzd(readAll.get(i).get(4).toString());
  315. eqs.setOutputDet(readAll.get(i).get(5).toString());
  316. eqs.setOutputFtr(readAll.get(i).get(6).toString());
  317. eqs.setOutputFzd(readAll.get(i).get(7).toString());
  318. eqs.setDi(readAll.get(i).get(8).toString());
  319. eqs.setZhong(readAll.get(i).get(9).toString());
  320. eqs.setGao(readAll.get(i).get(10).toString());
  321. eqs.setRemark(readAll.get(i).get(11).toString());
  322. ifpugList.add(eqs);
  323. }
  324. return ifpugList;
  325. }
  326. // 结果导出
  327. public void resultDownload(String resultId, OutputStream out) throws Exception {
  328. TestExcel excelUtils = new TestExcel();
  329. String template = V2Config.getProfile()+"Template/excelTemplate.xlsx";
  330. ExcelWriter excelWriter = excelUtils.getExcelWriter(out, template);
  331. {
  332. // 核算结果
  333. WriteSheet resultSheet = excelUtils.getWriteSheet(0, "核算结果");
  334. SysIfpugResult result = resultService.selectByPrimaryKey(resultId);
  335. Map<String, Object> resultMap = BeanUtil.beanToMap(result);
  336. excelWriter.fill(resultMap, resultSheet);
  337. FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
  338. excelWriter.fill(new ArrayList<Object>(), fillConfig, resultSheet);
  339. }
  340. {
  341. // TCF
  342. SysIfpugTcfExample tcfExample = new SysIfpugTcfExample();
  343. tcfExample.createCriteria().andResultIdEqualTo(resultId);
  344. List<SysIfpugTcf> tcfList = tcfService.selectByExample(tcfExample);
  345. SysIfpugTcf tcf = tcfList.size()>0?tcfList.get(0):new SysIfpugTcf();
  346. WriteSheet tcfSheet = excelUtils.getWriteSheet(1, "TCF");
  347. Map<String, Object> resultMap = BeanUtil.beanToMap(tcf);
  348. excelWriter.fill(resultMap, tcfSheet);
  349. FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
  350. excelWriter.fill(new ArrayList<>(), fillConfig, tcfSheet);
  351. }{
  352. // FPS - TODO 待完善
  353. // SysIfpugFpsExample fpsExample = new SysIfpugFpsExample();
  354. // fpsExample.createCriteria().andResultIdEqualTo(resultId);
  355. // List<SysIfpugFps> tcfList = fpsService.selectByExample(fpsExample);
  356. // SysIfpugFps fps = tcfList.size()>0?tcfList.get(0):new SysIfpugFps();
  357. // WriteSheet tcfSheet = excelUtils.getWriteSheet(2, "FPs");
  358. // Map<String, Object> resultMap = BeanUtil.beanToMap(fps);
  359. // excelWriter.fill(resultMap, tcfSheet);
  360. // FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
  361. // excelWriter.fill(new ArrayList<>(), fillConfig, tcfSheet);
  362. }{
  363. // ILFS
  364. SysIfpugIlfsExample ilfsExample = new SysIfpugIlfsExample();
  365. ilfsExample.createCriteria().andResultIdEqualTo(resultId);
  366. List<SysIfpugIlfs> ilfsList = ilfsService.selectByExample(ilfsExample);
  367. Map<String, Object> ilfsMap = new HashMap<>();
  368. int diCount = 0;
  369. int zhongCount = 0;
  370. int gaoCount = 0;
  371. for (SysIfpugIlfs item : ilfsList) {
  372. diCount += Integer.parseInt(item.getDi());
  373. zhongCount += Integer.parseInt(item.getZhong());
  374. gaoCount += Integer.parseInt(item.getGao());
  375. }
  376. ilfsMap.put("diCount", diCount);
  377. ilfsMap.put("zhongCount", zhongCount);
  378. ilfsMap.put("gaoCount", gaoCount);
  379. WriteSheet ilfsSheet = excelUtils.getWriteSheet(3, "ILFs");
  380. excelWriter.fill(ilfsMap, ilfsSheet);
  381. FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
  382. excelWriter.fill(ilfsList, fillConfig, ilfsSheet);
  383. }{
  384. // EIFS
  385. SysIfpugEifsExample eifsExample = new SysIfpugEifsExample();
  386. eifsExample.createCriteria().andResultIdEqualTo(resultId);
  387. List<SysIfpugEifs> eifsList = eifsService.selectByExample(eifsExample);
  388. Map<String, Object> eifsMap = new HashMap<>();
  389. int diCount = 0;
  390. int zhongCount = 0;
  391. int gaoCount = 0;
  392. for (SysIfpugEifs item : eifsList) {
  393. diCount += Integer.parseInt(item.getDi());
  394. zhongCount += Integer.parseInt(item.getZhong());
  395. gaoCount += Integer.parseInt(item.getGao());
  396. }
  397. eifsMap.put("diCount", diCount);
  398. eifsMap.put("zhongCount", zhongCount);
  399. eifsMap.put("gaoCount", gaoCount);
  400. WriteSheet ilfsSheet = excelUtils.getWriteSheet(3, "EIFs");
  401. excelWriter.fill(eifsMap, ilfsSheet);
  402. FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
  403. excelWriter.fill(eifsList, fillConfig, ilfsSheet);
  404. }{
  405. // EIS
  406. SysIfpugEisExample eisExample = new SysIfpugEisExample();
  407. eisExample.createCriteria().andResultIdEqualTo(resultId);
  408. List<SysIfpugEis> eisList = eisService.selectByExample(eisExample);
  409. Map<String, Object> eisMap = new HashMap<>();
  410. int diCount = 0;
  411. int zhongCount = 0;
  412. int gaoCount = 0;
  413. for (SysIfpugEis item : eisList) {
  414. diCount += Integer.parseInt(item.getDi());
  415. zhongCount += Integer.parseInt(item.getZhong());
  416. gaoCount += Integer.parseInt(item.getGao());
  417. }
  418. eisMap.put("diCount", diCount);
  419. eisMap.put("zhongCount", zhongCount);
  420. eisMap.put("gaoCount", gaoCount);
  421. WriteSheet eisSheet = excelUtils.getWriteSheet(4, "EIs");
  422. excelWriter.fill(eisMap, eisSheet);
  423. FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
  424. excelWriter.fill(eisList, fillConfig, eisSheet);
  425. }{
  426. // EOS
  427. SysIfpugEosExample eosExample = new SysIfpugEosExample();
  428. eosExample.createCriteria().andResultIdEqualTo(resultId);
  429. List<SysIfpugEos> eosList = eosService.selectByExample(eosExample);
  430. Map<String, Object> eosMap = new HashMap<>();
  431. int diCount = 0;
  432. int zhongCount = 0;
  433. int gaoCount = 0;
  434. for (SysIfpugEos item : eosList) {
  435. diCount += Integer.parseInt(item.getDi());
  436. zhongCount += Integer.parseInt(item.getZhong());
  437. gaoCount += Integer.parseInt(item.getGao());
  438. }
  439. eosMap.put("diCount", diCount);
  440. eosMap.put("zhongCount", zhongCount);
  441. eosMap.put("gaoCount", gaoCount);
  442. WriteSheet eosSheet = excelUtils.getWriteSheet(5, "EOs");
  443. excelWriter.fill(eosMap, eosSheet);
  444. FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
  445. excelWriter.fill(eosList, fillConfig, eosSheet);
  446. }{
  447. // EQS
  448. SysIfpugEqsExample eqsExample = new SysIfpugEqsExample();
  449. eqsExample.createCriteria().andResultIdEqualTo(resultId);
  450. List<SysIfpugEqs> eqsList = eqsService.selectByExample(eqsExample);
  451. Map<String, Object> eqsMap = new HashMap<>();
  452. int diCount = 0;
  453. int zhongCount = 0;
  454. int gaoCount = 0;
  455. for (SysIfpugEqs item : eqsList) {
  456. diCount += Integer.parseInt(item.getDi());
  457. zhongCount += Integer.parseInt(item.getZhong());
  458. gaoCount += Integer.parseInt(item.getGao());
  459. }
  460. eqsMap.put("diCount", diCount);
  461. eqsMap.put("zhongCount", zhongCount);
  462. eqsMap.put("gaoCount", gaoCount);
  463. WriteSheet eqsSheet = excelUtils.getWriteSheet(6, "EQs");
  464. excelWriter.fill(eqsMap, eqsSheet);
  465. FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
  466. excelWriter.fill(eqsList, fillConfig, eqsSheet);
  467. }
  468. excelUtils.clse(excelWriter);
  469. }
  470. // init - index
  471. public void initDataIndex(List<Object> dataList){
  472. int indez = 1;
  473. for (Object obj : dataList) {
  474. ReflectUtil.invoke(obj, "setIndex", String.valueOf(indez));
  475. indez++;
  476. }
  477. }
  478. // 页面结果导出
  479. public void resultViewDownload(ExcelResultModel resultModel, OutputStream out) throws Exception {
  480. TestExcel excelUtils = new TestExcel();
  481. String template = V2Config.getProfile()+"Template/excelTemplate.xlsx";
  482. ExcelWriter excelWriter = excelUtils.getExcelWriter(out, template);
  483. {
  484. // 核算结果
  485. WriteSheet resultSheet = excelUtils.getWriteSheet(0, "核算结果");
  486. SysIfpugResult result = resultModel.getResult();
  487. Map<String, Object> resultMap = BeanUtil.beanToMap(result);
  488. excelWriter.fill(resultMap, resultSheet);
  489. FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
  490. excelWriter.fill(new ArrayList<Object>(), fillConfig, resultSheet);
  491. }{
  492. // TCF
  493. SysIfpugTcf tcf = resultModel.getTcf();
  494. WriteSheet tcfSheet = excelUtils.getWriteSheet(1, "TCF");
  495. tcf = initSysIfpugTcf(tcf);
  496. Map<String, Object> resultMap = BeanUtil.beanToMap(tcf);
  497. excelWriter.fill(resultMap, tcfSheet);
  498. FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
  499. excelWriter.fill(new ArrayList<>(), fillConfig, tcfSheet);
  500. }{
  501. // FPS
  502. List<SysIfpugFps> fpsList = resultModel.getFpsList();
  503. int fpsCount = 0;
  504. for (SysIfpugFps sysIfpugFps : fpsList) {
  505. fpsCount += Integer.parseInt(sysIfpugFps.getFps());
  506. }
  507. Map<String, Object> fpsMap = new HashMap<>();
  508. fpsMap.put("fpsCount", fpsCount);
  509. fpsMap.put("fpCount", "100%");
  510. WriteSheet fpsSheet = excelUtils.getWriteSheet(2, "FPs");
  511. excelWriter.fill(fpsMap, fpsSheet);
  512. FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
  513. excelWriter.fill(fpsList, fillConfig, fpsSheet);
  514. }{
  515. // ILFS
  516. List<SysIfpugIlfs> ilfsList = resultModel.getIlfsList();
  517. Map<String, Object> ilfsMap = new HashMap<>();
  518. int diCount = 0;
  519. int zhongCount = 0;
  520. int gaoCount = 0;
  521. int index = 1;
  522. for (SysIfpugIlfs item : ilfsList) {
  523. item.setDi(!StringUtils.isNotEmpty(item.getDi())?"0":item.getDi());
  524. item.setZhong(!StringUtils.isNotEmpty(item.getZhong())?"0":item.getZhong());
  525. item.setGao(!StringUtils.isNotEmpty(item.getGao())?"0":item.getGao());
  526. diCount += Integer.parseInt(item.getDi());
  527. zhongCount += Integer.parseInt(item.getZhong());
  528. gaoCount += Integer.parseInt(item.getGao());
  529. item.setIndex(String.valueOf(index));
  530. index++;
  531. }
  532. ilfsMap.put("diCount", diCount);
  533. ilfsMap.put("zhongCount", zhongCount);
  534. ilfsMap.put("gaoCount", gaoCount);
  535. WriteSheet ilfsSheet = excelUtils.getWriteSheet(3, "ILFs");
  536. excelWriter.fill(ilfsMap, ilfsSheet);
  537. FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
  538. excelWriter.fill(ilfsList, fillConfig, ilfsSheet);
  539. }{
  540. // EIFS
  541. List<SysIfpugEifs> eifsList = resultModel.getEifsList();
  542. Map<String, Object> eifsMap = new HashMap<>();
  543. int diCount = 0;
  544. int zhongCount = 0;
  545. int gaoCount = 0;
  546. int index = 1;
  547. for (SysIfpugEifs item : eifsList) {
  548. item.setDi(!StringUtils.isNotEmpty(item.getDi())?"0":item.getDi());
  549. item.setZhong(!StringUtils.isNotEmpty(item.getZhong())?"0":item.getZhong());
  550. item.setGao(!StringUtils.isNotEmpty(item.getGao())?"0":item.getGao());
  551. diCount += Integer.parseInt(item.getDi());
  552. zhongCount += Integer.parseInt(item.getZhong());
  553. gaoCount += Integer.parseInt(item.getGao());
  554. item.setIndex(String.valueOf(index));
  555. index++;
  556. }
  557. eifsMap.put("diCount", diCount);
  558. eifsMap.put("zhongCount", zhongCount);
  559. eifsMap.put("gaoCount", gaoCount);
  560. WriteSheet ilfsSheet = excelUtils.getWriteSheet(4, "EIFs");
  561. excelWriter.fill(eifsMap, ilfsSheet);
  562. FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
  563. excelWriter.fill(eifsList, fillConfig, ilfsSheet);
  564. }{
  565. // EIS
  566. List<SysIfpugEis> eisList = resultModel.getEisList();
  567. Map<String, Object> eisMap = new HashMap<>();
  568. int diCount = 0;
  569. int zhongCount = 0;
  570. int gaoCount = 0;
  571. int index = 1;
  572. for (SysIfpugEis item : eisList) {
  573. item.setDi(!StringUtils.isNotEmpty(item.getDi())?"0":item.getDi());
  574. item.setZhong(!StringUtils.isNotEmpty(item.getZhong())?"0":item.getZhong());
  575. item.setGao(!StringUtils.isNotEmpty(item.getGao())?"0":item.getGao());
  576. diCount += Integer.parseInt(item.getDi());
  577. zhongCount += Integer.parseInt(item.getZhong());
  578. gaoCount += Integer.parseInt(item.getGao());
  579. item.setIndex(String.valueOf(index));
  580. index++;
  581. }
  582. eisMap.put("diCount", diCount);
  583. eisMap.put("zhongCount", zhongCount);
  584. eisMap.put("gaoCount", gaoCount);
  585. WriteSheet eisSheet = excelUtils.getWriteSheet(5, "EIs");
  586. excelWriter.fill(eisMap, eisSheet);
  587. FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
  588. excelWriter.fill(eisList, fillConfig, eisSheet);
  589. }{
  590. // EOS
  591. List<SysIfpugEos> eosList = resultModel.getEosList();
  592. Map<String, Object> eosMap = new HashMap<>();
  593. int diCount = 0;
  594. int zhongCount = 0;
  595. int gaoCount = 0;
  596. int index = 1;
  597. for (SysIfpugEos item : eosList) {
  598. item.setDi(!StringUtils.isNotEmpty(item.getDi())?"0":item.getDi());
  599. item.setZhong(!StringUtils.isNotEmpty(item.getZhong())?"0":item.getZhong());
  600. item.setGao(!StringUtils.isNotEmpty(item.getGao())?"0":item.getGao());
  601. diCount += Integer.parseInt(item.getDi());
  602. zhongCount += Integer.parseInt(item.getZhong());
  603. gaoCount += Integer.parseInt(item.getGao());
  604. item.setIndex(String.valueOf(index));
  605. index++;
  606. }
  607. eosMap.put("diCount", diCount);
  608. eosMap.put("zhongCount", zhongCount);
  609. eosMap.put("gaoCount", gaoCount);
  610. WriteSheet eosSheet = excelUtils.getWriteSheet(6, "EOs");
  611. excelWriter.fill(eosMap, eosSheet);
  612. FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
  613. excelWriter.fill(eosList, fillConfig, eosSheet);
  614. }{
  615. // EQS
  616. List<SysIfpugEqs> eqsList = resultModel.getEqsList();
  617. Map<String, Object> eqsMap = new HashMap<>();
  618. int diCount = 0;
  619. int zhongCount = 0;
  620. int gaoCount = 0;
  621. int index = 1;
  622. for (SysIfpugEqs item : eqsList) {
  623. item.setDi(!StringUtils.isNotEmpty(item.getDi())?"0":item.getDi());
  624. item.setZhong(!StringUtils.isNotEmpty(item.getZhong())?"0":item.getZhong());
  625. item.setGao(!StringUtils.isNotEmpty(item.getGao())?"0":item.getGao());
  626. diCount += Integer.parseInt(item.getDi());
  627. zhongCount += Integer.parseInt(item.getZhong());
  628. gaoCount += Integer.parseInt(item.getGao());
  629. item.setIndex(String.valueOf(index));
  630. index++;
  631. }
  632. eqsMap.put("diCount", diCount);
  633. eqsMap.put("zhongCount", zhongCount);
  634. eqsMap.put("gaoCount", gaoCount);
  635. WriteSheet eqsSheet = excelUtils.getWriteSheet(7, "EQs");
  636. excelWriter.fill(eqsMap, eqsSheet);
  637. FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
  638. excelWriter.fill(eqsList, fillConfig, eqsSheet);
  639. }{
  640. // 功能点规模计算明细
  641. List<IfpugPointScaleDetailsExcel> detailList = getPointScaleDetail(resultModel.getIlfsList(), resultModel.getEifsList(),
  642. resultModel.getEisList(), resultModel.getEosList(), resultModel.getEqsList());
  643. WriteSheet pointScaleSheet = excelUtils.getWriteSheet(8, "功能点规模计算明细");
  644. // 统计数据
  645. int ilfDetCount = 0, ilfRetCount = 0,
  646. eifDetCount = 0, eifRetCount = 0,
  647. eiDetCount = 0, eiFtrCount = 0,
  648. eoDetCount = 0, eoFtrCount = 0,
  649. eqImputDetCount = 0, eqImputFtrCount = 0, eqoutputDetCount = 0, eqoutputFtrCount = 0;
  650. for (IfpugPointScaleDetailsExcel detailsExcel : detailList) {
  651. ilfDetCount += StringUtils.isNotEmpty(detailsExcel.getIlfDet())?Integer.parseInt(detailsExcel.getIlfDet()):0;
  652. ilfRetCount += StringUtils.isNotEmpty(detailsExcel.getIlfRet())?Integer.parseInt(detailsExcel.getIlfRet()):0;
  653. eifDetCount += StringUtils.isNotEmpty(detailsExcel.getEifDet())?Integer.parseInt(detailsExcel.getEifDet()):0;
  654. eifRetCount += StringUtils.isNotEmpty(detailsExcel.getEifRet())?Integer.parseInt(detailsExcel.getEifRet()):0;
  655. eiDetCount += StringUtils.isNotEmpty(detailsExcel.getEiDet())?Integer.parseInt(detailsExcel.getEiDet()):0;
  656. eiFtrCount += StringUtils.isNotEmpty(detailsExcel.getEiFtr())?Integer.parseInt(detailsExcel.getEiFtr()):0;
  657. eoDetCount += StringUtils.isNotEmpty(detailsExcel.getEoDet())?Integer.parseInt(detailsExcel.getEoDet()):0;
  658. eoFtrCount += StringUtils.isNotEmpty(detailsExcel.getEoFtr())?Integer.parseInt(detailsExcel.getEoFtr()):0;
  659. eqImputDetCount += StringUtils.isNotEmpty(detailsExcel.getEqImputDet())?Integer.parseInt(detailsExcel.getEqImputDet()):0;
  660. eqImputFtrCount += StringUtils.isNotEmpty(detailsExcel.getEqImputFtr())?Integer.parseInt(detailsExcel.getEqImputFtr()):0;
  661. eqoutputDetCount += StringUtils.isNotEmpty(detailsExcel.getEqoutputDet())?Integer.parseInt(detailsExcel.getEqoutputDet()):0;
  662. eqoutputFtrCount += StringUtils.isNotEmpty(detailsExcel.getEqoutputFtr())?Integer.parseInt(detailsExcel.getEqoutputFtr()):0;
  663. }
  664. Map<String, Object> pointScaleMap = new HashMap<>();
  665. pointScaleMap.put("ilfDetCount", ilfDetCount);
  666. pointScaleMap.put("ilfRetCount", ilfRetCount);
  667. pointScaleMap.put("eifDetCount", eifDetCount);
  668. pointScaleMap.put("eifRetCount", eifRetCount);
  669. pointScaleMap.put("eiDetCount", eiDetCount);
  670. pointScaleMap.put("eiFtrCount", eiFtrCount);
  671. pointScaleMap.put("eoDetCount", eoDetCount);
  672. pointScaleMap.put("eoFtrCount", eoFtrCount);
  673. pointScaleMap.put("eqImputDetCount", eqImputDetCount);
  674. pointScaleMap.put("eqImputFtrCount", eqImputFtrCount);
  675. pointScaleMap.put("eqoutputDetCount", eqoutputDetCount);
  676. pointScaleMap.put("eqoutputFtrCount", eqoutputFtrCount);
  677. excelWriter.fill(pointScaleMap, pointScaleSheet);
  678. FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
  679. excelWriter.fill(detailList, fillConfig, pointScaleSheet);
  680. }
  681. excelUtils.clse(excelWriter);
  682. }
  683. public String notEmptyToString(String reslt){
  684. return StringUtils.isNotEmpty(reslt)?reslt:"0";
  685. }
  686. public SysIfpugTcf initSysIfpugTcf(SysIfpugTcf tcf){
  687. tcf.setDataComm(notEmptyToString(tcf.getDataComm()));
  688. tcf.setDataHandle(notEmptyToString(tcf.getDataHandle()));
  689. tcf.setBehavior(notEmptyToString(tcf.getBehavior()));
  690. tcf.setLoads(notEmptyToString(tcf.getLoads()));
  691. tcf.setThings(notEmptyToString(tcf.getThings()));
  692. tcf.setDataInput(notEmptyToString(tcf.getDataInput()));
  693. tcf.setUserRatio(notEmptyToString(tcf.getUserRatio()));
  694. tcf.setLineUpdate(notEmptyToString(tcf.getLineUpdate()));
  695. tcf.setComplex(notEmptyToString(tcf.getComplex()));
  696. tcf.setMultiplex(notEmptyToString(tcf.getMultiplex()));
  697. tcf.setInstalls(notEmptyToString(tcf.getInstalls()));
  698. tcf.setOperate(notEmptyToString(tcf.getOperate()));
  699. tcf.setPlatform(notEmptyToString(tcf.getPlatform()));
  700. tcf.setExtends(notEmptyToString(tcf.getExtend()));
  701. return tcf;
  702. }
  703. // 结果导入
  704. public Map<String, Object> resultImport(InputStream inputStream) throws Exception {
  705. ExcelReader reader = ExcelUtil.getReader(inputStream);
  706. List<List<Object>> readAll = reader.read(4);
  707. // 载体
  708. List<SysIfpugIlfs> ilfsList = new ArrayList<>();
  709. List<SysIfpugEifs> eifsList = new ArrayList<>();
  710. List<SysIfpugEis> eisList = new ArrayList<>();
  711. List<SysIfpugEos> eosList = new ArrayList<>();
  712. List<SysIfpugEqs> eqsList = new ArrayList<>();
  713. for (List<Object> objects : readAll) {
  714. resultDataInit(objects, ilfsList, eifsList, eisList, eosList, eqsList);
  715. }
  716. Map<String, Object> resultMap = new HashMap<>();
  717. resultMap.put("ilfs", ilfsList);
  718. resultMap.put("eifs", eifsList);
  719. resultMap.put("eis", eisList);
  720. resultMap.put("eos", eosList);
  721. resultMap.put("eqs", eqsList);
  722. IfpugDataUtils utils = new IfpugDataUtils();
  723. List<SysIfpugFps> fpsList = utils.initFps(ilfsList, eifsList, eisList, eosList, eqsList);
  724. resultMap.put("fps", fpsList);
  725. SysIfpugResult result = utils.initResult(fpsList);
  726. resultMap.put("result", result);
  727. return resultMap;
  728. }
  729. // 结果判空
  730. private boolean judgData(String... data) {
  731. boolean falg = false;
  732. for (String datum : data) {
  733. if(falg)
  734. continue;
  735. if(StringUtils.isNotEmpty(datum) && Integer.parseInt(datum) > 0)
  736. falg = true;
  737. }
  738. return falg;
  739. }
  740. // 结果装载
  741. private void resultDataInit(List<Object> list, List<SysIfpugIlfs> ilfsList, List<SysIfpugEifs> eifsList,
  742. List<SysIfpugEis> eisList, List<SysIfpugEos> eosList, List<SysIfpugEqs> eqsList) {
  743. // 功能点 TODO 未处理===
  744. String gnName = list.get(4).toString();
  745. // ILF
  746. String ilfDet = list.get(9).toString();
  747. String ilfRet = list.get(10).toString();
  748. // EIF
  749. String eifDet = list.get(11).toString();
  750. String eifRet = list.get(12).toString();
  751. // EI
  752. String eiDet = list.get(13).toString();
  753. String eiFtr = list.get(14).toString();
  754. // EO
  755. String eoDet = list.get(15).toString();
  756. String eoFtr = list.get(16).toString();
  757. // EQ
  758. String eqImDet = list.get(17).toString();
  759. String eqImFtr = list.get(18).toString();
  760. String eqOutDet = list.get(19).toString();
  761. String eqOutFtr = list.get(20).toString();
  762. // 备注
  763. String remark = list.get(21).toString();
  764. // ILF
  765. if(judgData(ilfDet, ilfRet)){
  766. SysIfpugIlfs ilfs = new SysIfpugIlfs();
  767. ilfs.setFileName(gnName);
  768. ilfs.setDet(ilfDet);
  769. ilfs.setRet(ilfRet);
  770. ilfs.setRemark(remark);
  771. // 计算复杂度
  772. IfpugDataUtils.ilfsFzd(ilfs);
  773. ilfsList.add(ilfs);
  774. }
  775. // EIF
  776. if(judgData(eifDet, eifRet)){
  777. SysIfpugEifs eifs = new SysIfpugEifs();
  778. eifs.setFileName(gnName);
  779. eifs.setDet(eifDet);
  780. eifs.setRet(eifRet);
  781. eifs.setRemark(remark);
  782. // 计算复杂度
  783. IfpugDataUtils.eifsFzd(eifs);
  784. eifsList.add(eifs);
  785. }
  786. // EI
  787. if(judgData(eiDet, eiFtr)){
  788. SysIfpugEis eis = new SysIfpugEis();
  789. eis.setInputName(gnName);
  790. eis.setDet(eiDet);
  791. eis.setFtr(eiFtr);
  792. eis.setRemark(remark);
  793. // 计算复杂度
  794. IfpugDataUtils.eisFzd(eis);
  795. eisList.add(eis);
  796. }
  797. // EO
  798. if(judgData(eoDet, eoFtr)){
  799. SysIfpugEos eos = new SysIfpugEos();
  800. eos.setOutputName(gnName);
  801. eos.setDet(eoDet);
  802. eos.setFtr(eoFtr);
  803. eos.setRemark(remark);
  804. // 计算复杂度
  805. IfpugDataUtils.eosFzd(eos);
  806. eosList.add(eos);
  807. }
  808. // EQ
  809. if(judgData(eqImDet, eqImFtr, eqOutDet, eqOutFtr)){
  810. SysIfpugEqs eqs = new SysIfpugEqs();
  811. eqs.setSeachName(gnName);
  812. eqs.setInputDet(eqImDet);
  813. eqs.setInputFtr(eqImFtr);
  814. eqs.setOutputDet(eqOutDet);
  815. eqs.setOutputFtr(eqOutFtr);
  816. eqs.setRemark(remark);
  817. // 计算复杂度
  818. IfpugDataUtils.eqsFzd(eqs);
  819. eqsList.add(eqs);
  820. }
  821. }
  822. // 获取EQ复杂度
  823. public String getEQCommplex(String inPfz, String ouFzd){
  824. if("低".equals(inPfz) && "低".equals(ouFzd)){
  825. return "低";
  826. }else if("高".equals(inPfz) && "高".equals(ouFzd)){
  827. return "高";
  828. }else{
  829. return "中";
  830. }
  831. }
  832. // 获取功能复杂度
  833. public String getCommplex(String di, String zhong, String gao){
  834. if(StringUtils.isNotEmpty(di) || StringUtils.isNotEmpty(zhong) || StringUtils.isNotEmpty(gao)){
  835. int diNum = StringUtils.isNotEmpty(di)?Integer.parseInt(di):0;
  836. int zhongNum = StringUtils.isNotEmpty(zhong)?Integer.parseInt(zhong):0;
  837. int gaoNum = StringUtils.isNotEmpty(gao)?Integer.parseInt(gao):0;
  838. if(diNum > 0 && zhongNum <= 0 && gaoNum <= 0){
  839. return "低";
  840. }else if(diNum <= 0 && zhongNum <= 0 && gaoNum > 0){
  841. return "高";
  842. }else{
  843. return "中";
  844. }
  845. }
  846. return "";
  847. }
  848. // 获取功能点数
  849. public String getCommplexNum(String di, String zhong, String gao){
  850. if(StringUtils.isNotEmpty(di) || StringUtils.isNotEmpty(zhong) || StringUtils.isNotEmpty(gao)){
  851. int diNum = StringUtils.isNotEmpty(di)?Integer.parseInt(di):0;
  852. int zhongNum = StringUtils.isNotEmpty(zhong)?Integer.parseInt(zhong):0;
  853. int gaoNum = StringUtils.isNotEmpty(gao)?Integer.parseInt(gao):0;
  854. if(diNum > 0 && zhongNum <= 0 && gaoNum <= 0){
  855. return String.valueOf(diNum);
  856. }else if(diNum <= 0 && zhongNum <= 0 && gaoNum > 0){
  857. return String.valueOf(gaoNum);
  858. }else{
  859. return String.valueOf(zhongNum);
  860. }
  861. }
  862. return "0";
  863. }
  864. // 计算权重
  865. public String getWeights(String type, String fzd){
  866. if("ILF".equals(type)){
  867. if("低".equals(fzd)){
  868. return "7";
  869. }else if("中".equals(fzd)){
  870. return "10";
  871. }else if("高".equals(fzd)){
  872. return "15";
  873. }
  874. }else if("EIF".equals(type)){
  875. if("低".equals(fzd)){
  876. return "5";
  877. }else if("中".equals(fzd)){
  878. return "7";
  879. }else if("高".equals(fzd)){
  880. return "10";
  881. }
  882. }else if("EI".equals(type)){
  883. if("低".equals(fzd)){
  884. return "3";
  885. }else if("中".equals(fzd)){
  886. return "4";
  887. }else if("高".equals(fzd)){
  888. return "6";
  889. }
  890. }else if("EO".equals(type)){
  891. if("低".equals(fzd)){
  892. return "4";
  893. }else if("中".equals(fzd)){
  894. return "5";
  895. }else if("高".equals(fzd)){
  896. return "7";
  897. }
  898. }else if("EQ".equals(type)){
  899. if("低".equals(fzd)){
  900. return "3";
  901. }else if("中".equals(fzd)){
  902. return "4";
  903. }else if("高".equals(fzd)){
  904. return "6";
  905. }
  906. }
  907. return "0";
  908. }
  909. // 生成功能点规模计算明细
  910. private List<IfpugPointScaleDetailsExcel> getPointScaleDetail(List<SysIfpugIlfs> ilfsList, List<SysIfpugEifs> eifsList,
  911. List<SysIfpugEis> eisList, List<SysIfpugEos> eosList, List<SysIfpugEqs> eqsList) {
  912. int indexNo = 0;
  913. List<IfpugPointScaleDetailsExcel> result = new ArrayList<>();
  914. for (SysIfpugIlfs item : ilfsList) {
  915. indexNo++;
  916. IfpugPointScaleDetailsExcel detailsExcel = new IfpugPointScaleDetailsExcel();
  917. detailsExcel.setIndexNo(String.valueOf(indexNo));
  918. detailsExcel.setFourthLayer(item.getFileName());
  919. detailsExcel.setFtype("ILF");
  920. String commplex = getCommplex(item.getDi(),item.getZhong(),item.getGao());
  921. detailsExcel.setCommplex(commplex);
  922. detailsExcel.setWeights(getWeights("ILF", commplex));
  923. detailsExcel.setNum(getCommplexNum(item.getDi(),item.getZhong(),item.getGao()));
  924. detailsExcel.setIlfDet(item.getDet());
  925. detailsExcel.setIlfRet(item.getRet());
  926. detailsExcel.setRemark(item.getRemark());
  927. result.add(detailsExcel);
  928. }
  929. for (SysIfpugEifs item : eifsList) {
  930. indexNo++;
  931. IfpugPointScaleDetailsExcel detailsExcel = new IfpugPointScaleDetailsExcel();
  932. detailsExcel.setIndexNo(String.valueOf(indexNo));
  933. detailsExcel.setFourthLayer(item.getFileName());
  934. detailsExcel.setFtype("EIF");
  935. String commplex = getCommplex(item.getDi(),item.getZhong(),item.getGao());
  936. detailsExcel.setCommplex(commplex);
  937. detailsExcel.setWeights(getWeights("EIF", commplex));
  938. detailsExcel.setNum(getCommplexNum(item.getDi(),item.getZhong(),item.getGao()));
  939. detailsExcel.setEifDet(item.getDet());
  940. detailsExcel.setEifRet(item.getRet());
  941. detailsExcel.setRemark(item.getRemark());
  942. result.add(detailsExcel);
  943. }
  944. for (SysIfpugEis item : eisList) {
  945. indexNo++;
  946. IfpugPointScaleDetailsExcel detailsExcel = new IfpugPointScaleDetailsExcel();
  947. detailsExcel.setIndexNo(String.valueOf(indexNo));
  948. detailsExcel.setFourthLayer(item.getInputName());
  949. detailsExcel.setFtype("EI");
  950. String commplex = getCommplex(item.getDi(),item.getZhong(),item.getGao());
  951. detailsExcel.setCommplex(commplex);
  952. detailsExcel.setWeights(getWeights("EI", commplex));
  953. detailsExcel.setNum(getCommplexNum(item.getDi(),item.getZhong(),item.getGao()));
  954. detailsExcel.setEiDet(item.getDet());
  955. detailsExcel.setEiFtr(item.getFtr());
  956. detailsExcel.setRemark(item.getRemark());
  957. result.add(detailsExcel);
  958. }
  959. for (SysIfpugEos item : eosList) {
  960. indexNo++;
  961. IfpugPointScaleDetailsExcel detailsExcel = new IfpugPointScaleDetailsExcel();
  962. detailsExcel.setIndexNo(String.valueOf(indexNo));
  963. detailsExcel.setFourthLayer(item.getOutputName());
  964. detailsExcel.setFtype("EO");
  965. String commplex = getCommplex(item.getDi(),item.getZhong(),item.getGao());
  966. detailsExcel.setCommplex(commplex);
  967. detailsExcel.setWeights(getWeights("EO", commplex));
  968. detailsExcel.setNum(getCommplexNum(item.getDi(),item.getZhong(),item.getGao()));
  969. detailsExcel.setEoDet(item.getDet());
  970. detailsExcel.setEoFtr(item.getFtr());
  971. detailsExcel.setRemark(item.getRemark());
  972. result.add(detailsExcel);
  973. }
  974. for (SysIfpugEqs item : eqsList) {
  975. indexNo++;
  976. IfpugPointScaleDetailsExcel detailsExcel = new IfpugPointScaleDetailsExcel();
  977. detailsExcel.setIndexNo(String.valueOf(indexNo));
  978. detailsExcel.setFourthLayer(item.getSeachName());
  979. detailsExcel.setFtype("EQ");
  980. String commplex = getEQCommplex(item.getInputFzd(), item.getOutputFtr());
  981. detailsExcel.setCommplex(commplex);
  982. detailsExcel.setWeights(getWeights("EQ", commplex));
  983. detailsExcel.setNum(getCommplexNum(item.getDi(),item.getZhong(),item.getGao()));
  984. detailsExcel.setEqImputDet(item.getInputDet());
  985. detailsExcel.setEqImputFtr(item.getInputDet());
  986. detailsExcel.setEqoutputDet(item.getOutputDet());
  987. detailsExcel.setEqoutputFtr(item.getOutputFtr());
  988. detailsExcel.setRemark(item.getRemark());
  989. result.add(detailsExcel);
  990. }
  991. return result;
  992. }
  993. public static void main(String[] args) {
  994. System.err.println(SecureUtil.md5("IndustrySupervisionSuperviseDistribute"));
  995. }
  996. }