RetreatOptimizationService.java 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568
  1. package platform.modules.government.service;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.aliyuncs.exceptions.ClientException;
  4. import com.github.pagehelper.PageHelper;
  5. import com.github.pagehelper.PageInfo;
  6. import org.apache.poi.ss.formula.functions.T;
  7. import org.apache.tomcat.util.bcel.Const;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.boot.autoconfigure.AutoConfigurationPackage;
  10. import org.springframework.stereotype.Service;
  11. import org.springframework.transaction.annotation.Transactional;
  12. import org.springframework.ui.ModelMap;
  13. import org.springframework.util.ObjectUtils;
  14. import org.springframework.util.StringUtils;
  15. import platform.common.Constant;
  16. import platform.common.base.model.DictionaryItem;
  17. import platform.common.base.model.Template;
  18. import platform.common.base.service.BaseService;
  19. import platform.common.base.service.DictionaryItemService;
  20. import platform.common.base.service.TemplateService;
  21. import platform.common.exception.BaseException;
  22. import platform.common.util.AlibabaSMSUtil;
  23. import platform.common.util.DateUtil;
  24. import platform.common.util.GenerateNoUtil;
  25. import platform.common.util.ShiroUtils;
  26. import platform.modules.company.entity.ProjectMaterial;
  27. import platform.modules.company.entity.ProjectMatters;
  28. import platform.modules.company.entity.ProjectProvinces;
  29. import platform.modules.company.service.ProjectMaterialService;
  30. import platform.modules.company.service.ProjectProvincesService;
  31. import platform.modules.government.dao.RetreatOptimizationDao;
  32. import platform.modules.government.dto.SearchCondition;
  33. import platform.modules.government.entity.*;
  34. import platform.modules.sys.entity.*;
  35. import platform.modules.sys.service.*;
  36. import tk.mybatis.mapper.entity.Example;
  37. import tk.mybatis.mapper.util.StringUtil;
  38. import java.util.*;
  39. /**
  40. * @author kevin
  41. * @since 2019/3/14 10:55 AM
  42. */
  43. @Service
  44. @Transactional
  45. public class RetreatOptimizationService extends BaseService<RetreatOptimization> {
  46. @Autowired
  47. private RetreatOptimizationDao retreatOptimizationDao;
  48. @Autowired
  49. private ProjectMaterialService projectMaterialService;
  50. @Autowired
  51. private AttachmentService attachmentService;
  52. @Autowired
  53. private ApprovalService approvalService;
  54. @Autowired
  55. private TemplateService templateService;
  56. @Autowired
  57. private UserService userService;
  58. @Autowired
  59. private DepartmentService departmentService;
  60. @Autowired
  61. private DictionaryItemService dictionaryItemService;
  62. @Autowired
  63. private StreetService streetService;
  64. @Autowired
  65. private MessageService messageService;
  66. @Autowired
  67. private GroupService groupService;
  68. @Autowired
  69. private UserGroupService userGroupService;
  70. @Autowired
  71. private WaitToDoService waitToDoService;
  72. /**
  73. * 退二优二列表
  74. *
  75. * @param condition
  76. * @return
  77. */
  78. public PageInfo<RetreatOptimization> findByCondition(SearchCondition condition) {
  79. PageHelper.startPage(condition.getPageNum(), condition.getPageSize());
  80. if (condition.getStreet_id() != null){
  81. condition.setStreet_id(condition.getStreet_id());
  82. }
  83. else {
  84. condition.setStreet_id(ShiroUtils.getStreetId());
  85. }
  86. condition.setUser_type(ShiroUtils.getUserType());
  87. List<RetreatOptimization> list = retreatOptimizationDao.findByCondition(condition);
  88. if (!ObjectUtils.isEmpty(list)){
  89. for (RetreatOptimization retreatOptimization : list) {
  90. Street street = streetService.findById(retreatOptimization.getPlate());
  91. retreatOptimization.setPlateName(street.getName());
  92. //是否可审核
  93. if(null != ShiroUtils.getStreetId()){
  94. //街道用户
  95. if(retreatOptimization.getStatus().equals(Constant.RetreatOptimizationStatus.SUBMIT)){
  96. Group group = groupService.findByNameAndUserType(Constant.RETREAT,null,Constant.UserType.STREET,retreatOptimization.getPlate());
  97. if (null != group) {
  98. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  99. for (UserGroup userGroup : userGroups) {
  100. if (ShiroUtils.getUserId().equals(userGroup.getUser_id())) {
  101. retreatOptimization.setCanAudit(true);
  102. }
  103. }
  104. }
  105. }
  106. }else{
  107. //政府用户
  108. if(retreatOptimization.getStatus().equals(Constant.RetreatOptimizationStatus.PENDINGRECEIVED)){
  109. Group group = groupService.findByNameAndUserType(Constant.RETREAT,null,Constant.UserType.GOVERNMENT, null);
  110. if (null != group) {
  111. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  112. for (UserGroup userGroup : userGroups) {
  113. if (userGroup.getUser_id().equals(ShiroUtils.getUserId())){
  114. retreatOptimization.setCanAudit(true);
  115. break;
  116. }
  117. }
  118. }
  119. }
  120. }
  121. if (retreatOptimization.getStatus().equals(Constant.RetreatOptimizationStatus.REJECT)){
  122. if (retreatOptimization.getCreate_by().equals(ShiroUtils.getUserId())){
  123. retreatOptimization.setCanEdit(true);
  124. }
  125. }
  126. }
  127. }
  128. return new PageInfo<>(list);
  129. }
  130. /**
  131. * 新建退二优二
  132. *
  133. * @param retreatOptimization
  134. */
  135. public void saveRetreatOptimization(RetreatOptimization retreatOptimization) {
  136. String no = GenerateNoUtil.generateProjectApplyNo(Constant.ProjectNoHeader.RETREAT_OPTIMIZATION);
  137. retreatOptimization.setCommit_time(DateUtil.getTimeString(new Date()));
  138. retreatOptimization.setStatus(1);
  139. retreatOptimization.setNo(no);
  140. retreatOptimization.setPlate(ShiroUtils.getStreetId());
  141. retreatOptimization.setIs_read(false);
  142. this.insertAndGetId(retreatOptimization);
  143. //保存材料
  144. if (retreatOptimization.getMaterials() != null && retreatOptimization.getMaterials().size() > 0){
  145. List<Template> templateList = retreatOptimization.getMaterials();
  146. for (Template template : templateList) {
  147. ProjectMaterial material = new ProjectMaterial();
  148. material.setApply_id(retreatOptimization.getId());
  149. material.setMaterial_type(5);
  150. material.setTemplate_id(template.getId());
  151. projectMaterialService.insertAndGetId(material);
  152. //更新文件
  153. int fileId = template.getFileDown().getFile_id();
  154. Attachment attachment = attachmentService.findById(fileId);
  155. attachment.setBusiness_id(material.getId());
  156. attachment.setBusiness_type(Constant.Attachment.RETREAT_OPTIMIZATION);
  157. attachmentService.updateSelective(attachment);
  158. }
  159. }
  160. //新增流程
  161. Approval approval = new Approval();
  162. approval.setApply_id(retreatOptimization.getId());
  163. approval.setType(Constant.DictionaryType.RETREAT_OPTIMIZATION);
  164. approval.setOper_type("提交");
  165. Integer departmentId = userService.findById(ShiroUtils.getUserId()).getDepartment_id();
  166. if (departmentId != null){
  167. Department department = departmentService.findById(departmentId);
  168. approval.setDepartment(department.getName());
  169. }
  170. approvalService.insertAndGetId(approval);
  171. //发送通知
  172. saveMessage(retreatOptimization);
  173. }
  174. /**
  175. * 发送信息
  176. *
  177. * @param retreatOptimization
  178. */
  179. private void saveMessage(RetreatOptimization retreatOptimization) {
  180. Message message = new Message();
  181. message.setApply_id(retreatOptimization.getId());
  182. message.setTitle(" 退二优二");
  183. String content = "您好,"+ShiroUtils.getUserName() + ",提交的编号为"+retreatOptimization.getNo()+"的退二优二需要你查看。";
  184. message.setContent(content);
  185. message.setBusiness_type(Constant.Message_Business_type.RETREAT_OPTIMIZATION);
  186. //获取组
  187. if(retreatOptimization.getStatus().equals(Constant.RetreatOptimizationStatus.SUBMIT)){
  188. //街道审核
  189. Group group = groupService.findByNameAndUserType(Constant.RETREAT,null,Constant.UserType.STREET,retreatOptimization.getPlate());
  190. if (null == group) {
  191. throw new BaseException("操作失败,退二优二组没有审核人员,请联系管理员配置");
  192. }
  193. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  194. int[] streetArrInt = new int[userGroups.size()];
  195. StringBuilder sb = new StringBuilder("");
  196. for (int i = 0 ;i<userGroups.size();i++) {
  197. streetArrInt[i] = userGroups.get(i).getUser_id();
  198. sb.append(userGroups.get(i).getUser_id()).append(",");
  199. }
  200. messageService.saveMessageAndPush(message, streetArrInt, Constant.UserType.STREET);
  201. //发送代办
  202. waitToDoService.newTODO("退二优二审核", "/retreatOpt/audit/" + retreatOptimization.getId(), Constant.WaitToDo_OperType.AUDIT, retreatOptimization.getId(),
  203. Constant.DictionaryType.RETREAT_OPTIMIZATION, retreatOptimization.getNo(), sb.toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false);
  204. }else if(retreatOptimization.getStatus().equals(Constant.RetreatOptimizationStatus.PENDINGRECEIVED)){
  205. //政府审核
  206. Group group = groupService.findByNameAndUserType(Constant.RETREAT,null,Constant.UserType.GOVERNMENT, null);
  207. if (null == group) {
  208. throw new BaseException("操作失败,退二优二组没有审核人员,请联系管理员配置");
  209. }
  210. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  211. StringBuilder sb = new StringBuilder("");
  212. for (UserGroup userGroup : userGroups) {
  213. // User user = userService.findById(userGroup.getUser_id());
  214. int[] streetArrInt = new int[1];
  215. streetArrInt[0] = userGroup.getUser_id();
  216. sb.append(userGroup.getUser_id()).append(",");
  217. messageService.saveMessageAndPush(message, streetArrInt, Constant.UserType.GOVERNMENT);
  218. }
  219. //发送代办
  220. waitToDoService.newTODO("退二优二审核", "/retreatOpt/audit/" + retreatOptimization.getId(), Constant.WaitToDo_OperType.AUDIT, retreatOptimization.getId(),
  221. Constant.DictionaryType.RETREAT_OPTIMIZATION, retreatOptimization.getNo(), sb.toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false);
  222. }
  223. }
  224. /**
  225. * 获取详情
  226. *
  227. * @param id
  228. * @return
  229. */
  230. @Transactional(readOnly = true)
  231. public RetreatOptimization findDetail(Integer id, ModelMap modelMap) {
  232. RetreatOptimization retreatOptimization = this.findById(id);
  233. //获取基本信息
  234. getFullBaseInfo(retreatOptimization);
  235. List<Template> materials = new ArrayList<>();
  236. //获取材料
  237. ProjectMaterial material = new ProjectMaterial();
  238. material.setApply_id(retreatOptimization.getId());
  239. material.setMaterial_type(5);
  240. material.setDel_flag(false);
  241. List<ProjectMaterial> materialList = projectMaterialService.findListByWhere(material);
  242. for (ProjectMaterial projectMaterial : materialList) {
  243. //上传文件
  244. Attachment attachment = attachmentService.
  245. findByBizIdAndBizType(projectMaterial.getId(), Constant.Attachment.RETREAT_OPTIMIZATION);
  246. //获取模版文件
  247. Attachment templateFile = attachmentService.
  248. findByBizIdAndBizType(projectMaterial.getTemplate_id(), Constant.Attachment.TEMPLATE);
  249. Template template = templateService.findById(projectMaterial.getTemplate_id());
  250. if (templateFile != null) {
  251. template.setUrl(templateFile.getFile_url());
  252. template.setItem_name(templateFile.getFile_name());
  253. }
  254. templateService.getFullTemplateInfo(template);
  255. if (attachment != null){
  256. FileDown fileDown = new FileDown();
  257. fileDown.setFile_id(attachment.getId());
  258. fileDown.setFile_name(attachment.getFile_name());
  259. fileDown.setDownload_uri(attachment.getDownload_uri());
  260. fileDown.setFile_url(attachment.getFile_url());
  261. template.setFileDown(fileDown);
  262. }
  263. materials.add(template);
  264. }
  265. retreatOptimization.setMaterials(materials);
  266. modelMap.put("materials", materials);
  267. //获取流程
  268. List<Approval> approvalList = approvalService.
  269. getListByApplyIdAndType(retreatOptimization.getId(), Constant.DictionaryType.RETREAT_OPTIMIZATION);
  270. retreatOptimization.setApprovals(approvalList);
  271. modelMap.put("approvals", approvalList);
  272. if (ShiroUtils.getUserId() == retreatOptimization.getCreate_by()){
  273. //是否在街道审核组
  274. if (inGroup(Constant.RETREAT, ShiroUtils.getStreetId())) {
  275. modelMap.put("canView", true);
  276. }
  277. }
  278. else {
  279. modelMap.put("canView", true);
  280. }
  281. Approval lastApproval = approvalService.getLatestApproval(retreatOptimization.getId(), Constant.DictionaryType.RETREAT_OPTIMIZATION);
  282. modelMap.put("lastApproval", lastApproval);
  283. return retreatOptimization;
  284. }
  285. private boolean inGroup(String groupName, Integer streetId) {
  286. Boolean flag = false;
  287. Group group = groupService.findByNameAndUserType(groupName, null, Constant.UserType.STREET, streetId);
  288. if (group != null) {
  289. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  290. for (int i = 0; i < userGroups.size(); i++) {
  291. if (userGroups.get(i).getUser_id() == ShiroUtils.getUserId()) {
  292. flag = true;
  293. break;
  294. }
  295. }
  296. }
  297. return flag;
  298. }
  299. /**
  300. * 获取基本信息
  301. *
  302. * @param retreatOptimization
  303. */
  304. private void getFullBaseInfo(RetreatOptimization retreatOptimization) {
  305. Street street = streetService.findById(retreatOptimization.getPlate());
  306. retreatOptimization.setPlateName(street.getName());
  307. retreatOptimization.setUserName(ShiroUtils.getUserName());
  308. if (retreatOptimization.getStatus().equals(Constant.RetreatOptimizationStatus.SUBMIT)){
  309. retreatOptimization.setStatusStr("提交");
  310. }
  311. else if (retreatOptimization.getStatus().equals(Constant.RetreatOptimizationStatus.PENDINGRECEIVED)){
  312. retreatOptimization.setStatusStr("待确认接收");
  313. }
  314. else if (retreatOptimization.getStatus().equals(Constant.RetreatOptimizationStatus.RECEIVED)){
  315. retreatOptimization.setStatusStr("接收成功");
  316. }
  317. else {
  318. retreatOptimization.setStatusStr("退回");
  319. }
  320. //获取类型
  321. String typeStr = dictionaryItemService.findNameByTypeAndValue(
  322. Constant.DictionaryType.RETREAT_OPTIMIZATION, retreatOptimization.getType().toString());
  323. retreatOptimization.setTypeStr(typeStr);
  324. }
  325. /**
  326. * 更新退二优二
  327. *
  328. * @param retreatOptimization
  329. */
  330. public void updateRetreatOptimization(RetreatOptimization retreatOptimization) {
  331. if (retreatOptimization.getId() == null){
  332. throw new NullPointerException("系统错误");
  333. }
  334. RetreatOptimization optimization = this.findById(retreatOptimization.getId());
  335. //更新附件
  336. ProjectMaterial material = new ProjectMaterial();
  337. material.setApply_id(retreatOptimization.getId());
  338. material.setMaterial_type(5);
  339. // 判断类型是否相同
  340. if (!optimization.getType().equals(retreatOptimization.getType())){
  341. //不同类型的材料,先删除原有的材料
  342. List<ProjectMaterial> listByWhere = projectMaterialService.findListByWhere(material);
  343. if (!ObjectUtils.isEmpty(listByWhere)){
  344. for (ProjectMaterial projectMaterial : listByWhere) {
  345. projectMaterial.setDel_flag(true);
  346. projectMaterialService.updateSelective(projectMaterial);
  347. //删除材料文件
  348. Attachment old = new Attachment();
  349. old.setBusiness_type(Constant.Attachment.RETREAT_OPTIMIZATION);
  350. old.setBusiness_id(projectMaterial.getId());
  351. Attachment attachmentOne = attachmentService.findOne(old);
  352. if (attachmentOne != null){
  353. attachmentOne.setDel_flag(true);
  354. attachmentService.updateSelective(attachmentOne);
  355. }
  356. }
  357. }
  358. if (retreatOptimization.getMaterials() != null && retreatOptimization.getMaterials().size() > 0){
  359. List<Template> templateList = retreatOptimization.getMaterials();
  360. for (Template template : templateList) {
  361. //查询已有的materials
  362. material.setTemplate_id(template.getId());
  363. projectMaterialService.insertAndGetId(material);
  364. //更新文件
  365. int fileId = template.getFileDown().getFile_id();
  366. Attachment attachment = attachmentService.findById(fileId);
  367. if (attachment.getBusiness_type() == null){
  368. attachment.setBusiness_id(material.getId());
  369. attachment.setBusiness_type(Constant.Attachment.RETREAT_OPTIMIZATION);
  370. attachmentService.updateSelective(attachment);
  371. }
  372. }
  373. }
  374. }
  375. else {
  376. if (retreatOptimization.getMaterials() != null && retreatOptimization.getMaterials().size() > 0){
  377. List<Template> templateList = retreatOptimization.getMaterials();
  378. for (Template template : templateList) {
  379. //查询已有的materials
  380. material.setTemplate_id(template.getId());
  381. ProjectMaterial one = projectMaterialService.findOne(material);
  382. if (one != null){
  383. //删除已有的文件
  384. Attachment old = new Attachment();
  385. old.setBusiness_type(Constant.Attachment.RETREAT_OPTIMIZATION);
  386. old.setBusiness_id(one.getId());
  387. Attachment attachmentOne = attachmentService.findOne(old);
  388. if (attachmentOne != null){
  389. attachmentOne.setDel_flag(true);
  390. attachmentService.updateSelective(attachmentOne);
  391. }
  392. }
  393. else {
  394. projectMaterialService.insertAndGetId(material);
  395. //更新文件
  396. int fileId = template.getFileDown().getFile_id();
  397. Attachment attachment = attachmentService.findById(fileId);
  398. if (attachment.getBusiness_type() == null){
  399. attachment.setBusiness_id(material.getId());
  400. attachment.setBusiness_type(Constant.Attachment.RETREAT_OPTIMIZATION);
  401. attachmentService.updateSelective(attachment);
  402. }
  403. }
  404. }
  405. }
  406. }
  407. //处于退回状态
  408. if (optimization.getStatus() ==2){
  409. //新增流程
  410. Approval approval = new Approval();
  411. approval.setApply_id(retreatOptimization.getId());
  412. approval.setType(Constant.DictionaryType.RETREAT_OPTIMIZATION);
  413. approval.setOper_type("提交");
  414. approval.setBefore_approvalstatus("2");
  415. approval.setAfter_approvalstatus("1");
  416. Integer departmentId = userService.findById(ShiroUtils.getUserId()).getDepartment_id();
  417. if (departmentId != null){
  418. Department department = departmentService.findById(departmentId);
  419. approval.setDepartment(department.getName());
  420. }
  421. approvalService.insertAndGetId(approval);
  422. }
  423. optimization.setStatus(1);
  424. updateSelective(optimization);
  425. saveMessage(optimization);
  426. }
  427. /**
  428. * 退回
  429. *
  430. * @param id
  431. * @param approvalComment
  432. */
  433. public void retreat(Integer id, String approvalComment) {
  434. //删除代办
  435. waitToDoService.completeAllTODO(id, Constant.DictionaryType.RETREAT_OPTIMIZATION);
  436. RetreatOptimization retreatOptimization = findById(id);
  437. retreatOptimization.setStatus(2);
  438. updateSelective(retreatOptimization);
  439. //更新流程
  440. Approval approval = new Approval();
  441. approval.setApply_id(retreatOptimization.getId());
  442. approval.setType(Constant.DictionaryType.RETREAT_OPTIMIZATION);
  443. approval.setOper_type("退回");
  444. approval.setBefore_approvalstatus("1");
  445. approval.setAfter_approvalstatus("2");
  446. approval.setApproval_comment(approvalComment);
  447. Integer departmentId = userService.findById(ShiroUtils.getUserId()).getDepartment_id();
  448. if (departmentId != null){
  449. Department department = departmentService.findById(departmentId);
  450. approval.setDepartment(department.getName());
  451. }
  452. approvalService.insertAndGetId(approval);
  453. //发送短信
  454. sendPhoneMess(retreatOptimization, "退回");
  455. }
  456. private void sendPhoneMess(RetreatOptimization retreatOptimization, String result) {
  457. //发送短信
  458. try {
  459. String phone = userService.findById(retreatOptimization.getCreate_by()).getPhone();
  460. String templateCode = Constant.SMS_TemplateCode.RETREAT_OPTIMIZATION;
  461. Map<String, String> paramMap = new HashMap<>();
  462. paramMap.put("apply_no", retreatOptimization.getNo());
  463. paramMap.put("result", result);
  464. // paramMap.put("reason", approvalComment);
  465. AlibabaSMSUtil.sendSMSMessage(phone, templateCode, Constant.SINGNAMW, JSONObject.toJSONString(paramMap));
  466. } catch (ClientException e) {
  467. e.printStackTrace();
  468. }
  469. }
  470. /**
  471. * 通过
  472. *
  473. * @param id
  474. * @param approvalComment
  475. */
  476. public void approve(Integer id, String approvalComment) {
  477. //删除代办
  478. waitToDoService.completeTODO(id, Constant.DictionaryType.RETREAT_OPTIMIZATION);
  479. RetreatOptimization retreatOptimization = findById(id);
  480. Integer nextStatus = getNextStatus(retreatOptimization.getStatus(),true);
  481. retreatOptimization.setStatus(nextStatus);
  482. updateSelective(retreatOptimization);
  483. //更新流程
  484. Approval approval = new Approval();
  485. approval.setApply_id(retreatOptimization.getId());
  486. approval.setType(Constant.DictionaryType.RETREAT_OPTIMIZATION);
  487. approval.setOper_type("通过");
  488. approval.setBefore_approvalstatus(retreatOptimization.getStatus().toString());
  489. approval.setAfter_approvalstatus(nextStatus.toString());
  490. approval.setApproval_comment(approvalComment);
  491. Integer departmentId = userService.findById(ShiroUtils.getUserId()).getDepartment_id();
  492. if (departmentId != null){
  493. Department department = departmentService.findById(departmentId);
  494. approval.setDepartment(department.getName());
  495. }
  496. approvalService.insertAndGetId(approval);
  497. //确认接收
  498. if (nextStatus.equals(Constant.RetreatOptimizationStatus.RECEIVED)){
  499. sendPhoneMess(retreatOptimization, "通过");
  500. }
  501. if (nextStatus.equals(Constant.RetreatOptimizationStatus.PENDINGRECEIVED)){
  502. saveMessage(retreatOptimization);
  503. }
  504. }
  505. //获取下一状态
  506. public Integer getNextStatus(Integer currStatus,Boolean isApprove){
  507. if(!isApprove){
  508. //退回
  509. return Constant.RetreatOptimizationStatus.REJECT;
  510. }else{
  511. //通过
  512. if(null !=currStatus){
  513. if(currStatus.equals(Constant.RetreatOptimizationStatus.PENDINGRECEIVED)){
  514. return Constant.RetreatOptimizationStatus.RECEIVED;
  515. }else if(currStatus.equals(Constant.RetreatOptimizationStatus.SUBMIT)){
  516. return Constant.RetreatOptimizationStatus.PENDINGRECEIVED;
  517. }
  518. }
  519. }
  520. return null;
  521. }
  522. }