DilNoticeServiceImpl.java 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. package com.steerinfo.dil.service.impl;
  2. import com.steerinfo.dil.mapper.DilNoticeMapper;
  3. import com.steerinfo.dil.model.DilNotice;
  4. import com.steerinfo.dil.service.IDilNoticeService;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.scheduling.annotation.Scheduled;
  7. import org.springframework.stereotype.Service;
  8. import java.util.*;
  9. import java.math.BigDecimal;
  10. /**
  11. * DilNotice服务实现:
  12. * @author generator
  13. * @version 1.0-SNAPSHORT 2021-12-08 02:21
  14. * 类描述
  15. * 修订历史:
  16. * 日期:2021-12-08
  17. * 作者:generator
  18. * 参考:
  19. * 描述:DilNotice服务实现
  20. * @see null
  21. * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved.
  22. */
  23. @Service(value = "dilNoticeService")
  24. public class DilNoticeServiceImpl implements IDilNoticeService {
  25. @Autowired
  26. private DilNoticeMapper dilNoticeMapper;
  27. /**
  28. * 获取通知信息
  29. * */
  30. @Override
  31. public List<Map<String, Object>> getNoticeList(Map<String, Object> mapVal) {
  32. return dilNoticeMapper.getNoticeList(mapVal);
  33. }
  34. /**
  35. * 承运商获取通知信息
  36. * */
  37. @Override
  38. public List<Map<String, Object>> getCarrierNoticeList(Map<String, Object> mapVal) {
  39. List<Map<String, Object>> mapList=dilNoticeMapper.getCarrierNoticeList(mapVal);
  40. for (Map<String, Object> map : mapList) {
  41. if ("1".equals(map.get("status"))){
  42. //有历史数据(替换)
  43. map.put("noticeTitle",map.get("updateTitle"));
  44. map.put("noticeContent",map.get("updateContent"));
  45. map.put("insertUsername",map.get("updateUsername"));
  46. map.put("insertTime",map.get("updateTime"));
  47. }
  48. }
  49. return mapList;
  50. }
  51. /**
  52. * 销售公司获取通知信息
  53. * */
  54. @Override
  55. public List<Map<String, Object>> getMarketingNoticeList(Map<String, Object> mapVal) {
  56. List<Map<String, Object>> mapList=dilNoticeMapper.getMarketingNoticeList(mapVal);
  57. for (Map<String, Object> map : mapList) {
  58. if ("1".equals(map.get("status"))){
  59. //有历史数据(替换)
  60. map.put("noticeTitle",map.get("updateTitle"));
  61. map.put("noticeContent",map.get("updateContent"));
  62. map.put("insertUsername",map.get("updateUsername"));
  63. map.put("insertTime",map.get("updateTime"));
  64. }
  65. }
  66. return mapList;
  67. }
  68. /**
  69. * 收货用户获取通知信息
  70. * */
  71. @Override
  72. public List<Map<String, Object>> getClientNoticeList(Map<String, Object> mapVal) {
  73. List<Map<String, Object>> mapList= dilNoticeMapper.getClientNoticeList(mapVal);
  74. for (Map<String, Object> map : mapList) {
  75. if ("1".equals(map.get("status"))){
  76. //有历史数据(替换)
  77. map.put("noticeTitle",map.get("updateTitle"));
  78. map.put("noticeContent",map.get("updateContent"));
  79. map.put("insertUsername",map.get("updateUsername"));
  80. map.put("insertTime",map.get("updateTime"));
  81. }
  82. }
  83. return mapList;
  84. }
  85. @Override
  86. public List<Map<String, Object>> getNewNoticeByPermission(BigDecimal permission) {
  87. return dilNoticeMapper.getNewNoticeByPermission(permission);
  88. }
  89. /**
  90. * 增加通知信息
  91. * */
  92. @Override
  93. /*这里是解决前端毛病所妥协的结果,前端拿不到value值,只能拿到name也就是key值,这里在后端强行将key转为value值QAQ*/
  94. public int insertNotice(DilNotice dilNotice) {
  95. int result=0;
  96. dilNotice.setDeleted(new BigDecimal(0));
  97. dilNotice.setInsertTime(dilNotice.getInsertTime());
  98. dilNotice.setNoticeId(dilNoticeMapper.selectNoticeId());
  99. dilNotice.setStatus("0");
  100. if(dilNotice.getPermissions()!=null){
  101. if(dilNotice.getPermissions().equals("承运商")){
  102. dilNotice.setPermission("chengyunshang");
  103. }
  104. else if(dilNotice.getPermissions().equals("销售公司")){
  105. dilNotice.setPermission("wuliuyunshubu");
  106. }
  107. else if(dilNotice.getPermissions().equals("收货客户")){
  108. dilNotice.setPermission("shouhuokehu");
  109. }else{
  110. dilNotice.setPermission("qita");
  111. /*dilNoticeMapper.insertSelective(dilNotice);
  112. result +=dilNoticeMapper.insertIntoNoticeUser1(dilNotice);
  113. return result;*/
  114. }
  115. }
  116. //需要手动设置发布人
  117. /*dilNotice.setInsertUsername("admin");*/
  118. result+=dilNoticeMapper.insertSelective(dilNotice);
  119. /*if (result==0){
  120. dilNoticeMapper.insertIntoNoticeUser(dilNotice);
  121. }*/
  122. return result;
  123. }
  124. /**
  125. * @author:zyf
  126. * @version:2.0
  127. * @Date:2022-10-14
  128. * @Description:发布通知
  129. */
  130. @Override
  131. public int releaseNotice(DilNotice dilNotice) {
  132. //发布通知
  133. //1.先判断permission是否有值
  134. //2.看notice有无历史的修改数据
  135. //3.发布
  136. int result=0;
  137. //发布的通知
  138. DilNotice dilNotice2=new DilNotice();
  139. if (dilNotice.getPermission()!=null){
  140. //查询是否有历史修改数据
  141. DilNotice dilNotice1 = dilNoticeMapper.gethistoryorgCode(dilNotice.getNoticeId());
  142. //历史数据有值与否(1为有值,0为没有值)
  143. if ("1".equals(dilNotice1.getStatus())){
  144. dilNoticeMapper.deleteNoticeUsers(dilNotice.getNoticeId());
  145. //1.判断时间是否需要修改(1.1)
  146. Date updateTime = dilNotice1.getUpdateTime();
  147. if (updateTime.compareTo(new Date())>0){
  148. //时间大于当前时间的不动
  149. dilNotice2.setInsertTime(updateTime);
  150. }else {
  151. //时间小于等于当前时间的,时间变为当前时间
  152. dilNotice2.setInsertTime(new Date());
  153. }
  154. //历史数据
  155. dilNotice2.setNoticeId(dilNotice.getNoticeId());
  156. dilNotice2.setNoticeTitle(dilNotice1.getUpdateTitle());
  157. dilNotice2.setNoticeContent(dilNotice1.getUpdateContent());
  158. dilNotice2.setInsertUsername(dilNotice1.getUpdateUsername());
  159. dilNoticeMapper.updatehistorydata(dilNotice2);
  160. if ("qita".equals(dilNotice.getPermission())){
  161. //全部要单独
  162. result+=dilNoticeMapper.insertIntoNoticeUser1(dilNotice);
  163. }else {
  164. result+=dilNoticeMapper.insertIntoNoticeUser(dilNotice);
  165. }
  166. }else {
  167. //判断时间是否需要修改(1.2)
  168. Date insertTime =dilNotice.getInsertTime();
  169. dilNoticeMapper.deleteNoticeUsers(dilNotice.getNoticeId());
  170. if (insertTime.compareTo(new Date())>0){
  171. //时间大于当前时间的不动
  172. dilNotice2.setInsertTime(dilNotice.getInsertTime());
  173. }else {
  174. //时间小于等于当前时间的,时间变为当前时间
  175. dilNotice2.setInsertTime(new Date());
  176. }
  177. dilNotice2.setNoticeId(dilNotice.getNoticeId());
  178. dilNoticeMapper.updateTime(dilNotice2);
  179. if ("qita".equals(dilNotice.getPermission())){
  180. //全部要单独
  181. result+=dilNoticeMapper.insertIntoNoticeUser1(dilNotice);
  182. }else {
  183. result+=dilNoticeMapper.insertIntoNoticeUser(dilNotice);
  184. }
  185. }
  186. }else {
  187. return 0;
  188. }
  189. return result;
  190. }
  191. /**
  192. * 修改通知信息
  193. * */
  194. @Override
  195. public int updateNotice(DilNotice dilNotice) {
  196. dilNotice.setUpdateTime(new Date());
  197. //存储修改过后的内容
  198. DilNotice dilNotice1=new DilNotice();
  199. dilNotice.setUpdateUsername("admin");
  200. if ("承运商".equals(dilNotice.getPermission())){
  201. dilNotice1.setPermission("chengyunshang");
  202. }else if ("销售公司".equals(dilNotice.getPermission())){
  203. dilNotice1.setPermission("wuliuyunshubu");
  204. }else if ("收货客户".equals(dilNotice.getPermission())){
  205. dilNotice1.setPermission("shouhuokehu");
  206. }else {
  207. dilNotice1.setPermission("qita");
  208. }
  209. String code = dilNoticeMapper.getorgCode(dilNotice.getNoticeId());
  210. dilNotice1.setUpdateTitle(dilNotice.getNoticeTitle());
  211. dilNotice1.setUpdateContent(dilNotice.getNoticeContent());
  212. dilNotice1.setUpdateTime(dilNotice.getInsertTime());
  213. dilNotice1.setUpdateUsername(dilNotice.getInsertUsername());
  214. dilNotice1.setStatus("1");
  215. dilNotice1.setNoticeId(dilNotice.getNoticeId());
  216. return dilNoticeMapper.modifyData(dilNotice1);
  217. }
  218. /**
  219. * @author:zyf
  220. * @version:1.0
  221. * @Date:2022-09-24
  222. * @Description:修改用户通知的相关信息
  223. */
  224. @Override
  225. public int updateNoticeStatus(String userId,int noticeId) {
  226. dilNoticeMapper.updatestatus(userId,noticeId);
  227. return dilNoticeMapper.gettaskAllNum(userId);
  228. }
  229. /**
  230. * 删除通知信息
  231. * */
  232. @Override
  233. public int deleteNotice(BigDecimal id) {
  234. DilNotice dilNotice = dilNoticeMapper.selectByPrimaryKey(id);
  235. dilNotice.setDeleted(new BigDecimal(1));
  236. //删除中间表信息
  237. dilNoticeMapper.deleteNoticeUsers(id);
  238. //删除通知表的数据
  239. return dilNoticeMapper.deleteNotice(id);
  240. }
  241. //根据用户ID获取用户名字
  242. @Override
  243. public String queryName(String userId) {
  244. return dilNoticeMapper.queryName(userId);
  245. }
  246. /**
  247. * 根据id获取运力信息
  248. * @param id
  249. * @return
  250. */
  251. @Override
  252. public List<Map<String, Object>> getNoticeById(BigDecimal id) {
  253. String status = dilNoticeMapper.getStatus(id);
  254. if ("1".equals(status)){
  255. return dilNoticeMapper.getNoticeById1(id);
  256. }else {
  257. return dilNoticeMapper.getNoticeById(id);
  258. }
  259. }
  260. /**
  261. * @author:zyf
  262. * @version:1.0
  263. * @Date:
  264. * @Description: 获取通知信息数据
  265. */
  266. public List<Map<String,Object>> getNoticeData(String userId){
  267. List<Map<String, Object>> noticeData=new ArrayList<>();
  268. /*if ("chengyunshang".equals(orgcode)){
  269. BigDecimal permission=BigDecimal.valueOf(1);
  270. noticeData = dilNoticeMapper.getNoticeData(permission);
  271. }else if ("xiaoshougongsi".equals(orgcode)){
  272. BigDecimal permission=BigDecimal.valueOf(2);
  273. noticeData = dilNoticeMapper.getNoticeData(permission);
  274. }else if ("shouhuokehu".equals(orgcode)){
  275. BigDecimal permission=BigDecimal.valueOf(3);
  276. noticeData = dilNoticeMapper.getNoticeData(permission);
  277. }else {
  278. noticeData = dilNoticeMapper.getNoticeData1();
  279. }*/
  280. return dilNoticeMapper.getNoticeData(userId);
  281. }
  282. /*
  283. * 获取下拉框
  284. * */
  285. /*
  286. @Override
  287. public List<Map<String,Object>> getCapacityTypeId() {
  288. return rmsCapacityMapper.getCapacityTypeId();
  289. }
  290. @Override
  291. public List<Map<String, Object>> getCarrierId() {
  292. return rmsCapacityMapper.getCarrierId();
  293. }
  294. */
  295. @Override
  296. public List<Map<String, Object>> getNoticeAll(Map<String, Object> mapValue) {
  297. return dilNoticeMapper.getNoticeAll(mapValue);
  298. }
  299. @Override
  300. public int readAll(Map<String, Object> map) {
  301. return dilNoticeMapper.readAll(map);
  302. }
  303. @Override
  304. public List<Map<String, Object>> getNoticeUser(Map<String, Object> mapValue) {
  305. return dilNoticeMapper.getNoticeUser(mapValue);
  306. }
  307. /**
  308. * 查询国内矿采购订单是否符合标准,若不符合则发送给自动化部负责人:(UserId:1012690778083954688)
  309. */
  310. @Scheduled(fixedRate = 1000*60*60)
  311. public void checkPurchaseOrder(){
  312. List<Map<String,Object>> purchaseOrders=dilNoticeMapper.findErrorOrder();
  313. for(Map<String,Object> item:purchaseOrders){
  314. //插入通知表
  315. DilNotice notice=new DilNotice();
  316. notice.setNoticeId(dilNoticeMapper.selectNoticeId());
  317. notice.setNoticeTitle(item.get("purchaseOrderNo")+"订单异常");
  318. notice.setNoticeContent("国内矿订单'"+item.get("purchaseOrderNo")+"'缺少发站!");
  319. notice.setInsertTime(new Date());
  320. notice.setInsertUsername("system");
  321. notice.setDeleted(new BigDecimal(0));
  322. notice.setInsertUpdateRemark(""+item.get("purchaseOrderNo"));
  323. dilNoticeMapper.insertSelective(notice);
  324. //插入通知子表
  325. item.put("noticeId",notice.getNoticeId());
  326. item.put("userId","1012690778083954688");
  327. dilNoticeMapper.insertIntoNoticeUserToOne(item);
  328. }
  329. }
  330. }