BillPcrServiceImpl.java 45 KB

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