GoodsServiceImpl.java 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  1. package com.hssx.pcbms.service.impl;
  2. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  3. import com.github.pagehelper.PageHelper;
  4. import com.github.pagehelper.PageInfo;
  5. import com.hssx.pcbms.constant.Constant;
  6. import com.hssx.pcbms.entity.*;
  7. import com.hssx.pcbms.entity.vo.*;
  8. import com.hssx.pcbms.mapper.*;
  9. import com.hssx.pcbms.service.GoodsNoService;
  10. import com.hssx.pcbms.service.GoodsService;
  11. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  12. import com.hssx.pcbms.service.MaintainRecordService;
  13. import com.hssx.pcbms.service.OperateRecordService;
  14. import com.hssx.pcbms.util.*;
  15. import lombok.extern.slf4j.Slf4j;
  16. import org.springframework.beans.BeanUtils;
  17. import org.springframework.beans.factory.annotation.Value;
  18. import org.springframework.stereotype.Service;
  19. import org.springframework.util.CollectionUtils;
  20. import org.springframework.web.bind.annotation.RequestParam;
  21. import org.springframework.web.multipart.MultipartFile;
  22. import javax.annotation.Resource;
  23. import javax.servlet.http.HttpServletResponse;
  24. import java.text.SimpleDateFormat;
  25. import java.time.LocalDate;
  26. import java.time.format.DateTimeFormatter;
  27. import java.util.*;
  28. import java.util.stream.Collectors;
  29. /**
  30. * <p>
  31. * 服务实现类
  32. * </p>
  33. *
  34. * @author 吴涛涛
  35. * @since 2019-10-25
  36. */
  37. @Service
  38. @Slf4j
  39. public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements GoodsService {
  40. @Resource
  41. private GoodsMapper goodsMapper;
  42. @Resource
  43. private GoodsNoMapper goodsNoMapper;
  44. @Resource
  45. private GoodsNoService goodsNoService;
  46. @Value("${upload.path}")
  47. private String path;
  48. @Resource
  49. private OperateRecordMapper operateRecordMapper;
  50. @Resource
  51. private UserMapper userMapper;
  52. @Resource
  53. private OperateRecordService operateRecordService;
  54. @Resource
  55. private MaintainRecordService maintainRecordService;
  56. @Resource
  57. private MaintainRecordMapper maintainRecordMapper;
  58. @Resource
  59. private GoodsTagsMapper goodsTagsMapper;
  60. @Resource
  61. private NewsNoticeMapper newsNoticeMapper;
  62. @Resource
  63. private NewsNoticeUserMapper newsNoticeUserMapper;
  64. @Resource
  65. private RacksEquipmentMapper racksEquipmentMapper;
  66. @Override
  67. public HttpRespMsg add(GoodsVO goodsVO) {
  68. HttpRespMsg msg = new HttpRespMsg();
  69. Integer count = goodsNoMapper.selectCount(new QueryWrapper<GoodsNo>().eq("division_code", goodsVO.getDeptStr()).eq("suffix_code", goodsVO.getGoodStr()).last("limit 1"));
  70. if (count > 0) {
  71. msg.setError("当前编号组合已存在,请更换编号组合后重试。");
  72. return msg;
  73. }
  74. Goods goods = new Goods();
  75. BeanUtils.copyProperties(goodsVO, goods);
  76. List<GoodsNo> list = new ArrayList<>();
  77. goods.setSuffixCode(goodsVO.getGoodStr());
  78. goods.setDivisionCode(goodsVO.getDeptStr());
  79. goods.setCreatorId(goodsVO.getUserId());
  80. goodsMapper.insert(goods);
  81. String mouldNo = goodsVO.getDeptStr() + "-" + goodsVO.getGoodStr();
  82. if (0 != goodsVO.getNumber()) {
  83. for (int i = 1; i <= goodsVO.getNumber(); i++) {
  84. GoodsNo goodsNo = new GoodsNo();
  85. goodsNo.setGoodsId(goods.getId());
  86. goodsNo.setModelNo(mouldNo + String.format("%04d", i));
  87. goodsNo.setSuffixCode(goodsVO.getGoodStr());
  88. goodsNo.setDivisionCode(goodsVO.getDeptStr());
  89. list.add(goodsNo);
  90. }
  91. goodsNoService.saveBatch(list);
  92. } else {
  93. msg.setError("资产数量必须大于零");
  94. }
  95. return msg;
  96. }
  97. @Override
  98. public HttpRespMsg updateInfo(Goods goods, MultipartFile file) {
  99. HttpRespMsg msg = new HttpRespMsg();
  100. goodsMapper.updateById(goods);
  101. return msg;
  102. }
  103. @Override
  104. public HttpRespMsg getList(PageUtil page, String keyName, Integer tagId, Integer uid) {
  105. System.out.println(tagId);
  106. HttpRespMsg msg = new HttpRespMsg();
  107. PageHelper.startPage(page.getPageNum(), page.getPageSize());
  108. List<GoodsVO> list = new ArrayList<>();
  109. // if(tagId != null){
  110. // if(tagId==-1){
  111. // //机柜列表
  112. //// list = goodsMapper.getRackListBycondition(keyName, tagId, uid);
  113. //// PageInfo<GoodsVO> info = new PageInfo<>(list);
  114. //// msg.data = info;
  115. //// return msg;
  116. // }else if(tagId==-2){
  117. //设备列表
  118. // QueryWrapper<GoodsNo> qw = new QueryWrapper();
  119. // if(keyName!=null && !"".equals(keyName)){
  120. // qw.eq("device_name",keyName);
  121. // }
  122. // List <GoodsNo> equipmentList = goodsNoMapper.selectList(qw.eq("type",1).select("id", "model_no", "state","indate", "goods_id"
  123. // ,"user_id", "update_indate", "is_maintain", "type", " device_name", "device_model", "good_sn_no",
  124. // "label_id", "rack_id", "model_id", "u_bit_num","current_state","alarm_level").orderByDesc("id"));
  125. // PageInfo<GoodsNo> info = new PageInfo<>(equipmentList);
  126. // msg.data = info;
  127. // return msg;
  128. // }else{
  129. // list = goodsMapper.getListBycondition(keyName, tagId, uid);
  130. // PageInfo<GoodsVO> info = new PageInfo<>(list);
  131. // msg.data = info;
  132. // return msg;
  133. // }
  134. // }else{
  135. Integer goodType = 0;
  136. if(tagId !=null){
  137. if(tagId==-1){
  138. goodType = 1;
  139. }else if(tagId==-2){
  140. goodType = 2;
  141. }
  142. }
  143. if(goodType==0){
  144. list = goodsMapper.getListBycondition(keyName, tagId, uid);
  145. PageInfo<GoodsVO> info = new PageInfo<>(list);
  146. msg.data = info;
  147. }else{
  148. list = goodsMapper.getRackListBycondition(keyName, tagId, uid,goodType);
  149. PageInfo<GoodsVO> info = new PageInfo<>(list);
  150. msg.data = info;
  151. }
  152. // }
  153. return msg;
  154. }
  155. @Override
  156. public HttpRespMsg del(Goods goods) {
  157. HttpRespMsg msg = new HttpRespMsg();
  158. goods.setIsDelete(1);
  159. goodsMapper.updateById(goods);
  160. return msg;
  161. }
  162. @Override
  163. public HttpRespMsg delNo(GoodsNo goodsNo) {
  164. HttpRespMsg msg = new HttpRespMsg();
  165. GoodsNo no = goodsNoMapper.selectById(goodsNo.getId());
  166. if (no != null && no.getState() == 0) {
  167. goodsNoMapper.deleteById(goodsNo.getId());
  168. } else {
  169. msg.setError("操作失败,该编号对应的资产不存在或者处于非空闲状态。");
  170. }
  171. return msg;
  172. }
  173. @Override
  174. public HttpRespMsg getDetail(Integer id) {
  175. HttpRespMsg msg = new HttpRespMsg();
  176. Goods goods = goodsMapper.selectById(id);
  177. Map<String,Object> map = new HashMap<>();
  178. if(goods.getGoodType()!=0){
  179. List<Integer> equipmentIds = racksEquipmentMapper.selectList(new QueryWrapper<RacksEquipment>().eq("rack_goods_id", id)).stream().map(RacksEquipment::getEquipmentGoodsId).collect(Collectors.toList());
  180. if(equipmentIds.size()>0){
  181. List<GoodsVO> list = goodsMapper.getEuipmentList(equipmentIds);
  182. map.put("equipments",list);
  183. }
  184. GoodsVO vo = goodsMapper.getDetail(id);
  185. map.put("rack",vo);
  186. msg.data = map;
  187. return msg;
  188. }else{
  189. GoodsVO vo = goodsMapper.getDetail(id);
  190. msg.data = vo;
  191. return msg;
  192. }
  193. }
  194. @Override
  195. public HttpRespMsg handle(GoodsNo goodsNo, Integer currentUserId) {
  196. HttpRespMsg msg = new HttpRespMsg();
  197. User user = userMapper.selectById(currentUserId);
  198. GoodsNo no = goodsNoMapper.selectById(goodsNo.getId());
  199. goodsNo.setGoodsId(no.getGoodsId());
  200. goodsNoMapper.updateById(goodsNo);
  201. //添加处置记录
  202. OperateRecord operateRecord = new OperateRecord();
  203. String oldState = "";
  204. String nowState = "";
  205. if (no.getState() == 0) {
  206. oldState = "未用";
  207. } else if (no.getState() == 1){
  208. oldState = "在用";
  209. User usering = userMapper.selectById(no.getUserId());
  210. oldState = oldState + ("(" + usering.getName() + "/" + usering.getPhone() + ")");
  211. }
  212. if (goodsNo.getState() == 0) {
  213. nowState = "未用";
  214. } else if (goodsNo.getState() == 1) {
  215. nowState = "在用";
  216. User usering = userMapper.selectById(goodsNo.getUserId());
  217. nowState = nowState + ("(" + usering.getName() + "/" + usering.getPhone() + ")");
  218. } else if (goodsNo.getState() == 3) {
  219. nowState = "报废";
  220. }
  221. String content = Constant.HANDLE_CONTENT.replace("oldState", oldState).replace("newState", nowState);
  222. operateRecord.setContent(content);
  223. operateRecord.setGoodId(no.getGoodsId());
  224. operateRecord.setGoodNoId(no.getId());
  225. operateRecord.setGoodState(goodsNo.getState());
  226. operateRecord.setUserId(currentUserId);
  227. operateRecord.setUserName(user.getName());
  228. operateRecord.setModelNo(no.getModelNo());
  229. operateRecordMapper.insert(operateRecord);
  230. return msg;
  231. }
  232. @Override
  233. public HttpRespMsg operateList(Goods goods, PageUtil page) {
  234. HttpRespMsg msg = new HttpRespMsg();
  235. PageHelper.startPage(page.getPageNum(), page.getPageSize());
  236. List<OperateRecordVO> list = operateRecordMapper.selectCondition(goods);
  237. PageInfo<OperateRecordVO> info = new PageInfo<>(list);
  238. msg.data = info;
  239. return msg;
  240. }
  241. @Override
  242. public HttpRespMsg goodsNoDetailById(GoodsNo goodsNo) {
  243. HttpRespMsg msg = new HttpRespMsg();
  244. GoodsNo oldGoodsNo = goodsNoMapper.selectById(goodsNo.getId());
  245. GoodsNoVO vo = new GoodsNoVO();
  246. BeanUtils.copyProperties(oldGoodsNo, vo);
  247. User user = userMapper.selectById(oldGoodsNo.getUserId());
  248. if (user != null) {
  249. vo.setUsername(user.getName());
  250. }
  251. msg.data = vo;
  252. return msg;
  253. }
  254. @Override
  255. public HttpRespMsg goodsNoAdd(GoodsNo goodsNo, Integer count) {
  256. HttpRespMsg msg = new HttpRespMsg();
  257. GoodsNo oldGoodsNo = goodsNoMapper.selectOne(new QueryWrapper<GoodsNo>().eq("goods_id", goodsNo.getGoodsId()).orderByDesc("id").last("limit 1"));
  258. Goods goods = goodsMapper.selectById(goodsNo.getGoodsId());
  259. Integer start = 0;
  260. String prefix = goods.getDivisionCode()+"-"+goods.getSuffixCode();
  261. if(goods != null){
  262. if (oldGoodsNo != null) {
  263. start = Integer.parseInt(oldGoodsNo.getModelNo().substring(oldGoodsNo.getModelNo().length() - 4));
  264. List<GoodsNo> goodsNoList = new ArrayList<>();
  265. for (int i = 1; i <= count; i++) {
  266. GoodsNo no = new GoodsNo();
  267. String format = String.format("%04d", start + i);
  268. BeanUtils.copyProperties(oldGoodsNo, no);
  269. no.setModelNo(prefix + format);
  270. no.setId(null);
  271. goodsNoList.add(no);
  272. }
  273. if (!CollectionUtils.isEmpty(goodsNoList)) {
  274. goodsNoService.saveBatch(goodsNoList);
  275. }
  276. } else {
  277. List<GoodsNo> goodsNoList = new ArrayList<>();
  278. for (int i = 1; i <= count; i++) {
  279. GoodsNo no = new GoodsNo();
  280. String format = String.format("%04d", start + i);
  281. no.setModelNo(prefix + format);
  282. no.setGoodsId(goodsNo.getGoodsId());
  283. no.setDivisionCode(goods.getDivisionCode());
  284. no.setSuffixCode(goods.getSuffixCode());
  285. goodsNoList.add(no);
  286. }
  287. if (!CollectionUtils.isEmpty(goodsNoList)) {
  288. goodsNoService.saveBatch(goodsNoList);
  289. }
  290. }
  291. }
  292. return msg;
  293. }
  294. @Override
  295. public HttpRespMsg distribute(GoodsNo goodsNo) {
  296. HttpRespMsg msg = new HttpRespMsg();
  297. Integer count = goodsNoMapper.selectCount(new QueryWrapper<GoodsNo>().eq("division_code", goodsNo.getDivisionCode()).eq("suffix_code", goodsNo.getSuffixCode()).last("limit 1"));
  298. if (count > 0) {
  299. msg.setError("当前编号组合已存在,请更换编号组合后重试。");
  300. return msg;
  301. }
  302. Goods goods = new Goods();
  303. goods.setDivisionCode(goodsNo.getDivisionCode());
  304. goods.setSuffixCode(goodsNo.getSuffixCode());
  305. goods.setId(goodsNo.getGoodsId());
  306. goodsMapper.updateById(goods);
  307. List<GoodsNo> goodsNoList = goodsNoMapper.selectList(new QueryWrapper<GoodsNo>().eq("goods_id", goodsNo.getGoodsId()));
  308. String suffixModelNo = goodsNo.getDivisionCode() + "-" + goodsNo.getSuffixCode();
  309. for (GoodsNo no : goodsNoList) {
  310. no.setModelNo(suffixModelNo + no.getModelNo().substring(no.getModelNo().length() - 4));
  311. no.setSuffixCode(goodsNo.getSuffixCode());
  312. no.setDivisionCode(goodsNo.getDivisionCode());
  313. }
  314. if (!CollectionUtils.isEmpty(goodsNoList)) {
  315. goodsNoService.updateBatchById(goodsNoList);
  316. }
  317. return msg;
  318. }
  319. @Override
  320. public HttpRespMsg maintain(MaintainRecordVO operateRecordVO) {
  321. HttpRespMsg msg = new HttpRespMsg();
  322. List<MaintainRecord> operateRecords = new ArrayList<>();
  323. if (null != operateRecordVO.getIds()) {
  324. List<Integer> idList = ListUtil.convertIntegerIdsArrayToList(operateRecordVO.getIds());
  325. if(idList.size()>0){
  326. List<GoodsNo> goodsNo = goodsNoMapper.selectList(new QueryWrapper<GoodsNo>().in("id", idList));
  327. for (Integer id : idList) {
  328. MaintainRecord operateRecord = new MaintainRecord();
  329. BeanUtils.copyProperties(operateRecordVO, operateRecord);
  330. operateRecord.setGoodsNoId(id);
  331. for (GoodsNo no : goodsNo) {
  332. if(id.equals(no.getId())){
  333. operateRecord.setModelNo(no.getModelNo());
  334. }
  335. }
  336. operateRecords.add(operateRecord);
  337. }
  338. }
  339. maintainRecordService.saveBatch(operateRecords);
  340. //将原来待维护的状态更新为正常
  341. GoodsNo goodsNo = new GoodsNo();
  342. goodsNo.setGoodsId(operateRecordVO.getGoodsId());
  343. goodsNo.setIsMaintain(0);
  344. goodsNoMapper.update(goodsNo, new QueryWrapper<GoodsNo>().in("id", idList));
  345. } else {
  346. msg.setError("资产对应的编号id不存在");
  347. }
  348. return msg;
  349. }
  350. @Override
  351. public HttpRespMsg isMaintainList(Goods goods) {
  352. HttpRespMsg msg = new HttpRespMsg();
  353. List<GoodsNo> goodsNoList = goodsNoMapper.selectList(new QueryWrapper<GoodsNo>().eq("goods_id", goods.getId()).eq("is_maintain", 1));//1-需要保养
  354. msg.data = goodsNoList;
  355. return msg;
  356. }
  357. @Override
  358. public HttpRespMsg isMaintainRecord(Goods goods, PageUtil page) {
  359. HttpRespMsg msg = new HttpRespMsg();
  360. PageHelper.startPage(page.getPageNum(), page.getPageSize());
  361. List<MaintainRecordVO> list = maintainRecordMapper.getRecordList(goods);
  362. PageInfo<MaintainRecordVO> info = new PageInfo<>(list);
  363. msg.data = info;
  364. return msg;
  365. }
  366. @Override
  367. public HttpRespMsg myList(PageUtil page, String keyName, Integer uid) {
  368. HttpRespMsg msg = new HttpRespMsg();
  369. Integer start = (page.getPageNum() - 1) * page.getPageSize();
  370. List<GoodsVO> list = goodsMapper.selectMyList(start, page.getPageSize(), uid);
  371. Integer total = goodsMapper.selectMyList(null, null, uid).size();
  372. PageUtil<GoodsVO> pageInfo = new PageUtil<>();
  373. pageInfo.setList(list);
  374. pageInfo.setTotal(total);
  375. pageInfo.setPageSize(page.getPageSize());
  376. pageInfo.setPages(total);
  377. msg.data = pageInfo;
  378. return msg;
  379. }
  380. @Override
  381. public HttpRespMsg handelRecordExcel(Goods goods, HttpServletResponse response) {
  382. HttpRespMsg msg = new HttpRespMsg();
  383. List<OperateRecordVO> recordList = operateRecordMapper.selectCondition(goods);
  384. List<List<String>> list = new ArrayList<List<String>>();
  385. //标题
  386. List<String> titleList = new ArrayList<String>();
  387. titleList.add("资产编号");
  388. titleList.add("处置人");
  389. titleList.add("处置时间");
  390. titleList.add("操作内容");
  391. list.add(titleList);
  392. SimpleDateFormat dateSdf2 = new SimpleDateFormat("yyyy年MM月dd+HH时mm分ss秒");
  393. for (OperateRecordVO dynamic : recordList) {
  394. List<String> rowList = new ArrayList<String>();
  395. //资产编号
  396. rowList.add(dynamic.getModelNo());
  397. //处置人
  398. rowList.add(dynamic.getUserName());
  399. //处置时间
  400. rowList.add(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(dynamic.getIndate()));
  401. //操作内容
  402. rowList.add(dynamic.getContent());
  403. list.add(rowList);
  404. }
  405. Goods newGoods = goodsMapper.selectById(goods.getId());
  406. String fileUrl = ExcelUtil.exportGeneralExcelByTitleAndList(response, newGoods.getName()+dateSdf2.format(new Date()), list, path);
  407. msg.data = fileUrl;
  408. return msg;
  409. }
  410. @Override
  411. public HttpRespMsg isMaintainExcel(Goods goods, HttpServletResponse response) {
  412. HttpRespMsg msg = new HttpRespMsg();
  413. List<MaintainRecordVO> recordList = maintainRecordMapper.getRecordList(goods);
  414. List<List<String>> list = new ArrayList<List<String>>();
  415. //标题
  416. List<String> titleList = new ArrayList<String>();
  417. titleList.add("资产编号");
  418. titleList.add("维护人");
  419. titleList.add("维护人号码");
  420. titleList.add("维护公司");
  421. titleList.add("维护公司电话");
  422. titleList.add("操作日期");
  423. list.add(titleList);
  424. SimpleDateFormat dateSdf2 = new SimpleDateFormat("yyyy年MM月dd+HH时mm分ss秒");
  425. for (MaintainRecordVO dynamic : recordList) {
  426. List<String> rowList = new ArrayList<String>();
  427. //资产编号
  428. rowList.add(dynamic.getModelNo());
  429. //维护人
  430. rowList.add(dynamic.getOperator());
  431. //维护人号码
  432. rowList.add(dynamic.getOperatorPhone());
  433. //维护公司
  434. rowList.add(dynamic.getCompany());
  435. //维护公司电话
  436. rowList.add(dynamic.getCompanyPhone());
  437. //操作日期
  438. rowList.add(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(dynamic.getIndate())
  439. );
  440. list.add(rowList);
  441. }
  442. Goods newGoods = goodsMapper.selectById(goods.getId());
  443. String fileUrl = ExcelUtil.exportGeneralExcelByTitleAndList(response, newGoods.getName()+dateSdf2.format(new Date()), list, path);
  444. msg.data = fileUrl;
  445. return msg;
  446. }
  447. @Override
  448. public HttpRespMsg listExcel(PageUtil page, String keyName, Integer tagId, Integer uid,HttpServletResponse response) {
  449. HttpRespMsg msg = new HttpRespMsg();
  450. List<List<String>> list = new ArrayList<List<String>>();
  451. //标题
  452. List<String> titleList = new ArrayList<String>();
  453. titleList.add("资产名称");
  454. titleList.add("所属分类");
  455. titleList.add("型号");
  456. titleList.add("数量");
  457. titleList.add("单位");
  458. titleList.add("生产厂家");
  459. list.add(titleList);
  460. List<GoodsVO> goodsVOList = goodsMapper.getListBycondition(keyName, tagId, uid);
  461. List<GoodsTags> goodsTags = goodsTagsMapper.selectList(new QueryWrapper<>());
  462. SimpleDateFormat dateSdf2 = new SimpleDateFormat("yyyy年MM月dd+HH时mm分ss秒");
  463. for (GoodsVO dynamic : goodsVOList) {
  464. List<String> rowList = new ArrayList<String>();
  465. //资产名称
  466. rowList.add(dynamic.getName());
  467. //所属分类
  468. for (GoodsTags goodsTag : goodsTags) {
  469. if(dynamic.getTagId().equals(goodsTag.getId())){
  470. rowList.add(goodsTag.getName());
  471. }
  472. }
  473. //型号
  474. rowList.add(dynamic.getModelNumber());
  475. //数量
  476. rowList.add(dynamic.getGoodsNosVO().size()+"");
  477. //单位
  478. rowList.add(dynamic.getUnit());
  479. //生产厂家
  480. rowList.add(dynamic.getFactory());
  481. list.add(rowList);
  482. }
  483. String fileUrl = ExcelUtil.exportGeneralExcelByTitleAndList(response, "资产"+dateSdf2.format(new Date()), list, path);
  484. msg.data = fileUrl;
  485. return msg;
  486. }
  487. @Override
  488. public HttpRespMsg goodsMaintainChecking() {
  489. HttpRespMsg msg = new HttpRespMsg();
  490. log.info("处理维护资产的定时任务启动了");
  491. // List<Goods> goodsLists = goodsMapper.selectList(new QueryWrapper<>());
  492. List<GoodsVO> goodsLists = goodsMapper.getListBycondition(null, null, null);
  493. String nowDate = DateTimeFormatter.ofPattern("yyyy-MM-dd").format(LocalDate.now());
  494. for (GoodsVO good : goodsLists) {
  495. if(nowDate.equals(good.getNextIndate())){
  496. GoodsNo no = new GoodsNo();
  497. no.setGoodsId(good.getId());
  498. no.setIsMaintain(1);
  499. //此处利用update配合修改条件和条件构造器来实现批量修改数据
  500. goodsNoMapper.update(no, new QueryWrapper<GoodsNo>().eq("goods_id", good.getId()));
  501. //条件通知消息
  502. NewsNotice newsNotice = new NewsNotice();
  503. newsNotice.setNoticeType(0);
  504. newsNotice.setRefId(good.getId());
  505. newsNotice.setRafName(good.getName());
  506. String content = Constant.GOODS_MATAIN_CONTENT;
  507. content = content.replace("name",good.getName()).replace("num",good.getGoodsNos().size()+good.getUnit());
  508. newsNotice.setContent(content);
  509. newsNoticeMapper.insert(newsNotice);
  510. List<User> users = userMapper.selectOperateUsersListByCondition();
  511. //通知所有操作员
  512. for (User user : users) {
  513. NewsNoticeUser noticeUser = new NewsNoticeUser();
  514. noticeUser.setNewsId(newsNotice.getId());
  515. noticeUser.setUserId(user.getId());
  516. newsNoticeUserMapper.insert(noticeUser);
  517. }
  518. }
  519. }
  520. return msg;
  521. }
  522. public static void main(String[] args) {
  523. // String format = String.format("%04d", 0);
  524. // System.out.println(format);
  525. // System.out.println("QWE-ASDF0001".substring(0, "QWE-ASDF0001".length() - 4));
  526. // System.out.println("QWE-ASDF0001".substring("QWE-ASDF0001".length() - 4));
  527. // System.out.println(Integer.parseInt("0001"));
  528. List<Integer> list = new ArrayList<>();
  529. System.out.println(list.stream().map(a ->a).collect(Collectors.toList()));
  530. String proId = "1111111";
  531. String sql = "select DESCS DESCS3 ADUITDATE ADUITDATE3 from t_pilot_flowaduit where proid='"+proId+"' and processinstanceid =(select processinstanceid from t_dtjms_start_report where pro_id='"+proId+"') and workitemname='开工报告建设审核'";
  532. sql = "select DESCS DESCS2,ADUITDATE ADUITDATE2 from t_pilot_flowaduit where proid='"+proId+"' and processinstanceid =(select processinstanceid from t_dtjms_start_command where pro_id='"+proId+"') and workitemname='建设负责人审核'"; System.out.println(sql);
  533. sql = "select UPLOAD_PATH from t_dtjms_upload_document where gx_id in("
  534. +"select gx_id from t_dtjms_build_log where pro_id='"
  535. +proId+"') and type=30 and Upload_Time >= '"+15+" 00:00:00"+"' and UploadTime <='"+15+" 23:59:59"+"'";
  536. System.out.println(sql);
  537. }
  538. }