2657f3269671ee89131eebda77ab59f98b8bf22f.svn-base 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. package cn.com.goldenwater.dcproj.service.impl.tac;
  2. import cn.com.goldenwater.core.service.AbstractCrudService;
  3. import cn.com.goldenwater.dcproj.constValue.TacEnum;
  4. import cn.com.goldenwater.dcproj.dao.*;
  5. import cn.com.goldenwater.dcproj.dto.*;
  6. import cn.com.goldenwater.dcproj.model.TacObjPblmstb;
  7. import cn.com.goldenwater.dcproj.model.TacObjPblmstbLaw;
  8. import cn.com.goldenwater.dcproj.model.TacObjSubject;
  9. import cn.com.goldenwater.dcproj.param.TacObjPblmstbLawParam;
  10. import cn.com.goldenwater.dcproj.param.TacObjPblmstbParam;
  11. import cn.com.goldenwater.dcproj.param.TacObjSubjectParam;
  12. import cn.com.goldenwater.dcproj.param.TacPblmClassParam;
  13. import cn.com.goldenwater.dcproj.service.TacObjPblmstbService;
  14. import cn.com.goldenwater.dcproj.utils.expExcel.ExportUtil;
  15. import cn.com.goldenwater.id.util.UuidUtil;
  16. import com.github.pagehelper.PageHelper;
  17. import com.github.pagehelper.PageInfo;
  18. import org.apache.commons.lang3.StringUtils;
  19. import org.apache.poi.ss.usermodel.Cell;
  20. import org.apache.poi.ss.usermodel.Row;
  21. import org.springframework.beans.factory.annotation.Autowired;
  22. import org.springframework.stereotype.Service;
  23. import org.springframework.transaction.annotation.Transactional;
  24. import org.springframework.web.multipart.MultipartFile;
  25. import java.util.ArrayList;
  26. import java.util.List;
  27. /**
  28. * @author lune
  29. * @date 2019-6-19
  30. */
  31. @Service
  32. @Transactional
  33. public class TacObjPblmstbServiceImpl extends AbstractCrudService<TacObjPblmstb, TacObjPblmstbParam> implements TacObjPblmstbService {
  34. @Autowired
  35. private TacObjPblmstbDao tacObjPblmstbDao;
  36. @Autowired
  37. private TacObjSubjectDao tacObjSubjectDao;
  38. @Autowired
  39. private TacObjPblmstb515Dao tacObjPblmstb515Dao;
  40. @Autowired
  41. private TacObjSubject515Dao tacObjSubject515Dao;
  42. @Autowired
  43. private TacObjPblmstbLawDao tacObjPblmstbLawDao;
  44. public TacObjPblmstbServiceImpl(TacObjPblmstbDao tacObjPblmstbDao) {
  45. super(tacObjPblmstbDao);
  46. this.tacObjPblmstbDao = tacObjPblmstbDao;
  47. }
  48. @Override
  49. public int insert(TacObjPblmstb entity) {
  50. entity.setIsNew("1");
  51. return super.insert(entity);
  52. }
  53. @Override
  54. public int upload(MultipartFile file) {
  55. List<Row> rowList = ExportUtil.getRowListByFile(file);
  56. if (rowList.size() > 5) {
  57. Row spfsnlTypeRow = rowList.get(1);
  58. String spfsnlTypeValue = spfsnlTypeRow.getCell(0).getStringCellValue().replace("专业:", "").replaceAll(" ", "");
  59. String class1 = "";
  60. String className1 = "";
  61. String class2 = "";
  62. String className2 = "";
  63. TacEnum tacEnum = TacEnum.getTacEnum(spfsnlTypeValue);
  64. int index = Integer.valueOf(tacEnum.getKey() + "0001");
  65. List<TacObjPblmstb> result = new ArrayList<>();
  66. for (int i = 4; i < rowList.size(); i++) {
  67. Row dataRow = rowList.get(i);
  68. Cell cell = dataRow.getCell(0);
  69. if (cell == null) {
  70. continue;
  71. }
  72. String value = cell.toString();
  73. if (value.endsWith(".0") || value.length() == 1) {
  74. class1 = cell.toString();
  75. className1 = dataRow.getCell(1).toString();
  76. continue;
  77. }
  78. if (value.contains(".") && value.length() == 3) {
  79. class2 = value;
  80. className2 = dataRow.getCell(1).toString();
  81. continue;
  82. }
  83. TacObjPblmstb pblmstb = new TacObjPblmstb();
  84. pblmstb.setSpfsnlType(spfsnlTypeValue);
  85. pblmstb.setClass1(Double.valueOf(class1).intValue() + "");
  86. pblmstb.setClass1Name(className1);
  87. pblmstb.setClass2(class2);
  88. pblmstb.setClass2Name(className2);
  89. pblmstb.setSn(value);
  90. pblmstb.setSortNo(index++ + "");
  91. for (int j = 1; j < 12; j++) {
  92. Cell dataCell = dataRow.getCell(j);
  93. if (dataCell == null) {
  94. continue;
  95. }
  96. String dataValue = dataCell.toString();
  97. if (j == 1) {
  98. pblmstb.setPblmsDesc(dataValue);
  99. } else if (j == 2) {
  100. pblmstb.setRelativeLaw(dataValue);
  101. } else if (j == 3) {
  102. pblmstb.setLawContent(dataValue);
  103. } else if (j == 4) {
  104. if (StringUtils.isBlank(dataValue)) {
  105. pblmstb.setCate0("0");
  106. } else {
  107. pblmstb.setCate0("1");
  108. if (!"√".endsWith(dataValue)) {
  109. pblmstb.setCate0Desc(dataValue);
  110. }
  111. }
  112. } else if (j == 5) {
  113. if (StringUtils.isBlank(dataValue)) {
  114. pblmstb.setCate1("0");
  115. } else {
  116. pblmstb.setCate1("1");
  117. if (!"√".endsWith(dataValue)) {
  118. pblmstb.setCate1Desc(dataValue);
  119. }
  120. }
  121. } else if (j == 6) {
  122. if (StringUtils.isBlank(dataValue)) {
  123. pblmstb.setCate2("0");
  124. } else {
  125. pblmstb.setCate2("1");
  126. if (!"√".endsWith(dataValue)) {
  127. pblmstb.setCate2Desc(dataValue);
  128. }
  129. }
  130. } else if (j == 7) {
  131. pblmstb.setSubName(dataValue);
  132. } else if (j == 8) {
  133. pblmstb.setSubName(pblmstb.getSubName() + "," + dataValue);
  134. } else if (j == 9) {
  135. pblmstb.setSubName(pblmstb.getSubName() + "," + dataValue);
  136. } else if (j == 10) {
  137. pblmstb.setSubName(pblmstb.getSubName() + "," + dataValue);
  138. } else if (j == 11) {
  139. pblmstb.setNote(dataValue);
  140. }
  141. }
  142. result.add(pblmstb);
  143. }
  144. if (result.size() > 0) {
  145. for (TacObjPblmstb pblmstb : result) {
  146. if (StringUtils.isBlank(pblmstb.getPblmsDesc())) {
  147. continue;
  148. }
  149. tacObjPblmstbDao.updateStb(pblmstb);
  150. // pblmstb.setId(UuidUtil.uuid());
  151. // pblmstb.setIntm(new Date());
  152. // pblmstb.setUptm(new Date());
  153. // pblmstb.setDataStat("1");
  154. // if (pblmstb.getSubName().contains(",")) {
  155. // StringBuilder st = new StringBuilder();
  156. // for (String subName : pblmstb.getSubName().split(",")) {
  157. // if (StringUtils.isBlank(subName)) {
  158. // continue;
  159. // }
  160. // TacObjSubjectParam subjectParam = new TacObjSubjectParam();
  161. // subjectParam.setSubName(subName.replace(" ","").replace("\n",""));
  162. // TacObjSubject objSubjectList = tacObjSubjectDao.getBy(subjectParam);
  163. // if (objSubjectList == null) {
  164. // objSubjectList = tacObjSubject515Dao.getBy(subjectParam);
  165. // }
  166. // st.append(objSubjectList.getId()).append(",");
  167. // }
  168. // if (st.length() > 0) {
  169. // pblmstb.setSubjectIds(st.substring(0, st.length() - 1));
  170. // }
  171. // } else {
  172. // TacObjSubjectParam subjectParam = new TacObjSubjectParam();
  173. // subjectParam.setSubName(pblmstb.getSubName().replace(" ","").replace("\n",""));
  174. // TacObjSubject objSubjectList = tacObjSubjectDao.getBy(subjectParam);
  175. // pblmstb.setSubjectIds(objSubjectList.getId());
  176. // }
  177. // System.out.println(pblmstb.toString());
  178. // tacObjPblmstbDao.insert(pblmstb);
  179. }
  180. }
  181. }
  182. return 0;
  183. }
  184. @Override
  185. public TacObjPblmstb getOne(String id) {
  186. TacObjPblmstb tacObjPblmstb = tacObjPblmstbDao.get(id);
  187. boolean newPblms = true;
  188. if (tacObjPblmstb == null) {
  189. newPblms = false;
  190. tacObjPblmstb = tacObjPblmstb515Dao.get(id);
  191. }
  192. if (tacObjPblmstb != null) {
  193. if (StringUtils.isNotBlank(tacObjPblmstb.getSubjectIds())) {
  194. TacObjSubjectParam subjectParam = new TacObjSubjectParam();
  195. subjectParam.setIds(tacObjPblmstb.getSubjectIds());
  196. if (newPblms) {
  197. List<TacObjSubject> objSubjectList = tacObjSubjectDao.findList(subjectParam);
  198. tacObjPblmstb.setObjSubjectList(objSubjectList);
  199. } else {
  200. List<TacObjSubject> objSubjectList = tacObjSubject515Dao.findList(subjectParam);
  201. tacObjPblmstb.setObjSubjectList(objSubjectList);
  202. }
  203. }
  204. List<CateObj> cateObjList = new ArrayList<>();
  205. List<CateObj> cateNotObjList = new ArrayList<>();
  206. CateObj cateObj = new CateObj();
  207. cateObj.setCate("0");
  208. cateObj.setDesc("一般");
  209. String catedesc = tacObjPblmstb.getCate0Desc();
  210. if (StringUtils.isNotBlank(catedesc)) {
  211. cateObj.setDesc("(一般)" + catedesc);
  212. }
  213. if ("1".equals(tacObjPblmstb.getCate0())) {
  214. cateObjList.add(cateObj);
  215. } else if ("0".equals(tacObjPblmstb.getCate0())) {
  216. cateNotObjList.add(cateObj);
  217. }
  218. CateObj cateObj1 = new CateObj();
  219. cateObj1.setCate("1");
  220. cateObj1.setDesc("较重");
  221. String catedesc1 = tacObjPblmstb.getCate1Desc();
  222. if (StringUtils.isNotBlank(catedesc1)) {
  223. cateObj1.setDesc("(较重)" + catedesc1);
  224. }
  225. if ("1".equals(tacObjPblmstb.getCate1())) {
  226. cateObjList.add(cateObj1);
  227. } else if ("0".equals(tacObjPblmstb.getCate1())) {
  228. cateNotObjList.add(cateObj1);
  229. }
  230. CateObj cateObj2 = new CateObj();
  231. cateObj2.setCate("2");
  232. cateObj2.setDesc("严重");
  233. String catedesc2 = tacObjPblmstb.getCate2Desc();
  234. if (StringUtils.isNotBlank(catedesc2)) {
  235. cateObj2.setDesc("(严重)" + catedesc2);
  236. }
  237. if ("1".equals(tacObjPblmstb.getCate2())) {
  238. cateObjList.add(cateObj2);
  239. } else if ("0".equals(tacObjPblmstb.getCate2())) {
  240. cateNotObjList.add(cateObj2);
  241. }
  242. tacObjPblmstb.setCateObjList(cateObjList);
  243. tacObjPblmstb.setCateNotObjList(cateNotObjList);
  244. TacObjPblmstbLawParam lawParam = new TacObjPblmstbLawParam();
  245. lawParam.setPblmstbId(tacObjPblmstb.getId());
  246. List<TacObjPblmstbLaw> pblmstbLawList = tacObjPblmstbLawDao.findList(lawParam);
  247. tacObjPblmstb.setPblmstbLawList(pblmstbLawList);
  248. }
  249. return tacObjPblmstb;
  250. }
  251. @Override
  252. public TacObjPblmstb getOneByParam(TacObjPblmstbParam pblmstbParam) {
  253. return tacObjPblmstbDao.getOne(pblmstbParam);
  254. }
  255. @Override
  256. public PageInfo<TacObjPblmstb> findPblmsPageinfo(TacObjPblmstbParam pblmInfoParam) {
  257. PageHelper.startPage(pblmInfoParam.getPageNum(), pblmInfoParam.getPageSize());
  258. List<TacObjPblmstb> list = tacObjPblmstbDao.findPblmstbList(pblmInfoParam);
  259. return new PageInfo<>(list);
  260. }
  261. @Override
  262. public PageInfo<TacObjPblmstb> findPblmstbList_bak(TacObjPblmstbParam pblmstbParam) {
  263. PageHelper.startPage(pblmstbParam.getPageNum(), pblmstbParam.getPageSize());
  264. List<TacObjPblmstb> list = tacObjPblmstbDao.findPblmstbList_bak(pblmstbParam);
  265. return new PageInfo<>(list);
  266. }
  267. @Override
  268. public int delList(List<String> ids) {
  269. int ret = tacObjPblmstbDao.delList(ids);
  270. return ret;
  271. }
  272. @Override
  273. public int updateList(TacPblmClassParam tacPblmClassParam) {
  274. return tacObjPblmstbDao.updateList(tacPblmClassParam);
  275. }
  276. @Override
  277. public List<TacObjPblmstbDto> findSpfsnlType(String persId, String year) {
  278. return tacObjPblmstbDao.findSpfsnlType(persId, year);
  279. }
  280. @Override
  281. public List<TacObjPblmstbClass> findClass1ByType(String pblmChType, String persId, String year) {
  282. return tacObjPblmstbDao.findClass1ByType(pblmChType, persId, year);
  283. }
  284. @Override
  285. public List<TacObjPblmstbClass2> findClass2ByClass1(String pblmChType, String class1, String persId, String year) {
  286. return tacObjPblmstbDao.findClass2ByClass1(pblmChType, class1, persId, year);
  287. }
  288. @Override
  289. public List<TacPblmsSn> findClass3ByTypeClass1Class2(String pblmChType, String class1, String class2, String persId, String year) {
  290. return tacObjPblmstbDao.findClass3ByTypeClass1Class2(pblmChType, class1, class2, persId, year);
  291. }
  292. @Override
  293. public void updateNew(TacObjPblmstb tacObjPblmstb) {
  294. addPblmsLaw(tacObjPblmstb, "1");
  295. tacObjPblmstbDao.update(tacObjPblmstb);
  296. }
  297. @Override
  298. public void insertNew(TacObjPblmstb tacObjPblmstb) {
  299. addPblmsLaw(tacObjPblmstb, "");
  300. tacObjPblmstb.setIsNew("1");
  301. tacObjPblmstbDao.insert(tacObjPblmstb);
  302. }
  303. private void addPblmsLaw(TacObjPblmstb tacObjPblmstb, String flag) {
  304. if ("1".equals(flag)) {
  305. TacObjPblmstbLawParam lawParam = new TacObjPblmstbLawParam();
  306. lawParam.setPblmstbId(tacObjPblmstb.getId());
  307. tacObjPblmstbLawDao.deleteBy(lawParam);
  308. }
  309. List<TacObjPblmstbLaw> pblmstbLawList = tacObjPblmstb.getPblmstbLawList();
  310. if (pblmstbLawList != null && !pblmstbLawList.isEmpty()) {
  311. StringBuffer lawes = new StringBuffer();
  312. StringBuffer relativeLaw = new StringBuffer();
  313. for (TacObjPblmstbLaw law : pblmstbLawList) {
  314. law.setId(UuidUtil.uuid());
  315. law.setPblmstbId(tacObjPblmstb.getId());
  316. tacObjPblmstbLawDao.insert(law);
  317. lawes.append(law.getLawContent()).append("\r\n");
  318. relativeLaw.append(law.getNote()).append("、");
  319. }
  320. tacObjPblmstb.setLawContent(lawes.toString());
  321. tacObjPblmstb.setRelativeLaw(relativeLaw.toString());
  322. }
  323. }
  324. }