BillPcrServiceImpl.java 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700
  1. package com.huimv.receive.service.impl;
  2. import cn.hutool.core.io.FileUtil;
  3. import cn.hutool.core.util.ObjectUtil;
  4. import cn.hutool.http.Header;
  5. import cn.hutool.http.HttpRequest;
  6. import com.alibaba.fastjson.JSONObject;
  7. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  8. import com.baomidou.mybatisplus.core.toolkit.StringUtils;
  9. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  10. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  11. import com.huimv.receive.common.token.TokenSign;
  12. import com.huimv.receive.common.utils.*;
  13. import com.huimv.receive.entity.*;
  14. import com.huimv.receive.entity.dto.PcrDto;
  15. import com.huimv.receive.entity.vo.PcrVo;
  16. import com.huimv.receive.entity.vo.PcrVo1;
  17. import com.huimv.receive.mapper.*;
  18. import com.huimv.receive.service.IBillPcrService;
  19. import org.springframework.beans.factory.annotation.Autowired;
  20. import org.springframework.stereotype.Service;
  21. import org.springframework.transaction.interceptor.TransactionAspectSupport;
  22. import org.springframework.web.multipart.MultipartFile;
  23. import javax.annotation.Resource;
  24. import javax.servlet.http.HttpServletRequest;
  25. import javax.servlet.http.HttpServletResponse;
  26. import java.io.FileOutputStream;
  27. import java.io.IOException;
  28. import java.io.InputStream;
  29. import java.net.HttpURLConnection;
  30. import java.net.URL;
  31. import java.text.DecimalFormat;
  32. import java.text.ParseException;
  33. import java.text.SimpleDateFormat;
  34. import java.time.LocalDateTime;
  35. import java.util.*;
  36. import java.util.concurrent.Executors;
  37. import java.util.concurrent.ScheduledExecutorService;
  38. import java.util.concurrent.TimeUnit;
  39. /**
  40. * <p>
  41. * pcr 表 服务实现类
  42. * </p>
  43. *
  44. * @author author
  45. * @since 2023-07-21
  46. */
  47. @Service
  48. public class BillPcrServiceImpl extends ServiceImpl<BillPcrMapper, BillPcr> implements IBillPcrService {
  49. @Resource
  50. private BillPcrMapper billPcrMapper;
  51. @Override
  52. public Result listPersonalPcr(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
  53. String pageNo = paramsMap.get("pageNum");
  54. String pageSize = paramsMap.get("pageSize");
  55. String vistitType = paramsMap.get("vistitType");
  56. Page<BillPcr> page = new Page<>(Integer.parseInt(pageNo), Integer.parseInt(pageSize));
  57. Page<BillPcr> billPcrPage = billPcrMapper.selectPage(page, new QueryWrapper<BillPcr>().eq(StringUtils.isNotBlank(vistitType), "vistit_type", vistitType).eq("admission_user_id", TokenSign.getMemberIdByJwtToken(httpServletRequest)).orderByDesc("sub_date"));
  58. QueryWrapper<BillPcr> queryWrapper = new QueryWrapper<>();
  59. queryWrapper.eq(StringUtils.isNotBlank(vistitType), "vistit_type", vistitType).eq("admission_user_id", TokenSign.getMemberIdByJwtToken(httpServletRequest)).orderByDesc("sub_date");
  60. return new Result(ResultCode.SUCCESS, billPcrPage, billPcrMapper.selectCount(queryWrapper));
  61. }
  62. @Override
  63. public Result pcrWhole(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
  64. String farmId = paramsMap.get("farmId");
  65. Date timesmorning = DataUill.getTimesmorning();
  66. QueryWrapper<BillPcr> queryWrapper = new QueryWrapper<>();
  67. queryWrapper.eq("farm_id", farmId).eq("bill_status", 1).ge("sub_date", timesmorning);//今日合格
  68. Integer count = billPcrMapper.selectCount(queryWrapper);
  69. QueryWrapper<BillPcr> queryWrapper1 = new QueryWrapper<>();
  70. queryWrapper1.eq("farm_id", farmId).eq("bill_status", 2).ge("sub_date", timesmorning);//今日异常
  71. Integer count1 = billPcrMapper.selectCount(queryWrapper1);
  72. QueryWrapper<BillPcr> queryWrapper2 = new QueryWrapper<>();
  73. queryWrapper2.eq("farm_id", farmId).eq("bill_status", 3).ge("sub_date", timesmorning);//今日失效
  74. Integer count2 = billPcrMapper.selectCount(queryWrapper2);
  75. PcrDto dto = new PcrDto();
  76. dto.setWholeCount(count + count1);
  77. dto.setPassCount(count);
  78. dto.setRefuseCount(count1);
  79. dto.setLoseCount(count2);
  80. return new Result(ResultCode.SUCCESS, dto);
  81. }
  82. @Override
  83. public Result listType(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
  84. String farmId = paramsMap.get("farmId");
  85. String type = paramsMap.get("type");
  86. if ("".equals(type) || null == type) {
  87. type = "1";
  88. }
  89. List<PcrVo> pcrVos = null;
  90. QueryWrapper<BillPcr> queryWrapper = new QueryWrapper<>();
  91. queryWrapper.eq("farm_id", farmId).in("bill_status", 1, 2);
  92. if ("1".equals(type)) {
  93. Date timesmorning = DataUill.getTimesmorning();
  94. queryWrapper.ge("sub_date", timesmorning);
  95. } else if ("2".equals(type)) {
  96. Calendar calendar = Calendar.getInstance();
  97. calendar.set(Calendar.DATE, calendar.get(Calendar.DATE) - 7);
  98. queryWrapper.ge("sub_date", calendar.getTime());
  99. } else if ("3".equals(type)) {
  100. Date monthmorning = DataUill.getTimesMonthmorning();
  101. queryWrapper.ge("sub_date", monthmorning);
  102. }
  103. pcrVos = billPcrMapper.listPcr(queryWrapper);
  104. for (PcrVo pcrVo : pcrVos) {
  105. if (pcrVo.getType().equals("0")) {
  106. pcrVo.setType("人员");
  107. } else if (pcrVo.getType().equals("1")) {
  108. pcrVo.setType("环保车");
  109. } else if (pcrVo.getType().equals("2")) {
  110. pcrVo.setType("拉猪车");
  111. } else if (pcrVo.getType().equals("3")) {
  112. pcrVo.setType("饲料车");
  113. } else if (pcrVo.getType().equals("4")) {
  114. pcrVo.setType("送猪车");
  115. } else if (pcrVo.getType().equals("5")) {
  116. pcrVo.setType("物资车");
  117. }
  118. }
  119. return new Result(ResultCode.SUCCESS, pcrVos);
  120. }
  121. @Override
  122. public Result listLocation(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
  123. String farmId = paramsMap.get("farmId");
  124. String type = paramsMap.get("type");
  125. if ("".equals(type) || null == type) {
  126. type = "1";
  127. }
  128. List<PcrVo> pcrVos = null;
  129. QueryWrapper<BillPcr> queryWrapper = new QueryWrapper<>();
  130. queryWrapper.eq("farm_id", farmId).in("bill_status", 1, 2);
  131. if ("1".equals(type)) {
  132. Date timesmorning = DataUill.getTimesmorning();
  133. queryWrapper.ge("sub_date", timesmorning);
  134. } else if ("2".equals(type)) {
  135. Calendar calendar = Calendar.getInstance();
  136. calendar.set(Calendar.DATE, calendar.get(Calendar.DATE) - 7);
  137. queryWrapper.ge("sub_date", calendar.getTime());
  138. } else if ("3".equals(type)) {
  139. Date monthmorning = DataUill.getTimesMonthmorning();
  140. queryWrapper.ge("sub_date", monthmorning);
  141. }
  142. pcrVos = billPcrMapper.listLocation(queryWrapper);
  143. return new Result(ResultCode.SUCCESS, pcrVos);
  144. }
  145. @Override
  146. public Result listAll(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
  147. String farmId = paramsMap.get("farmId");
  148. String personType = paramsMap.get("personType");
  149. String type = paramsMap.get("type");
  150. if ("".equals(type) || null == type) {
  151. type = "1";
  152. }
  153. List<PcrVo1> pcrVos = null;
  154. QueryWrapper<BillPcr> queryWrapper = new QueryWrapper<>();
  155. queryWrapper.eq("farm_id", farmId).in("bill_status", 1, 2);
  156. if ("".equals(personType) || null == personType) {
  157. } else {
  158. queryWrapper.eq("vistit_type", personType);
  159. }
  160. if ("1".equals(type)) {
  161. Date timesmorning = DataUill.getTimesmorning();
  162. queryWrapper.ge("sub_date", timesmorning);
  163. } else if ("2".equals(type)) {
  164. Calendar calendar = Calendar.getInstance();
  165. calendar.set(Calendar.DATE, calendar.get(Calendar.DATE) - 7);
  166. queryWrapper.ge("sub_date", calendar.getTime());
  167. } else if ("3".equals(type)) {
  168. Date monthmorning = DataUill.getTimesMonthmorning();
  169. queryWrapper.ge("sub_date", monthmorning);
  170. }
  171. pcrVos = billPcrMapper.listAll(queryWrapper);
  172. for (PcrVo1 pcrVo : pcrVos) {
  173. pcrVo.setAllCount(pcrVo.getPassCount() + pcrVo.getRefuseCount());
  174. }
  175. return new Result(ResultCode.SUCCESS, pcrVos);
  176. }
  177. @Override
  178. public Result selectList(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
  179. String farmId = paramsMap.get("farmId");
  180. String type = paramsMap.get("type");//来访类型
  181. String destId = paramsMap.get("destId");//目的地
  182. String startTime = paramsMap.get("startTime");
  183. String endTime = paramsMap.get("endTime");
  184. String pageNum = paramsMap.get("pageNum");
  185. String pageSize = paramsMap.get("pageSize");
  186. if ("".equals(pageNum) || null == pageNum) {
  187. pageNum = "1";
  188. }
  189. if ("".equals(pageSize) || null == pageSize) {
  190. pageSize = "10";
  191. }
  192. QueryWrapper<BillPcr> queryWrapper = new QueryWrapper<>();
  193. if (ObjectUtil.isNotEmpty(startTime)) {
  194. startTime = startTime + " 00:00:00";
  195. endTime = endTime + " 23:59:59";
  196. queryWrapper.between("check_date", startTime, endTime);
  197. }
  198. queryWrapper.in("bill_status", 1, 2);
  199. queryWrapper.lambda().orderByDesc(BillPcr::getId);
  200. queryWrapper.eq("farm_id", farmId).eq(StringUtils.isNotBlank(destId), "dest_id", destId).eq(StringUtils.isNotBlank(type), "vistit_type", type);
  201. Page<BillPcr> page = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
  202. return new Result(ResultCode.SUCCESS, billPcrMapper.selectPage(page, queryWrapper));
  203. }
  204. @Override
  205. public void printPcr(HttpServletResponse httpServletRequest, Map<String, String> paramsMap) throws Exception {
  206. String ids = paramsMap.get("ids");
  207. String[] split = ids.split(",");
  208. List<BillPcr> list = new ArrayList<>();
  209. for (String s : split) {
  210. BillPcr admission = billPcrMapper.selectById(s);
  211. list.add(admission);
  212. }
  213. Print.printPcr(list);
  214. }
  215. @Override
  216. public Result PcrList(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
  217. String farmId = paramsMap.get("farmId");
  218. QueryWrapper<BillPcr> queryWrapper = new QueryWrapper<>();
  219. queryWrapper.eq("farm_id", farmId);
  220. Integer integer = pcrMapper.selectCount(queryWrapper);//检测总数
  221. queryWrapper.in("bill_status", 1, 3);
  222. Integer integer1 = pcrMapper.selectCount(queryWrapper);//合格总数
  223. queryWrapper.orderByDesc("sub_date").last(" limit 10");
  224. DecimalFormat def = new DecimalFormat("0.00");
  225. String rank;
  226. if (integer == 0 || integer == null) {
  227. Double ranks = Double.valueOf("0.00");
  228. rank = ranks.toString();
  229. } else {
  230. Double ranks = (Double.valueOf(integer1.toString()) / Double.valueOf(integer.toString())) * 100;
  231. rank = def.format(ranks);
  232. }
  233. JSONObject jsonObject = new JSONObject();
  234. jsonObject.put("allCount", integer);
  235. jsonObject.put("passCount", integer1);
  236. jsonObject.put("rank", rank);
  237. jsonObject.put("pcrList", pcrMapper.selectList(queryWrapper));
  238. return new Result(ResultCode.SUCCESS, jsonObject);
  239. }
  240. @Autowired
  241. private BillPcrMapper pcrMapper;
  242. @Autowired
  243. private BaseProcessMapper processMapper;
  244. @Autowired
  245. private BaseLocationMapper locationMapper;
  246. @Autowired
  247. private BillCleanMapper cleanMapper;
  248. @Autowired
  249. private BillGoodsInventoryMapper goodsInventoryMapper;
  250. @Autowired
  251. private ConfigurationMapper configurationMapper;
  252. @Autowired
  253. private UploadImage uploadImage;
  254. @Autowired
  255. private ExistMapper existMapper;
  256. @Autowired
  257. private DeviceListMapper deviceListMapper;
  258. @Autowired
  259. private PeopleListMapper peopleListMapper;
  260. @Autowired
  261. private BillPersonnelAdmissionMapper personnelAdmissionMapper;
  262. @Autowired
  263. private BaseWashoutPointMapper washoutPointMapper;
  264. @Autowired
  265. private BillDryMapper dryMapper;
  266. @Autowired
  267. private BillIsolateMapper isolateMapper;
  268. @Autowired
  269. private BillSamplingMapper samplingMapper;
  270. @Autowired
  271. private BillCleanBeforeMapper beforeMapper;
  272. @Override
  273. public Result list(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
  274. String farmId = paramsMap.get("farmId");
  275. String type = paramsMap.get("type");//展示类型
  276. String pageNum = paramsMap.get("pageNum");
  277. String pageSize = paramsMap.get("pageSize");
  278. if ("".equals(pageNum) || null == pageNum) {
  279. pageNum = "1";
  280. }
  281. if ("".equals(pageSize) || null == pageSize) {
  282. pageSize = "20";
  283. }
  284. Page<BillPcr> page = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
  285. QueryWrapper<BillPcr> queryWrapper = new QueryWrapper<>();
  286. queryWrapper.eq("farm_id", farmId).eq("test_location_id", TokenSign.getWorkIdByJwtToken(httpServletRequest)).orderByDesc("sub_date");
  287. if ("0".equals(type)) {
  288. queryWrapper.in("bill_status", 0, 1, 2, 3);
  289. }
  290. if ("1".equals(type)) {
  291. queryWrapper.eq("bill_status", 0);
  292. }
  293. if ("2".equals(type)) {
  294. queryWrapper.eq("bill_status", 1);
  295. }
  296. if ("3".equals(type)) {
  297. queryWrapper.in("bill_status", 2, 3);
  298. }
  299. QueryWrapper<BillPcr> queryWrapper2 = new QueryWrapper<>();
  300. queryWrapper2.eq("farm_id", farmId).eq("test_location_id", TokenSign.getWorkIdByJwtToken(httpServletRequest)).orderByDesc("sub_date");
  301. queryWrapper2.eq("bill_status", 0);
  302. return new Result(ResultCode.SUCCESS, pcrMapper.selectPage(page, queryWrapper), pcrMapper.selectCount(queryWrapper2));
  303. }
  304. @Override
  305. public Result listById(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
  306. String id = paramsMap.get("id");
  307. BillPcr billPcr = pcrMapper.selectById(id);
  308. return new Result(ResultCode.SUCCESS, billPcr);
  309. }
  310. @Override
  311. public Result edit(HttpServletRequest httpServletRequest, String farmId, String id, String date, String result,
  312. MultipartFile img1, MultipartFile img2, MultipartFile img3) throws ParseException, IOException {
  313. //1为合格2为异常
  314. String s1 = "";
  315. String s2 = "";
  316. String s3 = "";
  317. if (ObjectUtil.isNotEmpty(img1)) {
  318. if (uploadImage.getImageCom(img1).equals("上传失败")) {
  319. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  320. return new Result(10001, "图片1上传失败", false);
  321. }
  322. s1 = uploadImage.uploadImg(img1);
  323. }
  324. if (ObjectUtil.isNotEmpty(img2)) {
  325. if (uploadImage.getImageCom(img2).equals("上传失败")) {
  326. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  327. return new Result(10001, "图片2上传失败", false);
  328. }
  329. s2 = "," + uploadImage.uploadImg(img2);
  330. }
  331. if (ObjectUtil.isNotEmpty(img3)) {
  332. if (uploadImage.getImageCom(img3).equals("上传失败")) {
  333. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  334. return new Result(10001, "图片3上传失败", false);
  335. }
  336. s3 = "," + uploadImage.uploadImg(img3);
  337. }
  338. String s = s1 + s2 + s3;
  339. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
  340. if (StringUtils.isBlank(date)) {
  341. date = sdf.format(new Date());
  342. }
  343. BillPcr billPcr = pcrMapper.selectById(id);
  344. billPcr.setImgUrl(s);
  345. billPcr.setImgStatus(1);
  346. QueryWrapper<BaseProcess> processQueryWrapper = new QueryWrapper<>();
  347. processQueryWrapper.eq("farm_id", farmId).eq("id", billPcr.getProcessId());
  348. BaseProcess baseProcess = processMapper.selectOne(processQueryWrapper);//进程
  349. QueryWrapper<BaseLocation> locationQueryWrapper = new QueryWrapper<>();
  350. locationQueryWrapper.eq("id", billPcr.getTestLocationId());
  351. BaseLocation baseLocation = locationMapper.selectOne(locationQueryWrapper);//当前pcr检测所在的位置
  352. String allLocationId = baseProcess.getAllLocationId();//所有的位置id
  353. String allFlowId = baseProcess.getAllFlowId();//所有的流程id
  354. String currentFlowId = baseProcess.getCurrentFlowId();//当前已经完成的流程id
  355. String substring1 = allFlowId.substring(currentFlowId.length() + 1, allFlowId.length());
  356. String[] split = substring1.split(",");
  357. Integer nextId = Integer.parseInt(split[0]);
  358. if (billPcr.getBillStatus() != 0) {
  359. return new Result(10001, "该订单已通过,无需再次提交!", false);
  360. }
  361. if (baseProcess.getProcessType() == 2 || baseProcess.getProcessType() == 1) {
  362. return new Result(10001, "修改失败!该申请已提前结束或者被拒绝", false);
  363. } else {
  364. if ("1".equals(result)) {
  365. Integer pcrTime = washoutPointMapper.selectOne(new QueryWrapper<BaseWashoutPoint>().eq("farm_ids", farmId)
  366. .eq("visiting_type", billPcr.getVistitType()).eq("location_id", baseLocation.getId())).getPcrTime();
  367. billPcr.setBillStatus(1);
  368. billPcr.setPassUserName(TokenSign.getUserNameByJwtToken(httpServletRequest));
  369. billPcr.setPassUserId(TokenSign.getMemberIdByJwtToken(httpServletRequest));
  370. billPcr.setTestLocation(baseLocation.getLocationName());
  371. billPcr.setTestLocationId(baseLocation.getId());
  372. billPcr.setCheckDate(sdf.parse(date));
  373. billPcr.setPassDate(sdf.parse(sdf.format(new Date())));
  374. billPcr.setQualifiedDate(pcrTime);
  375. Object newObject = getNewObject(nextId, billPcr.getDestName(), billPcr.getDestId(), billPcr.getAdmissionUserName(),
  376. billPcr.getAdmissionUserId(), billPcr.getVistitDate(), billPcr.getSubDate(),
  377. billPcr.getProcessId(), billPcr.getFarmId(), billPcr.getTestLocation(), billPcr.getTestLocationId(),
  378. billPcr.getVistitType(),billPcr.getPhone(),billPcr.getDepartureName(),billPcr.getDepartureId());
  379. System.out.println("这里是pcr通过的下一个流程id:" + nextId);
  380. if (nextId == 0) {
  381. int index = allLocationId.indexOf(baseLocation.getId());
  382. StringBuilder status = new StringBuilder(baseProcess.getAllLocationId());
  383. status.setCharAt(index, '1');
  384. status.setCharAt(index + 2, '1');
  385. baseProcess.setAllLocationStatus(status.toString());
  386. } else if (nextId == 1) {
  387. //新增采样
  388. BillSampling billSampling = (BillSampling) newObject;
  389. samplingMapper.insert(billSampling);
  390. }else if (nextId == 2) {
  391. //新增pcr
  392. BillPcr billClean = (BillPcr) newObject;
  393. pcrMapper.insert(billClean);
  394. }else if (nextId == 3) {
  395. //新增洗澡
  396. BillClean billClean = (BillClean) newObject;
  397. cleanMapper.insert(billClean);
  398. }else if (nextId == 4) {
  399. //新增隔离
  400. BillIsolate pcr = (BillIsolate) newObject;
  401. isolateMapper.insert(pcr);
  402. }else if (nextId == 5) {
  403. BillDry billClean = (BillDry) newObject;
  404. dryMapper.insert(billClean);
  405. //新增烘干
  406. }else if (nextId == 6) {
  407. //新增洗澡前拍照
  408. BillCleanBefore before = (BillCleanBefore) newObject;
  409. beforeMapper.insert(before);
  410. }
  411. // //通过生成门禁白名单
  412. // QueryWrapper<DeviceList> deviceListQueryWrapper = new QueryWrapper<>();
  413. // deviceListQueryWrapper.eq("farm_id", billPcr.getFarmId()).eq("location_id", baseLocation.getId());
  414. // List<DeviceList> deviceLists = deviceListMapper.selectList(deviceListQueryWrapper);
  415. // //找到对应的入场申请表
  416. // QueryWrapper<BillPersonnelAdmission> queryWrapper1 = new QueryWrapper<>();
  417. // queryWrapper1.eq("farm_id", billPcr.getFarmId()).eq("process_id", baseProcess.getId());
  418. // BillPersonnelAdmission billPersonnelAdmission = personnelAdmissionMapper.selectOne(queryWrapper1);
  419. // if (deviceLists.size() > 0) {
  420. // for (DeviceList deviceList : deviceLists) {
  421. // //通过生成门禁白名单
  422. // PeopleList peopleList = new PeopleList();
  423. // peopleList.setFarmId(billPcr.getFarmId().toString());
  424. // peopleList.setDeviceCode(deviceList.getDeviceCode());
  425. // peopleList.setUserId(billPcr.getAdmissionUserId());
  426. // peopleList.setUserName(billPcr.getAdmissionUserName());
  427. // peopleList.setPassword("123456");
  428. // peopleList.setType(0);
  429. // peopleList.setCreateTime(new Date());
  430. // Date date2 = new Date();
  431. // Calendar calendar = Calendar.getInstance();
  432. // calendar.setTime(date2);
  433. // calendar.add(Calendar.HOUR_OF_DAY, 2);
  434. // Date date1 = calendar.getTime();
  435. // peopleList.setOutTime(date1);
  436. // peopleListMapper.insert(peopleList);
  437. //
  438. // HashMap<String, Object> jsonObject = new HashMap<>();
  439. // jsonObject.put("seq", deviceList.getDeviceCode());
  440. //// String savePath = "D:\\works\\pig_projects\\甜妹.jpg";
  441. // String savePath = "/opt/huatong/test.jpg";
  442. // URL url = new URL(billPersonnelAdmission.getUserImgUrl());
  443. // HttpURLConnection connection = (HttpURLConnection) url.openConnection();
  444. // connection.setRequestMethod("GET");
  445. // int resCode = connection.getResponseCode();
  446. // if (resCode == HttpURLConnection.HTTP_OK) {
  447. // InputStream inputStream = connection.getInputStream();
  448. // byte[] buffer = new byte[4096];
  449. // int length;
  450. // //读取数据并写入到文件中
  451. // try (FileOutputStream outStream = new FileOutputStream(savePath)) {
  452. // while ((length = inputStream.read(buffer)) != -1) {
  453. // outStream.write(buffer, 0, length);
  454. // }
  455. // outStream.flush();
  456. // } finally {
  457. // inputStream.close();
  458. // }
  459. // } else {
  460. // System.out.println("文件下载错误码为" + resCode);
  461. // }
  462. //
  463. //// jsonObject.put("face", FileUtil.file("D:\\works\\pig_projects\\甜妹.jpg"));
  464. // jsonObject.put("face", FileUtil.file(savePath));
  465. // jsonObject.put("name", billPersonnelAdmission.getAdmissionUserName());
  466. // jsonObject.put("password", "123456");
  467. // jsonObject.put("timestamp", date1.getTime());
  468. // jsonObject.put("uid", billPersonnelAdmission.getAdmissionUserId());
  469. // String post = HttpRequest.post("http://39.173.90.137:8040/addDeviceUser")
  470. // .header(Header.CONTENT_TYPE, "multipart/form-data")
  471. // .form(jsonObject)
  472. // .timeout(30 * 1000).execute().body();
  473. // System.out.println(post);
  474. // }
  475. // }
  476. baseProcess.setUpdateDate(baseProcess.getUpdateDate() + "," + sdf.format(new Date()));
  477. baseProcess.setCurrentLocation(baseProcess.getCurrentLocation() + "," + baseLocation.getLocationName());
  478. baseProcess.setCurrentLocationId(baseProcess.getCurrentLocationId() + "," + baseLocation.getId());
  479. String status = baseProcess.getCurrentStatus();
  480. String substring = status.substring(0, status.length() - 1);
  481. baseProcess.setCurrentStatus(substring + "1," + 0);
  482. baseProcess.setCurrentFlowId(baseProcess.getCurrentFlowId() + "," + nextId);
  483. processMapper.updateById(baseProcess);
  484. pcrMapper.updateById(billPcr);
  485. return new Result(10000, "修改成功!", true);
  486. } else {
  487. billPcr.setBillStatus(2);
  488. billPcr.setPcrType(1);
  489. billPcr.setPassUserName(TokenSign.getUserNameByJwtToken(httpServletRequest));
  490. billPcr.setPassUserId(TokenSign.getMemberIdByJwtToken(httpServletRequest));
  491. billPcr.setTestLocation(baseLocation.getLocationName());
  492. billPcr.setTestLocationId(baseLocation.getId());
  493. billPcr.setCheckDate(sdf.parse(date));
  494. billPcr.setPassDate(sdf.parse(sdf.format(new Date())));
  495. baseProcess.setUpdateDate(baseProcess.getUpdateDate() + "," + sdf.format(new Date()));
  496. String status = baseProcess.getCurrentStatus();
  497. String substring = status.substring(0, status.length() - 1);
  498. baseProcess.setCurrentStatus(substring + "2," + 0);
  499. processMapper.updateById(baseProcess);
  500. pcrMapper.updateById(billPcr);
  501. return new Result(10000, "修改成功!", true);
  502. }
  503. }
  504. }
  505. public static void main(String[] args) {
  506. String s = "0,1,0,2,0,3,0";
  507. StringBuilder sb = new StringBuilder(s);
  508. Integer a = s.length() - 3;
  509. sb.setCharAt(a,'0');
  510. System.out.println(sb.toString());
  511. // String s1 = "1,1,1,0,0,0";
  512. // System.out.println(s.indexOf("2"));
  513. // StringBuilder sb = new StringBuilder(s1);
  514. // sb.setCharAt(6, '1');
  515. // sb.setCharAt(8, '1');
  516. // System.out.println(sb.toString());
  517. }
  518. private void xiugaiPro(BaseProcess baseProcess, BillPcr billPcr) {
  519. baseProcess.setUpdateDate(baseProcess.getUpdateDate() + "," + new Date());
  520. baseProcess.setCurrentLocation(baseProcess.getCurrentLocation() + "," + billPcr.getTestLocation());
  521. baseProcess.setCurrentLocationId(baseProcess.getCurrentLocationId() + "," + billPcr.getTestLocationId());
  522. baseProcess.setCurrentStatus(baseProcess.getCurrentStatus() + "," + 2);
  523. }
  524. public String add() {
  525. ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(10);
  526. Runnable task = new Runnable() {
  527. @Override
  528. public void run() {
  529. //这里写业务
  530. System.out.println();
  531. }
  532. };
  533. // 设定延迟时间(两小时后执行,单位为秒)
  534. long delay = 3;
  535. // 执行定时任务
  536. scheduler.schedule(task, delay, TimeUnit.SECONDS);
  537. System.out.println("完结");
  538. return "成功";
  539. }
  540. public static Object getNewObject(Integer id, String destName, Integer destId, String admissionUserName, Integer admissionUserId
  541. , LocalDateTime vistitDate, LocalDateTime subDate, Integer processId, Integer farmId, String testLocation
  542. , Integer testLocationId,Integer vistitType,String phone,String departureName,Integer departureId) {
  543. if (id == 1) {
  544. //采样
  545. BillSampling billSampling = new BillSampling();
  546. billSampling.setVistitType(vistitType);
  547. billSampling.setDestName(destName);
  548. billSampling.setDestId(destId);
  549. billSampling.setAdmissionUserName(admissionUserName);
  550. billSampling.setAdmissionUserId(admissionUserId);
  551. billSampling.setVistitDate(vistitDate);
  552. billSampling.setSubDate(LocalDateTime.now());
  553. billSampling.setPhone(phone);
  554. billSampling.setTestLocation(testLocation);
  555. billSampling.setTestLocationId(testLocationId);
  556. billSampling.setProcessId(processId);
  557. billSampling.setFarmId(String.valueOf(farmId));
  558. billSampling.setDepartureName(departureName);
  559. billSampling.setDepartureId(departureId);
  560. return billSampling;
  561. }
  562. if (id == 2) {
  563. //pcr
  564. BillPcr billPcr = new BillPcr();
  565. billPcr.setDestName(destName);
  566. billPcr.setDestId(destId);
  567. billPcr.setAdmissionUserId(admissionUserId);
  568. billPcr.setAdmissionUserName(admissionUserName);
  569. billPcr.setVistitDate(vistitDate);
  570. billPcr.setSubDate(subDate);
  571. billPcr.setBillStatus(0);
  572. billPcr.setProcessId(processId);
  573. billPcr.setFarmId(farmId);
  574. billPcr.setTestLocationId(testLocationId);
  575. billPcr.setTestLocation(testLocation);
  576. billPcr.setDepartureName(departureName);
  577. billPcr.setDepartureId(departureId);
  578. return billPcr;
  579. }
  580. if (id == 3) {
  581. //洗消
  582. BillClean billPcr = new BillClean();
  583. billPcr.setDestName(destName);
  584. billPcr.setDestId(destId);
  585. billPcr.setAdmissionUserId(admissionUserId);
  586. billPcr.setAdmissionUserName(admissionUserName);
  587. billPcr.setVistitDate(vistitDate);
  588. billPcr.setSubDate(subDate);
  589. billPcr.setBillStatus(0);
  590. billPcr.setProcessId(processId);
  591. billPcr.setFarmId(farmId);
  592. billPcr.setTestLocationId(testLocationId);
  593. billPcr.setTestLocation(testLocation);
  594. billPcr.setDepartureName(departureName);
  595. billPcr.setDepartureId(departureId);
  596. return billPcr;
  597. }
  598. if (id == 4) {
  599. //隔离
  600. BillIsolate billPcr = new BillIsolate();
  601. billPcr.setDestName(destName);
  602. billPcr.setDestId(destId);
  603. billPcr.setAdmissionUserId(admissionUserId);
  604. billPcr.setAdmissionUserName(admissionUserName);
  605. billPcr.setVistitDate(vistitDate);
  606. billPcr.setSubDate(subDate);
  607. billPcr.setBillStatus(0);
  608. billPcr.setProcessId(processId);
  609. billPcr.setFarmId(farmId);
  610. billPcr.setIsolateLocation(testLocation);
  611. billPcr.setIsolateLocationId(testLocationId);
  612. billPcr.setDepartureName(departureName);
  613. billPcr.setDepartureId(departureId);
  614. return billPcr;
  615. }
  616. if (id == 5) {
  617. //烘干
  618. BillDry billPcr = new BillDry();
  619. billPcr.setDestName(destName);
  620. billPcr.setDestId(destId);
  621. billPcr.setAdmissionUserId(admissionUserId);
  622. billPcr.setAdmissionUserName(admissionUserName);
  623. billPcr.setVistitDate(vistitDate);
  624. billPcr.setSubDate(subDate);
  625. billPcr.setBillStatus(0);
  626. billPcr.setProcessId(processId);
  627. billPcr.setFarmId(farmId);
  628. billPcr.setTestLocationId(testLocationId);
  629. billPcr.setTestLocation(testLocation);
  630. billPcr.setDepartureName(departureName);
  631. billPcr.setDepartureId(departureId);
  632. return billPcr;
  633. }
  634. if (id == 6) {
  635. //洗澡前拍照
  636. BillCleanBefore billCleanBefore = new BillCleanBefore();
  637. billCleanBefore.setVistitType(vistitType);
  638. billCleanBefore.setDestName(destName);
  639. billCleanBefore.setDestId(destId);
  640. billCleanBefore.setAdmissionUserName(admissionUserName);
  641. billCleanBefore.setAdmissionUserId(admissionUserId);
  642. billCleanBefore.setVistitDate(vistitDate);
  643. billCleanBefore.setSubDate(LocalDateTime.now());
  644. billCleanBefore.setPhone(phone);
  645. billCleanBefore.setTestLocation(testLocation);
  646. billCleanBefore.setTestLocationId(testLocationId);
  647. billCleanBefore.setProcessId(processId);
  648. billCleanBefore.setFarmId(String.valueOf(farmId));
  649. billCleanBefore.setDepartureName(departureName);
  650. billCleanBefore.setDepartureId(departureId);
  651. return billCleanBefore;
  652. }
  653. return null;
  654. }
  655. }