BillCleanServiceImpl.java 64 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249
  1. package com.huimv.receive.service.impl;
  2. import cn.hutool.core.util.ObjectUtil;
  3. import com.alibaba.fastjson.JSONObject;
  4. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  5. import com.baomidou.mybatisplus.core.toolkit.StringUtils;
  6. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  7. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  8. import com.huimv.receive.common.token.TokenSign;
  9. import com.huimv.receive.common.utils.*;
  10. import com.huimv.receive.entity.*;
  11. import com.huimv.receive.entity.vo.CleanAndDryVo;
  12. import com.huimv.receive.entity.vo.CleanAndDryVo2;
  13. import com.huimv.receive.entity.vo.CleanVo;
  14. import com.huimv.receive.entity.vo.PcrVo1;
  15. import com.huimv.receive.mapper.*;
  16. import com.huimv.receive.service.IBillCleanService;
  17. import org.springframework.beans.factory.annotation.Autowired;
  18. import org.springframework.stereotype.Service;
  19. import org.springframework.transaction.interceptor.TransactionAspectSupport;
  20. import org.springframework.web.multipart.MultipartFile;
  21. import javax.annotation.Resource;
  22. import javax.servlet.http.HttpServletRequest;
  23. import javax.servlet.http.HttpServletResponse;
  24. import java.io.IOException;
  25. import java.text.DecimalFormat;
  26. import java.text.ParseException;
  27. import java.text.SimpleDateFormat;
  28. import java.time.LocalDateTime;
  29. import java.util.*;
  30. /**
  31. * <p>
  32. * 洗消表 服务实现类
  33. * </p>
  34. *
  35. * @author author
  36. * @since 2023-07-21
  37. */
  38. @Service
  39. public class BillCleanServiceImpl extends ServiceImpl<BillCleanMapper, BillClean> implements IBillCleanService {
  40. @Autowired
  41. private BillCleanMapper cleanMapper;
  42. @Autowired
  43. private BillIsolateMapper isolateMapper;
  44. @Autowired
  45. private BillPcrMapper pcrMapper;
  46. @Autowired
  47. private BaseProcessMapper processMapper;
  48. @Autowired
  49. private BaseLocationMapper locationMapper;
  50. @Autowired
  51. private UploadImage uploadImage;
  52. @Autowired
  53. private BillDryMapper dryMapper;
  54. @Autowired
  55. private BillPersonnelAdmissionMapper admissionMapper;
  56. @Autowired
  57. private ConfigurationMapper configurationMapper;
  58. @Autowired
  59. private ExistMapper existMapper;
  60. @Override
  61. public Result listAll(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
  62. String type = paramsMap.get("type");//展示类型 0-6
  63. String data = paramsMap.get("data");//状态
  64. String farmId = paramsMap.get("farmId");
  65. String pageNum = paramsMap.get("pageNum");
  66. String pageSize = paramsMap.get("pageSize");
  67. if ("".equals(pageNum) || null == pageNum) {
  68. pageNum = "1";
  69. }
  70. if ("".equals(pageSize) || null == pageSize) {
  71. pageSize = "20";
  72. }
  73. if ("".equals(type) || null == type) {
  74. type = "1";
  75. }
  76. if ("".equals(data) || null == data) {
  77. data = "0";
  78. }
  79. if (type.equals("0")) {
  80. QueryWrapper<BaseLocation> queryWrapper1 = new QueryWrapper<>();
  81. queryWrapper1.eq("location_type", TokenSign.getWorkIdByJwtToken(httpServletRequest));
  82. List<BaseLocation> baseLocations = locationMapper.selectList(queryWrapper1);
  83. List<Integer> ids = new ArrayList<>();
  84. for (BaseLocation baseLocation : baseLocations) {
  85. ids.add(baseLocation.getId());
  86. }
  87. Page<BillClean> page = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
  88. QueryWrapper<BillClean> queryWrapper = new QueryWrapper<>();
  89. queryWrapper.eq("farm_id", farmId).eq("vistit_type", type).orderByDesc("sub_date")
  90. .in("test_location_id", ids);
  91. if ("0".equals(data)) {
  92. queryWrapper.in("bill_status", 0, 1, 2);
  93. }
  94. if ("1".equals(data)) {
  95. queryWrapper.eq("bill_status", 0);
  96. }
  97. if ("2".equals(data)) {
  98. queryWrapper.eq("bill_status", 1);
  99. }
  100. QueryWrapper<BillClean> queryWrapper2 = new QueryWrapper<>();
  101. queryWrapper2.eq("farm_id", farmId).eq("vistit_type", type).orderByDesc("sub_date")
  102. .in("test_location_id", ids).eq("bill_status", 0);
  103. return new Result(ResultCode.SUCCESS, cleanMapper.selectPage(page, queryWrapper), cleanMapper.selectCount(queryWrapper2));
  104. }/* else if (type.equals("4")) {
  105. Page<BillClean> page = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
  106. QueryWrapper<BillClean> queryWrapper = new QueryWrapper<>();
  107. queryWrapper.eq("farm_id", farmId).eq("vistit_type", 4).orderByDesc("sub_date")
  108. .eq("test_location_id", TokenSign.getWorkIdByJwtToken(httpServletRequest));
  109. if ("0".equals(data)) {
  110. queryWrapper.in("bill_status", 0, 1, 2);
  111. }
  112. if ("1".equals(data)) {
  113. queryWrapper.eq("bill_status", 0);
  114. }
  115. if ("2".equals(data)) {
  116. queryWrapper.eq("bill_status", 1);
  117. }
  118. return new Result(ResultCode.SUCCESS, cleanMapper.selectPage(page, queryWrapper));
  119. }*/ else {
  120. Page<CleanAndDryVo2> cleanAndDryVo2Page = null;
  121. Page<CleanAndDryVo2> page = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
  122. QueryWrapper<BaseLocation> queryWrapper1 = new QueryWrapper<>();
  123. queryWrapper1.eq("location_type", TokenSign.getWorkIdByJwtToken(httpServletRequest));
  124. List<BaseLocation> baseLocations = locationMapper.selectList(queryWrapper1);
  125. QueryWrapper<BillClean> queryWrapper = new QueryWrapper<>();
  126. queryWrapper.eq("farm_id", farmId).eq("vistit_type", type);
  127. QueryWrapper<BillDry> queryWrapper2 = new QueryWrapper<>();
  128. queryWrapper2.eq("farm_id", farmId).eq("vistit_type", type);
  129. if ("0".equals(data)) {
  130. ArrayList<String> arrayList = new ArrayList<>();
  131. for (BaseLocation baseLocation : baseLocations) {
  132. arrayList.add(baseLocation.getId().toString());
  133. }
  134. String[] s = arrayList.toArray(new String[arrayList.size()]);
  135. System.out.println("传入自定义sql的位置参数形式:" + s);
  136. cleanAndDryVo2Page = cleanMapper.CleanAndDry(page, farmId, type, "0,1".split(","), s);
  137. queryWrapper.in("test_location_id", arrayList);
  138. queryWrapper2.in("test_location_id", arrayList);
  139. }
  140. if ("1".equals(data)) {
  141. ArrayList<String> integerArrayList = new ArrayList<>();
  142. for (BaseLocation baseLocation : baseLocations) {
  143. integerArrayList.add(baseLocation.getId().toString());
  144. }
  145. String[] ids = integerArrayList.toArray(new String[integerArrayList.size()]);
  146. ArrayList<String> arrayList = new ArrayList<>();
  147. arrayList.add("0");
  148. String[] s = arrayList.toArray(new String[arrayList.size()]);
  149. cleanAndDryVo2Page = cleanMapper.CleanAndDry(page, farmId, type, s, ids);
  150. queryWrapper.in("test_location_id", integerArrayList);
  151. queryWrapper2.in("test_location_id", integerArrayList);
  152. }
  153. if ("2".equals(data)) {
  154. ArrayList<String> integerArrayList = new ArrayList<>();
  155. for (BaseLocation baseLocation : baseLocations) {
  156. integerArrayList.add(baseLocation.getId().toString());
  157. }
  158. String[] ids = integerArrayList.toArray(new String[integerArrayList.size()]);
  159. ArrayList<String> arrayList = new ArrayList<>();
  160. arrayList.add("1");
  161. String[] s = arrayList.toArray(new String[arrayList.size()]);
  162. cleanAndDryVo2Page = cleanMapper.CleanAndDry(page, farmId, type, s, ids);
  163. queryWrapper.in("test_location_id", integerArrayList);
  164. queryWrapper2.in("test_location_id", integerArrayList);
  165. }
  166. queryWrapper.eq("img_status", 0);
  167. queryWrapper2.eq("img_status", 0);
  168. Integer integer = cleanMapper.selectCount(queryWrapper);
  169. Integer integer1 = dryMapper.selectCount(queryWrapper2);
  170. return new Result(ResultCode.SUCCESS, cleanAndDryVo2Page, integer + integer1);
  171. }
  172. }
  173. @Override
  174. public Result listById(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
  175. String id = paramsMap.get("id");
  176. BillClean billClean = cleanMapper.selectById(id);
  177. return new Result(ResultCode.SUCCESS, billClean);
  178. }
  179. @Override
  180. public Result listByIdDry(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
  181. String id = paramsMap.get("id");
  182. return new Result(ResultCode.SUCCESS, dryMapper.selectById(id));
  183. }
  184. @Override
  185. public Result commitClean(HttpServletRequest httpServletRequest, String farmId, String id, String date, String result
  186. , MultipartFile img1, MultipartFile img2, MultipartFile img3) throws ParseException, IOException {
  187. String s1 = "";
  188. String s2 = "";
  189. String s3 = "";
  190. if (ObjectUtil.isNotEmpty(img1)) {
  191. if (uploadImage.getImageCom(img1).equals("上传失败")) {
  192. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  193. return new Result(10001, "图片1上传失败", false);
  194. }
  195. s1 = uploadImage.uploadImg(img1);
  196. }
  197. if (ObjectUtil.isNotEmpty(img2)) {
  198. if (uploadImage.getImageCom(img2).equals("上传失败")) {
  199. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  200. return new Result(10001, "图片2上传失败", false);
  201. }
  202. s2 = "," + uploadImage.uploadImg(img2);
  203. }
  204. if (ObjectUtil.isNotEmpty(img3)) {
  205. if (uploadImage.getImageCom(img3).equals("上传失败")) {
  206. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  207. return new Result(10001, "图片3上传失败", false);
  208. }
  209. s3 = "," + uploadImage.uploadImg(img3);
  210. }
  211. String s = s1 + s2 + s3;
  212. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
  213. if (StringUtils.isBlank(date)) {
  214. date = sdf.format(new Date());
  215. }
  216. BillClean billClean = cleanMapper.selectById(id);//某条洗消记录
  217. billClean.setImgUrl(s);
  218. billClean.setImgStatus(1);
  219. QueryWrapper<BaseProcess> queryWrapper = new QueryWrapper<>();
  220. queryWrapper.eq("farm_id", farmId).eq("id", billClean.getProcessId());
  221. BaseProcess baseProcess = processMapper.selectOne(queryWrapper);//某条进程
  222. QueryWrapper<BaseLocation> locationQueryWrapper = new QueryWrapper<>();
  223. locationQueryWrapper.eq("id", billClean.getTestLocationId());
  224. BaseLocation baseLocation = locationMapper.selectOne(locationQueryWrapper);//当前所在的位置
  225. QueryWrapper<Configuration> queryWrapper3 = new QueryWrapper<>();
  226. queryWrapper3.eq("farm_id", farmId);
  227. Configuration configuration = configurationMapper.selectOne(queryWrapper3);
  228. QueryWrapper<Exist> existQueryWrapper = new QueryWrapper<>();
  229. existQueryWrapper.eq("farm_id", farmId);
  230. Exist exist = existMapper.selectOne(existQueryWrapper);//判断是否有二级洗消站
  231. if (billClean.getBillStatus() != 0) {
  232. return new Result(10001, "该订单已通过,无需再次提交!", false);
  233. }
  234. if (billClean.getDestId() >= billClean.getTestLocationId()) { //不是目的地
  235. if ("1".equals(result)) {
  236. billClean.setBillStatus(1);
  237. billClean.setPassUserName(TokenSign.getUserNameByJwtToken(httpServletRequest));
  238. billClean.setPassUserId(TokenSign.getMemberIdByJwtToken(httpServletRequest));
  239. billClean.setTestLocation(baseLocation.getLocationName());
  240. billClean.setTestLocationId(baseLocation.getId());
  241. billClean.setCheckDate(sdf.parse(date));
  242. billClean.setPassDate(sdf.parse(sdf.format(new Date())));
  243. billClean.setCleanTime("10");
  244. if (exist.getExist() == 0) {
  245. if (baseLocation.getId() == 1 && baseProcess.getDestId() > 2) {
  246. //生成pcr检测申请
  247. BillPcr billPcr = new BillPcr();
  248. billPcr.setPcrType(0);
  249. billPcr.setPhone(billClean.getPhone());
  250. billPcr.setVistitType(billClean.getVistitType());
  251. billPcr.setDestName(billClean.getDestName());
  252. billPcr.setDestId(billClean.getDestId());
  253. billPcr.setAdmissionUserName(billClean.getAdmissionUserName());
  254. billPcr.setAdmissionUserId(billClean.getAdmissionUserId());
  255. billPcr.setVistitDate(billClean.getVistitDate());
  256. billPcr.setSubDate(LocalDateTime.now());
  257. billPcr.setBillStatus(0);
  258. billPcr.setProcessId(billClean.getProcessId());
  259. billPcr.setFarmId(billClean.getFarmId());
  260. billPcr.setTestLocation("人员二级洗消站");
  261. billPcr.setTestLocationId(3);
  262. billPcr.setQualifiedDate(configuration.getPcr());
  263. pcrMapper.insert(billPcr);
  264. String status = baseProcess.getAllLocationStatus();
  265. String[] split1 = status.split(",");
  266. split1[0] = "2";
  267. split1[1] = "2";
  268. split1[2] = "2";
  269. split1[3] = "1";
  270. baseProcess.setAllLocationStatus(split1[0] + "," + split1[1] + "," + split1[2] + "," + split1[3] + status.substring(7));
  271. }
  272. if (baseLocation.getId() == 3) {
  273. //生成隔离申请
  274. BillIsolate isolate = new BillIsolate();
  275. isolate.setPhone(billClean.getPhone());
  276. isolate.setVistitType(billClean.getVistitType());
  277. isolate.setDestName(billClean.getDestName());
  278. isolate.setDestId(billClean.getDestId());
  279. isolate.setAdmissionUserName(billClean.getAdmissionUserName());
  280. isolate.setAdmissionUserId(billClean.getAdmissionUserId());
  281. isolate.setVistitDate(billClean.getVistitDate());
  282. isolate.setSubDate(billClean.getSubDate());
  283. isolate.setFarmId(billClean.getFarmId());
  284. isolate.setBillStatus(0);
  285. isolate.setIsolateDayNum("");
  286. isolate.setProcessId(billClean.getProcessId());
  287. isolate.setIsolateLocation(baseLocation.getLocationName());
  288. isolate.setIsolateLocationId(baseLocation.getId());
  289. isolateMapper.insert(isolate);
  290. String status = baseProcess.getAllLocationStatus();
  291. String[] split1 = status.split(",");
  292. split1[0] = "2";
  293. split1[1] = "2";
  294. split1[2] = "2";
  295. split1[3] = "1";
  296. baseProcess.setAllLocationStatus(split1[0] + "," + split1[1] + "," + split1[2] + "," + split1[3] + status.substring(7));
  297. }
  298. }
  299. if (exist.getExist() == 1 && billClean.getDestId() >= 4 && baseLocation.getId() == 1) {
  300. BillClean billClean1 = new BillClean();
  301. billClean1.setVistitType(billClean.getVistitType());
  302. billClean1.setDestName(billClean.getDestName());
  303. billClean1.setDestId(billClean.getDestId());
  304. billClean1.setAdmissionUserId(billClean.getAdmissionUserId());
  305. billClean1.setAdmissionUserName(billClean.getAdmissionUserName());
  306. billClean1.setVistitDate(billClean.getVistitDate());
  307. billClean1.setSubDate(LocalDateTime.now());
  308. billClean1.setFarmId(billClean.getFarmId());
  309. billClean1.setBillStatus(0);
  310. billClean1.setProcessId(billClean.getProcessId());
  311. billClean1.setPhone(billClean.getPhone());
  312. billClean1.setTestLocation("场内");
  313. billClean1.setTestLocationId(4);
  314. billCleanMapper.insert(billClean1);
  315. String status = baseProcess.getAllLocationStatus();
  316. String[] split1 = status.split(",");
  317. split1[0] = "2";
  318. split1[1] = "2";
  319. split1[2] = "2";
  320. split1[3] = "1";
  321. baseProcess.setAllLocationStatus(split1[0] + "," + split1[1] + "," + split1[2] + "," + split1[3] + status.substring(7));
  322. }
  323. if (baseLocation.getId() == 4) {
  324. QueryWrapper<BillPcr> queryWrapper1 = new QueryWrapper<>();
  325. queryWrapper1.eq("farm_id", farmId).eq("process_id", baseProcess.getId()).eq("test_location_id", 4);
  326. if (ObjectUtil.isEmpty(pcrMapper.selectOne(queryWrapper1))) {
  327. //生成pcr检测申请
  328. BillPcr billPcr = new BillPcr();
  329. billPcr.setPcrType(0);
  330. billPcr.setPhone(billClean.getPhone());
  331. billPcr.setVistitType(billClean.getVistitType());
  332. billPcr.setDestName(billClean.getDestName());
  333. billPcr.setDestId(billClean.getDestId());
  334. billPcr.setAdmissionUserName(billClean.getAdmissionUserName());
  335. billPcr.setAdmissionUserId(billClean.getAdmissionUserId());
  336. billPcr.setVistitDate(billClean.getVistitDate());
  337. billPcr.setSubDate(LocalDateTime.now());
  338. billPcr.setBillStatus(0);
  339. billPcr.setProcessId(billClean.getProcessId());
  340. billPcr.setFarmId(billClean.getFarmId());
  341. billPcr.setTestLocation("场内");
  342. billPcr.setTestLocationId(4);
  343. billPcr.setQualifiedDate(configuration.getPcr());
  344. pcrMapper.insert(billPcr);
  345. if (exist.getExist() == 0) {
  346. String status = baseProcess.getAllLocationStatus();
  347. String[] split1 = status.split(",");
  348. split1[0] = "2";
  349. split1[1] = "2";
  350. split1[2] = "2";
  351. split1[3] = "2";
  352. split1[4] = "1";
  353. baseProcess.setAllLocationStatus(split1[0] + "," + split1[1] + "," + split1[2] + "," + split1[3] + "," + split1[4] + status.substring(9));
  354. } else {
  355. String status = baseProcess.getAllLocationStatus();
  356. String[] split1 = status.split(",");
  357. split1[0] = "2";
  358. split1[1] = "2";
  359. split1[2] = "2";
  360. split1[3] = "1";
  361. baseProcess.setAllLocationStatus(split1[0] + "," + split1[1] + "," + split1[2] + "," + split1[3] + status.substring(7));
  362. }
  363. } else {
  364. //生成隔离申请
  365. BillIsolate isolate = new BillIsolate();
  366. isolate.setPhone(billClean.getPhone());
  367. isolate.setVistitType(billClean.getVistitType());
  368. isolate.setDestName(billClean.getDestName());
  369. isolate.setDestId(billClean.getDestId());
  370. isolate.setAdmissionUserName(billClean.getAdmissionUserName());
  371. isolate.setAdmissionUserId(billClean.getAdmissionUserId());
  372. isolate.setVistitDate(billClean.getVistitDate());
  373. isolate.setSubDate(LocalDateTime.now());
  374. isolate.setFarmId(billClean.getFarmId());
  375. isolate.setBillStatus(0);
  376. isolate.setIsolateDayNum("");
  377. isolate.setProcessId(billClean.getProcessId());
  378. isolate.setIsolateLocation(baseLocation.getNextLocation());
  379. isolate.setIsolateLocationId(baseLocation.getNextId());
  380. isolateMapper.insert(isolate);
  381. if (exist.getExist() == 0) {
  382. String status = baseProcess.getAllLocationStatus();
  383. String[] split1 = status.split(",");
  384. split1[0] = "2";
  385. split1[1] = "2";
  386. split1[2] = "2";
  387. split1[3] = "2";
  388. split1[4] = "2";
  389. baseProcess.setAllLocationStatus(split1[0] + "," + split1[1] + "," + split1[2] + "," + split1[3] + "," + split1[4] + "," + "1");
  390. } else {
  391. String status = baseProcess.getAllLocationStatus();
  392. String[] split1 = status.split(",");
  393. split1[0] = "2";
  394. split1[1] = "2";
  395. split1[2] = "2";
  396. split1[3] = "2";
  397. baseProcess.setAllLocationStatus(split1[0] + "," + split1[1] + "," + split1[2] + "," + split1[3] + "," + "1");
  398. }
  399. }
  400. }
  401. if (baseProcess.getDestId() == 1) {
  402. baseProcess.setAllLocationStatus("2,2");
  403. }
  404. if (baseProcess.getDestId() == 4 && baseLocation.getId() == 1) {
  405. baseProcess.setAllLocationStatus("2,2,2,1,0");
  406. }
  407. if (baseProcess.getDestId() == 2) {
  408. baseProcess.setAllLocationStatus("2,2,2");
  409. }
  410. baseProcess.setUpdateDate(baseProcess.getUpdateDate() + "," + sdf.format(new Date()));
  411. baseProcess.setCurrentLocation(baseProcess.getCurrentLocation() + "," + baseLocation.getLocationName());
  412. baseProcess.setCurrentLocationId(baseProcess.getCurrentLocationId() + "," + baseLocation.getId());
  413. String status = baseProcess.getCurrentStatus();
  414. String substring = status.substring(0, status.length() - 1);
  415. baseProcess.setCurrentStatus(substring + "1," + 0);
  416. } else {
  417. billClean.setBillStatus(2);
  418. billClean.setPassUserName(TokenSign.getUserNameByJwtToken(httpServletRequest));
  419. billClean.setPassUserId(TokenSign.getMemberIdByJwtToken(httpServletRequest));
  420. billClean.setTestLocation(baseLocation.getLocationName());
  421. billClean.setTestLocationId(baseLocation.getId());
  422. billClean.setCheckDate(sdf.parse(date));
  423. billClean.setPassDate(sdf.parse(sdf.format(new Date())));
  424. billClean.setCleanTime("10");
  425. if (baseProcess.getDestId() == 1) {
  426. baseProcess.setAllLocationStatus("2,3");
  427. }
  428. if (baseProcess.getDestId() == 2) {
  429. baseProcess.setAllLocationStatus("2,3,0");
  430. }
  431. if (baseProcess.getDestId() >= 3 && baseLocation.getId() == 3) {
  432. String status = baseProcess.getAllLocationStatus();
  433. String[] split1 = status.split(",");
  434. split1[0] = "2";
  435. split1[1] = "2";
  436. split1[2] = "2";
  437. split1[3] = "3";
  438. baseProcess.setAllLocationStatus(split1[0] + "," + split1[1] + "," + split1[2] + "," + split1[3] + status.substring(7));
  439. }
  440. if (baseLocation.getId() == 1 && baseProcess.getDestId() > 2) {
  441. String status = baseProcess.getAllLocationStatus();
  442. String[] split1 = status.split(",");
  443. split1[0] = "2";
  444. split1[1] = "3";
  445. split1[2] = "0";
  446. split1[3] = "0";
  447. baseProcess.setAllLocationStatus(split1[0] + "," + split1[1] + "," + split1[2] + "," + split1[3] + status.substring(7));
  448. }
  449. if (baseLocation.getId() == 4 && exist.getExist() == 0) {
  450. String status = baseProcess.getAllLocationStatus();
  451. String[] split1 = status.split(",");
  452. split1[0] = "2";
  453. split1[1] = "2";
  454. split1[2] = "2";
  455. split1[3] = "2";
  456. split1[4] = "3";
  457. baseProcess.setAllLocationStatus(split1[0] + "," + split1[1] + "," + split1[2] + "," + split1[3] + "," + split1[4] + status.substring(9));
  458. }
  459. if (exist.getExist() == 1 && baseProcess.getDestId() > 2 && baseLocation.getId() == 4) {
  460. String status = baseProcess.getAllLocationStatus();
  461. String[] split1 = status.split(",");
  462. split1[0] = "2";
  463. split1[1] = "2";
  464. split1[2] = "2";
  465. split1[3] = "3";
  466. baseProcess.setAllLocationStatus(split1[0] + "," + split1[1] + "," + split1[2] + "," + split1[3] + status.substring(7));
  467. }
  468. baseProcess.setProcessType(2);
  469. baseProcess.setUpdateDate(baseProcess.getUpdateDate() + "," + sdf.format(new Date()));
  470. baseProcess.setCurrentLocation(baseProcess.getCurrentLocation());
  471. baseProcess.setCurrentLocationId(baseProcess.getCurrentLocationId());
  472. String status = baseProcess.getCurrentStatus();
  473. String substring = status.substring(0, status.length() - 1);
  474. baseProcess.setCurrentStatus(substring + "2");
  475. }
  476. cleanMapper.updateById(billClean);
  477. processMapper.updateById(baseProcess);
  478. return new Result(10000, "修改成功!", true);
  479. } else {
  480. //当前是目的地
  481. if ("1".equals(result)) {
  482. billClean.setBillStatus(1);
  483. baseProcess.setProcessType(1);
  484. } else {
  485. billClean.setBillStatus(2);
  486. baseProcess.setProcessType(2);
  487. }
  488. billClean.setPassUserName(TokenSign.getUserNameByJwtToken(httpServletRequest));
  489. billClean.setPassUserId(TokenSign.getMemberIdByJwtToken(httpServletRequest));
  490. billClean.setTestLocation(baseLocation.getLocationName());
  491. billClean.setTestLocationId(baseLocation.getId());
  492. billClean.setCheckDate(sdf.parse(date));
  493. billClean.setPassDate(sdf.parse(sdf.format(new Date())));
  494. billClean.setCleanTime("10");
  495. baseProcess.setUpdateDate(baseProcess.getUpdateDate() + "," + sdf.format(new Date()));
  496. baseProcess.setCurrentLocation(baseProcess.getCurrentLocation());
  497. baseProcess.setCurrentLocationId(baseProcess.getCurrentLocationId());
  498. String status = baseProcess.getCurrentStatus();
  499. String substring = status.substring(0, status.length() - 1);
  500. baseProcess.setCurrentStatus(substring + "1");
  501. String ids = baseProcess.getAllLocationId();
  502. String[] split = ids.split(",");
  503. Integer s22 = 0;
  504. for (int i = 0; i < split.length; i++) {
  505. if (Integer.parseInt(split[i]) == baseLocation.getId()) {
  506. s22 = i;
  507. }
  508. }
  509. String status1 = baseProcess.getAllLocationStatus();
  510. StringBuilder split1 = new StringBuilder(status1);
  511. split1.replace(s22, s22 + 1, "3");
  512. baseProcess.setAllLocationStatus(split1.toString());
  513. if (baseProcess.getDestId() == 1) {
  514. baseProcess.setAllLocationStatus("2,3");
  515. }
  516. if (baseProcess.getDestId() == 3) {
  517. baseProcess.setAllLocationStatus("2,2,3");
  518. }
  519. if (baseProcess.getDestId() == 4) {
  520. baseProcess.setAllLocationStatus("2,2,2,3");
  521. }
  522. processMapper.updateById(baseProcess);
  523. cleanMapper.updateById(billClean);
  524. return new Result(10000, "修改成功!", true);
  525. }
  526. }
  527. @Resource
  528. private BillCleanMapper billCleanMapper;
  529. @Override
  530. public Result listPersonalClean(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
  531. String pageNo = paramsMap.get("pageNum");
  532. String pageSize = paramsMap.get("pageSize");
  533. String vistitType = paramsMap.get("vistitType");
  534. Page<BillClean> page = new Page<>(Integer.parseInt(pageNo), Integer.parseInt(pageSize));
  535. QueryWrapper<BillClean> queryWrapper = new QueryWrapper<>();
  536. queryWrapper.eq(StringUtils.isNotBlank(vistitType), "vistit_type", vistitType).eq("admission_user_id", TokenSign.getMemberIdByJwtToken(httpServletRequest)).orderByDesc("sub_date");
  537. return new Result(ResultCode.SUCCESS, billCleanMapper.selectPage(page, new QueryWrapper<BillClean>().eq(StringUtils.isNotBlank(vistitType), "vistit_type", vistitType).eq("admission_user_id", TokenSign.getMemberIdByJwtToken(httpServletRequest)).orderByDesc("sub_date")), billCleanMapper.selectCount(queryWrapper));
  538. }
  539. @Override
  540. public Result carClean(HttpServletRequest httpServletRequest, String farmId, String id, String data, MultipartFile img1, MultipartFile img2, MultipartFile img3, MultipartFile img4, MultipartFile img5, String type) throws ParseException, IOException {
  541. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
  542. if (StringUtils.isBlank(data)) {
  543. data = sdf.format(new Date());
  544. }
  545. if ("1".equals(type)) {
  546. BillClean billClean1 = cleanMapper.selectById(id);//某条洗消记录
  547. if (billClean1.getBillStatus() != 0) {
  548. return new Result(10001, "该订单已通过,无需再次提交!", false);
  549. }
  550. //洗消上传
  551. BillClean billClean = cleanMapper.selectById(id);//某条洗消记录
  552. System.out.println("洗消记录的id:" + billClean.getTestLocationId());
  553. Integer testId = billClean.getTestLocationId();
  554. QueryWrapper<BaseLocation> locationQueryWrapper = new QueryWrapper<>();
  555. locationQueryWrapper.eq("id", testId);
  556. BaseLocation baseLocation = locationMapper.selectOne(locationQueryWrapper);//当前所在的位置
  557. QueryWrapper<BaseProcess> queryWrapper = new QueryWrapper<>();
  558. queryWrapper.eq("farm_id", farmId).eq("id", billClean.getProcessId());
  559. BaseProcess baseProcess = processMapper.selectOne(queryWrapper);//某条进程
  560. billClean.setBillStatus(0);
  561. billClean.setImgStatus(1);
  562. billClean.setPassUserName(TokenSign.getUserNameByJwtToken(httpServletRequest));
  563. billClean.setPassUserId(TokenSign.getMemberIdByJwtToken(httpServletRequest));
  564. billClean.setTestLocation(baseLocation.getLocationName());
  565. billClean.setTestLocationId(baseLocation.getId());
  566. billClean.setCheckDate(sdf.parse(data));
  567. billClean.setPassDate(sdf.parse(sdf.format(new Date())));
  568. billClean.setCleanTime("10");
  569. String s1 = "";
  570. String s2 = "";
  571. String s3 = "";
  572. String s4 = "";
  573. String s5 = "";
  574. if (ObjectUtil.isNotEmpty(img1)) {
  575. if (uploadImage.getImageCom(img1).equals("上传失败")) {
  576. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  577. return new Result(10001, "图片1上传失败", false);
  578. }
  579. s1 = uploadImage.uploadImg(img1);
  580. }
  581. if (ObjectUtil.isNotEmpty(img2)) {
  582. if (uploadImage.getImageCom(img2).equals("上传失败")) {
  583. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  584. return new Result(10001, "图片2上传失败", false);
  585. }
  586. s2 = "," + uploadImage.uploadImg(img2);
  587. }
  588. if (ObjectUtil.isNotEmpty(img3)) {
  589. if (uploadImage.getImageCom(img3).equals("上传失败")) {
  590. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  591. return new Result(10001, "图片3上传失败", false);
  592. }
  593. s3 = "," + uploadImage.uploadImg(img3);
  594. }
  595. if (ObjectUtil.isNotEmpty(img4)) {
  596. if (uploadImage.getImageCom(img4).equals("上传失败")) {
  597. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  598. return new Result(10001, "图片4上传失败", false);
  599. }
  600. s4 = "," + uploadImage.uploadImg(img4);
  601. }
  602. if (ObjectUtil.isNotEmpty(img5)) {
  603. if (uploadImage.getImageCom(img5).equals("上传失败")) {
  604. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  605. return new Result(10001, "图片5上传失败", false);
  606. }
  607. s5 = "," + uploadImage.uploadImg(img5);
  608. }
  609. String s = s1 + s2 + s3 + s4 + s5;
  610. billClean.setImgUrl(s);
  611. cleanMapper.updateById(billClean);
  612. //物资车生成二次申请
  613. } else {
  614. BillDry billClean = dryMapper.selectById(id);//某条烘干记录
  615. if (billClean.getBillStatus() != 0) {
  616. return new Result(10001, "该订单已通过,无需再次提交!", false);
  617. }
  618. System.out.println("洗消记录的id:" + billClean.getTestLocationId());
  619. Integer testId = billClean.getTestLocationId();
  620. QueryWrapper<BaseLocation> locationQueryWrapper = new QueryWrapper<>();
  621. locationQueryWrapper.eq("id", testId);
  622. BaseLocation baseLocation = locationMapper.selectOne(locationQueryWrapper);//当前所在的位置
  623. QueryWrapper<BaseProcess> queryWrapper = new QueryWrapper<>();
  624. queryWrapper.eq("farm_id", farmId).eq("id", billClean.getProcessId());
  625. BaseProcess baseProcess = processMapper.selectOne(queryWrapper);//某条进程
  626. billClean.setBillStatus(0);
  627. billClean.setImgStatus(1);
  628. billClean.setPassUserName(TokenSign.getUserNameByJwtToken(httpServletRequest));
  629. billClean.setPassUserId(TokenSign.getMemberIdByJwtToken(httpServletRequest));
  630. billClean.setTestLocation(baseLocation.getLocationName());
  631. billClean.setTestLocationId(baseLocation.getId());
  632. billClean.setCheckDate(sdf.parse(data));
  633. billClean.setPassDate(sdf.parse(sdf.format(new Date())));
  634. billClean.setDryTem("70");
  635. billClean.setDryTime("10");
  636. String s1 = "";
  637. String s2 = "";
  638. String s3 = "";
  639. String s4 = "";
  640. String s5 = "";
  641. if (ObjectUtil.isNotEmpty(img1)) {
  642. if (uploadImage.getImageCom(img1).equals("上传失败")) {
  643. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  644. return new Result(10001, "图片1上传失败", false);
  645. }
  646. s1 = uploadImage.uploadImg(img1);
  647. }
  648. if (ObjectUtil.isNotEmpty(img2)) {
  649. if (uploadImage.getImageCom(img2).equals("上传失败")) {
  650. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  651. return new Result(10001, "图片2上传失败", false);
  652. }
  653. s2 = "," + uploadImage.uploadImg(img2);
  654. }
  655. if (ObjectUtil.isNotEmpty(img3)) {
  656. if (uploadImage.getImageCom(img3).equals("上传失败")) {
  657. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  658. return new Result(10001, "图片3上传失败", false);
  659. }
  660. s3 = "," + uploadImage.uploadImg(img3);
  661. }
  662. if (ObjectUtil.isNotEmpty(img4)) {
  663. if (uploadImage.getImageCom(img4).equals("上传失败")) {
  664. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  665. return new Result(10001, "图片4上传失败", false);
  666. }
  667. s4 = "," + uploadImage.uploadImg(img4);
  668. }
  669. if (ObjectUtil.isNotEmpty(img5)) {
  670. if (uploadImage.getImageCom(img5).equals("上传失败")) {
  671. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  672. return new Result(10001, "图片5上传失败", false);
  673. }
  674. s5 = "," + uploadImage.uploadImg(img5);
  675. }
  676. String s = s1 + s2 + s3 + s4 + s5;
  677. billClean.setImgUrl(s);
  678. dryMapper.updateById(billClean);
  679. }
  680. return new Result(10000, "提交成功!", true);
  681. }
  682. @Override
  683. public Result listCleanAndDry(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
  684. String type = paramsMap.get("type");
  685. String pageNo = paramsMap.get("pageNum");
  686. String pageSize = paramsMap.get("pageSize");
  687. Page<CleanAndDryVo> page = new Page<>(Integer.parseInt(pageNo), Integer.parseInt(pageSize));
  688. Page<CleanAndDryVo> cleanAndDryVoPage;
  689. switch (type) {
  690. case "1":
  691. cleanAndDryVoPage = billCleanMapper.listCleanAndDry(page, Integer.parseInt(TokenSign.getFarmIds(httpServletRequest)), 0);
  692. break;
  693. case "2":
  694. cleanAndDryVoPage = billCleanMapper.listCleanAndDry(page, Integer.parseInt(TokenSign.getFarmIds(httpServletRequest)), 1);
  695. break;
  696. case "3":
  697. cleanAndDryVoPage = billCleanMapper.listCleanAndDry(page, Integer.parseInt(TokenSign.getFarmIds(httpServletRequest)), 2);
  698. break;
  699. default:
  700. cleanAndDryVoPage = billCleanMapper.listCleanAndDry(page, Integer.parseInt(TokenSign.getFarmIds(httpServletRequest)));
  701. break;
  702. }
  703. return new Result(ResultCode.SUCCESS, cleanAndDryVoPage, cleanAndDryVoPage.getSize());
  704. }
  705. @Override
  706. public Result listPersonalCleanAndDry(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
  707. String pageNo = paramsMap.get("pageNum");
  708. String pageSize = paramsMap.get("pageSize");
  709. String vistitType = paramsMap.get("vistitType");
  710. Page<CleanAndDryVo> page = new Page<>(Integer.parseInt(pageNo), Integer.parseInt(pageSize));
  711. Integer userId = TokenSign.getMemberIdByJwtToken(httpServletRequest);
  712. Page<CleanAndDryVo> cleanAndDryVoPage = cleanMapper.listPersonalCleanAndDry(page, userId, vistitType);
  713. return new Result(ResultCode.SUCCESS, cleanAndDryVoPage, cleanAndDryVoPage.getSize());
  714. }
  715. @Override
  716. public Result goodsCarClean(HttpServletRequest httpServletRequest, String farmId, String id, String date, MultipartFile img1,
  717. MultipartFile img2, MultipartFile img3, MultipartFile img4, MultipartFile img5, String type, String result
  718. ) throws ParseException, IOException {
  719. QueryWrapper<Exist> existQueryWrapper = new QueryWrapper<>();
  720. existQueryWrapper.eq("farm_id", farmId);
  721. Exist exist = existMapper.selectOne(existQueryWrapper);//判断是否有二级洗消站
  722. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
  723. if (StringUtils.isBlank(date)) {
  724. date = sdf.format(new Date());
  725. }
  726. /* BillClean billClean1 = cleanMapper.selectById(id);//某条洗消记录
  727. if (billClean1.getBillStatus() != 0) {
  728. return new Result(10001, "该订单已通过,无需再次提交!", false);
  729. }*/
  730. String s1 = "";
  731. String s2 = "";
  732. String s3 = "";
  733. String s4 = "";
  734. String s5 = "";
  735. if (ObjectUtil.isNotEmpty(img1)) {
  736. if (uploadImage.getImageCom(img1).equals("上传失败")) {
  737. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  738. return new Result(10001, "图片1上传失败", false);
  739. }
  740. s1 = uploadImage.uploadImg(img1);
  741. }
  742. if (ObjectUtil.isNotEmpty(img2)) {
  743. if (uploadImage.getImageCom(img2).equals("上传失败")) {
  744. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  745. return new Result(10001, "图片2上传失败", false);
  746. }
  747. s2 = "," + uploadImage.uploadImg(img2);
  748. }
  749. if (ObjectUtil.isNotEmpty(img3)) {
  750. if (uploadImage.getImageCom(img3).equals("上传失败")) {
  751. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  752. return new Result(10001, "图片3上传失败", false);
  753. }
  754. s3 = "," + uploadImage.uploadImg(img3);
  755. }
  756. if (ObjectUtil.isNotEmpty(img4)) {
  757. if (uploadImage.getImageCom(img4).equals("上传失败")) {
  758. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  759. return new Result(10001, "图片4上传失败", false);
  760. }
  761. s4 = "," + uploadImage.uploadImg(img4);
  762. }
  763. if (ObjectUtil.isNotEmpty(img5)) {
  764. if (uploadImage.getImageCom(img5).equals("上传失败")) {
  765. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  766. return new Result(10001, "图片5上传失败", false);
  767. }
  768. s5 = "," + uploadImage.uploadImg(img5);
  769. }
  770. String s = s1 + s2 + s3 + s4 + s5;
  771. if ("1".equals(type)) {
  772. BillClean billClean = cleanMapper.selectById(id);//某条洗消记录
  773. QueryWrapper<BaseProcess> queryWrapper = new QueryWrapper<>();
  774. queryWrapper.eq("farm_id", farmId).eq("id", billClean.getProcessId());
  775. BaseProcess baseProcess = processMapper.selectOne(queryWrapper);//某条进程
  776. QueryWrapper<BaseLocation> locationQueryWrapper = new QueryWrapper<>();
  777. locationQueryWrapper.eq("id", billClean.getTestLocationId());
  778. BaseLocation baseLocation = locationMapper.selectOne(locationQueryWrapper);//当前所在的位置
  779. if (billClean.getDestId() >= billClean.getTestLocationId() || billClean.getDestId() == 7) { //不是目的地
  780. if ("1".equals(result)) {
  781. billClean.setBillStatus(1);
  782. billClean.setPassUserName(TokenSign.getUserNameByJwtToken(httpServletRequest));
  783. billClean.setPassUserId(TokenSign.getMemberIdByJwtToken(httpServletRequest));
  784. billClean.setTestLocation(baseLocation.getLocationName());
  785. billClean.setTestLocationId(baseLocation.getId());
  786. billClean.setCheckDate(sdf.parse(date));
  787. billClean.setPassDate(sdf.parse(sdf.format(new Date())));
  788. billClean.setImgUrl(s);
  789. billClean.setImgStatus(1);
  790. billClean.setCleanTime("10");
  791. cleanMapper.updateById(billClean);
  792. if (billClean.getDestId() == 11) {
  793. baseProcess.setAllLocationStatus("2,2,2,2");
  794. }
  795. if (billClean.getTestLocationId() == 9 || billClean.getTestLocationId() == 10) {
  796. if (billClean.getDestId() > 9 || billClean.getDestId() > 10) {
  797. Integer processId = billClean.getProcessId();
  798. QueryWrapper<BillPersonnelAdmission> queryWrapper1 = new QueryWrapper<>();
  799. queryWrapper1.eq("farm_id", farmId).eq("process_id", processId);
  800. BillPersonnelAdmission admission = admissionMapper.selectOne(queryWrapper1);
  801. admission.setBillStatus(1);
  802. admission.setPassDate(LocalDateTime.now());
  803. admission.setPassUserId(TokenSign.getMemberIdByJwtToken(httpServletRequest));
  804. admission.setPassUserName(TokenSign.getUserNameByJwtToken(httpServletRequest));
  805. admissionMapper.updateById(admission);
  806. if (billClean.getTestLocationId() == 10) {
  807. baseProcess.setAllLocationStatus("2,2,2,1");
  808. } else {
  809. baseProcess.setAllLocationStatus("2,2,1,0");
  810. }
  811. }
  812. if (billClean.getDestId() == 9) {
  813. baseProcess.setAllLocationStatus("2,2");
  814. }
  815. if (billClean.getDestId() == 10) {
  816. baseProcess.setAllLocationStatus("2,2,2");
  817. }
  818. }
  819. //第一次通过生成洗消
  820. if (billClean.getTestLocationId() == 6 && exist.getExist() == 0) {
  821. BillClean clean = new BillClean();
  822. clean.setVistitType(billClean.getVistitType());
  823. clean.setVistitDate(billClean.getVistitDate());
  824. clean.setDestName(billClean.getDestName());
  825. clean.setDestId(billClean.getDestId());
  826. clean.setAdmissionUserId(billClean.getAdmissionUserId());
  827. clean.setAdmissionUserName(billClean.getAdmissionUserName());
  828. clean.setSubDate(LocalDateTime.now());
  829. clean.setBillStatus(0);
  830. clean.setImgStatus(0);
  831. clean.setFarmId(billClean.getFarmId());
  832. clean.setCarNum(billClean.getCarNum());
  833. clean.setPhone(billClean.getPhone());
  834. clean.setProcessId(billClean.getProcessId());
  835. clean.setTestLocationId(baseLocation.getNextId());
  836. clean.setTestLocation(baseLocation.getNextLocation());
  837. cleanMapper.insert(clean);
  838. if (billClean.getDestId() == 7) {
  839. baseProcess.setAllLocationStatus("2,2,1");
  840. } else {
  841. baseProcess.setAllLocationStatus("2,2,1,0");
  842. }
  843. }
  844. if (billClean.getTestLocationId() == 6 && exist.getExist() == 1) {
  845. if (baseProcess.getDestId() > 6) {
  846. baseProcess.setAllLocationStatus("2,2,2");
  847. } else {
  848. baseProcess.setAllLocationStatus("2,2");
  849. }
  850. }
  851. if (billClean.getTestLocationId() == 7) {
  852. //生成烘干申请
  853. BillDry billPcr = new BillDry();
  854. billPcr.setPhone(billClean.getPhone());
  855. billPcr.setVistitType(billClean.getVistitType());
  856. billPcr.setDestName(billClean.getDestName());
  857. billPcr.setDestId(billClean.getDestId());
  858. billPcr.setAdmissionUserName(billClean.getAdmissionUserName());
  859. billPcr.setAdmissionUserId(billClean.getAdmissionUserId());
  860. billPcr.setVistitDate(billClean.getVistitDate());
  861. billPcr.setSubDate(LocalDateTime.now());
  862. billPcr.setBillStatus(0);
  863. billPcr.setImgStatus(0);
  864. billPcr.setCarNum(billClean.getCarNum());
  865. billPcr.setProcessId(billClean.getProcessId());
  866. billPcr.setFarmId(billClean.getFarmId());
  867. billPcr.setTestLocation(baseLocation.getLocationName());
  868. billPcr.setTestLocationId(baseLocation.getId());
  869. dryMapper.insert(billPcr);
  870. baseProcess.setAllLocationStatus("2,2,1,0");
  871. }
  872. baseProcess.setUpdateDate(baseProcess.getUpdateDate() + "," + sdf.format(new Date()));
  873. baseProcess.setCurrentLocation(baseProcess.getCurrentLocation() + "," + baseLocation.getLocationName());
  874. baseProcess.setCurrentLocationId(baseProcess.getCurrentLocationId() + "," + baseLocation.getId());
  875. String status = baseProcess.getCurrentStatus();
  876. String substring = status.substring(0, status.length() - 1);
  877. baseProcess.setCurrentStatus(substring + "1," + 0);
  878. processMapper.updateById(baseProcess);
  879. } else {
  880. billClean.setImgStatus(1);
  881. billClean.setImgUrl(s);
  882. billClean.setBillStatus(2);
  883. billClean.setPassUserName(TokenSign.getUserNameByJwtToken(httpServletRequest));
  884. billClean.setPassUserId(TokenSign.getMemberIdByJwtToken(httpServletRequest));
  885. billClean.setTestLocation(baseLocation.getLocationName());
  886. billClean.setTestLocationId(baseLocation.getId());
  887. billClean.setCheckDate(sdf.parse(date));
  888. billClean.setPassDate(sdf.parse(sdf.format(new Date())));
  889. billClean.setCleanTime("10");
  890. cleanMapper.updateById(billClean);
  891. baseProcess.setProcessType(2);
  892. baseProcess.setUpdateDate(baseProcess.getUpdateDate() + "," + sdf.format(new Date()));
  893. baseProcess.setCurrentLocation(baseProcess.getCurrentLocation());
  894. baseProcess.setCurrentLocationId(baseProcess.getCurrentLocationId());
  895. String status = baseProcess.getCurrentStatus();
  896. String substring = status.substring(0, status.length() - 1);
  897. baseProcess.setCurrentStatus(substring + "2");
  898. String status1 = baseProcess.getAllLocationStatus();
  899. String[] split = status1.split(",");
  900. if (billClean.getTestLocationId() == 6) {
  901. split[0] = "2";
  902. split[1] = "3";
  903. baseProcess.setAllLocationStatus(split[0] + "," + split[1] + status1.substring(3));
  904. }
  905. if (billClean.getTestLocationId() == 7) {
  906. split[0] = "2";
  907. split[1] = "2";
  908. split[2] = "3";
  909. baseProcess.setAllLocationStatus(split[0] + "," + split[1] + "," + split[2] + status1.substring(5));
  910. }
  911. if (billClean.getTestLocationId() == 9) {
  912. split[0] = "2";
  913. split[1] = "3";
  914. baseProcess.setAllLocationStatus(split[0] + "," + split[1] + status1.substring(3));
  915. }
  916. if (billClean.getTestLocationId() == 10) {
  917. split[0] = "2";
  918. split[1] = "3";
  919. baseProcess.setAllLocationStatus(split[0] + "," + split[1] + status1.substring(3));
  920. }
  921. if (billClean.getTestLocationId() == 11) {
  922. baseProcess.setAllLocationStatus("2,3");
  923. }
  924. processMapper.updateById(baseProcess);
  925. }
  926. return new Result(10000, "修改成功!", true);
  927. } else {
  928. //当前是目的地
  929. if ("1".equals(result)) {
  930. billClean.setBillStatus(1);
  931. baseProcess.setProcessType(1);
  932. } else {
  933. billClean.setBillStatus(2);
  934. baseProcess.setProcessType(2);
  935. }
  936. billClean.setImgStatus(1);
  937. billClean.setImgUrl(s);
  938. billClean.setPassUserName(TokenSign.getUserNameByJwtToken(httpServletRequest));
  939. billClean.setPassUserId(TokenSign.getMemberIdByJwtToken(httpServletRequest));
  940. billClean.setTestLocation(baseLocation.getLocationName());
  941. billClean.setTestLocationId(baseLocation.getId());
  942. billClean.setCheckDate(sdf.parse(date));
  943. billClean.setPassDate(sdf.parse(sdf.format(new Date())));
  944. billClean.setCleanTime("10");
  945. String status1 = baseProcess.getAllLocationStatus();
  946. String[] split = status1.split(",");
  947. if (billClean.getTestLocationId() == 6) {
  948. split[0] = "2";
  949. split[1] = "3";
  950. baseProcess.setAllLocationStatus(split[0] + "," + split[1] + status1.substring(3));
  951. }
  952. if (billClean.getTestLocationId() == 7) {
  953. split[0] = "2";
  954. split[1] = "2";
  955. split[2] = "3";
  956. baseProcess.setAllLocationStatus(split[0] + "," + split[1] + "," + split[2] + status1.substring(5));
  957. }
  958. if (billClean.getTestLocationId() == 9) {
  959. split[0] = "2";
  960. split[1] = "3";
  961. baseProcess.setAllLocationStatus(split[0] + "," + split[1] + status1.substring(3));
  962. }
  963. if (billClean.getTestLocationId() == 10) {
  964. split[0] = "2";
  965. split[1] = "3";
  966. baseProcess.setAllLocationStatus(split[0] + "," + split[1] + status1.substring(3));
  967. }
  968. if (billClean.getTestLocationId() == 11) {
  969. baseProcess.setAllLocationStatus("2,3");
  970. }
  971. baseProcess.setUpdateDate(baseProcess.getUpdateDate() + "," + sdf.format(new Date()));
  972. baseProcess.setCurrentLocation(baseProcess.getCurrentLocation());
  973. baseProcess.setCurrentLocationId(baseProcess.getCurrentLocationId());
  974. String status = baseProcess.getCurrentStatus();
  975. String substring = status.substring(0, status.length() - 1);
  976. baseProcess.setCurrentStatus(substring + "1");
  977. processMapper.updateById(baseProcess);
  978. cleanMapper.updateById(billClean);
  979. return new Result(10000, "修改成功!", true);
  980. }
  981. } else {
  982. BillDry billClean = dryMapper.selectById(id);//某条烘干记录
  983. QueryWrapper<BaseProcess> queryWrapper = new QueryWrapper<>();
  984. queryWrapper.eq("farm_id", farmId).eq("id", billClean.getProcessId());
  985. BaseProcess baseProcess = processMapper.selectOne(queryWrapper);//某条进程
  986. QueryWrapper<BaseLocation> locationQueryWrapper = new QueryWrapper<>();
  987. locationQueryWrapper.eq("id", billClean.getTestLocationId());
  988. BaseLocation baseLocation = locationMapper.selectOne(locationQueryWrapper);//当前所在的位置
  989. if (baseProcess.getProcessType() == 2 || baseProcess.getProcessType() == 1) {
  990. return new Result(10001, "修改失败!该申请已提前结束或者被拒绝", false);
  991. } else {
  992. if ("1".equals(result)) {
  993. //烘干通过
  994. billClean.setImgUrl(s);
  995. billClean.setBillStatus(1);
  996. billClean.setPassDate(new Date());
  997. billClean.setCheckDate(new Date());
  998. billClean.setPhone(billClean.getPhone());
  999. billClean.setCarNum(billClean.getCarNum());
  1000. billClean.setImgStatus(1);
  1001. billClean.setPassUserName(TokenSign.getUserNameByJwtToken(httpServletRequest));
  1002. billClean.setPassUserId(TokenSign.getMemberIdByJwtToken(httpServletRequest));
  1003. billClean.setTestLocation(baseLocation.getLocationName());
  1004. billClean.setTestLocationId(baseLocation.getId());
  1005. billClean.setDryTime("10");
  1006. billClean.setDryTem("70");
  1007. dryMapper.updateById(billClean);
  1008. baseProcess.setProcessType(1);
  1009. baseProcess.setUpdateDate(baseProcess.getUpdateDate() + "," + sdf.format(new Date()));
  1010. baseProcess.setCurrentLocation(baseProcess.getCurrentLocation());
  1011. baseProcess.setCurrentLocationId(baseProcess.getCurrentLocationId());
  1012. String status = baseProcess.getCurrentStatus();
  1013. String substring = status.substring(0, status.length() - 1);
  1014. baseProcess.setCurrentStatus(substring + "1");
  1015. baseProcess.setAllLocationStatus("2,2,2,2");
  1016. processMapper.updateById(baseProcess);
  1017. } else {
  1018. billClean.setImgStatus(1);
  1019. billClean.setImgUrl(s);
  1020. billClean.setBillStatus(2);
  1021. billClean.setPassUserName(TokenSign.getUserNameByJwtToken(httpServletRequest));
  1022. billClean.setPassUserId(TokenSign.getMemberIdByJwtToken(httpServletRequest));
  1023. billClean.setTestLocation(baseLocation.getLocationName());
  1024. billClean.setTestLocationId(baseLocation.getId());
  1025. billClean.setCheckDate(sdf.parse(date));
  1026. billClean.setPassDate(sdf.parse(sdf.format(new Date())));
  1027. billClean.setDryTime("10");
  1028. billClean.setDryTem("70");
  1029. dryMapper.updateById(billClean);
  1030. baseProcess.setProcessType(2);
  1031. baseProcess.setUpdateDate(baseProcess.getUpdateDate() + "," + sdf.format(new Date()));
  1032. baseProcess.setCurrentLocation(baseProcess.getCurrentLocation());
  1033. baseProcess.setCurrentLocationId(baseProcess.getCurrentLocationId());
  1034. String status = baseProcess.getCurrentStatus();
  1035. String substring = status.substring(0, status.length() - 1);
  1036. baseProcess.setCurrentStatus(substring + "2");
  1037. // baseProcess.setAllLocationStatus("2,2,2,3");
  1038. String status1 = baseProcess.getAllLocationStatus();
  1039. String[] split = status1.split(",");
  1040. if (billClean.getTestLocationId() == 7) {
  1041. split[0] = "2";
  1042. split[1] = "2";
  1043. split[2] = "3";
  1044. baseProcess.setAllLocationStatus(split[0] + "," + split[1] + "," + split[2] + status1.substring(5));
  1045. }
  1046. processMapper.updateById(baseProcess);
  1047. }
  1048. return new Result(10000, "修改成功!", true);
  1049. }
  1050. }
  1051. }
  1052. @Override
  1053. public Result listCount(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
  1054. String farmId = paramsMap.get("farmId");
  1055. Date timesmorning = DataUill.getTimesmorning();
  1056. QueryWrapper<BillClean> queryWrapper = new QueryWrapper<>();
  1057. queryWrapper.eq("farm_id", farmId).ge("sub_date", timesmorning);
  1058. queryWrapper.eq("bill_status", 1);
  1059. Integer count = billCleanMapper.selectCount(queryWrapper);//合格
  1060. QueryWrapper<BillClean> queryWrapper1 = new QueryWrapper<>();
  1061. queryWrapper1.eq("farm_id", farmId).ge("sub_date", timesmorning);
  1062. queryWrapper1.eq("bill_status", 2);
  1063. Integer count1 = billCleanMapper.selectCount(queryWrapper1);//异常
  1064. Integer allCount = count + count1;
  1065. DecimalFormat def = new DecimalFormat("0.00");
  1066. String rank;
  1067. if (allCount == 0 || allCount == null) {
  1068. Double ranks = Double.valueOf("0.00");
  1069. rank = ranks.toString();
  1070. } else {
  1071. Double ranks = (Double.valueOf(count.toString()) / Double.valueOf(allCount.toString())) * 100;
  1072. rank = def.format(ranks);
  1073. }
  1074. JSONObject jsonObject = new JSONObject();
  1075. jsonObject.put("count", allCount);
  1076. jsonObject.put("count1", count);
  1077. jsonObject.put("count2", count1);
  1078. jsonObject.put("rank", rank);
  1079. return new Result(ResultCode.SUCCESS, jsonObject);
  1080. }
  1081. @Override
  1082. public Result AllClean(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
  1083. String farmId = paramsMap.get("farmId");
  1084. String personType = paramsMap.get("personType");
  1085. String type = paramsMap.get("type");
  1086. if ("".equals(type) || null == type) {
  1087. type = "1";
  1088. }
  1089. List<CleanVo> pcrVos = null;
  1090. QueryWrapper<BillClean> queryWrapper = new QueryWrapper<>();
  1091. queryWrapper.eq("farm_id", farmId).in("bill_status", 1, 2);
  1092. if ("".equals(personType) || null == personType) {
  1093. } else {
  1094. queryWrapper.eq("vistit_type", personType);
  1095. }
  1096. if ("1".equals(type)) {
  1097. Date timesmorning = DataUill.getTimesmorning();
  1098. queryWrapper.ge("sub_date", timesmorning);
  1099. } else if ("2".equals(type)) {
  1100. Calendar calendar = Calendar.getInstance();
  1101. calendar.set(Calendar.DATE, calendar.get(Calendar.DATE) - 7);
  1102. queryWrapper.ge("sub_date", calendar.getTime());
  1103. } else if ("3".equals(type)) {
  1104. Date monthmorning = DataUill.getTimesMonthmorning();
  1105. queryWrapper.ge("sub_date", monthmorning);
  1106. }
  1107. pcrVos = billCleanMapper.listAll(queryWrapper);
  1108. for (CleanVo pcrVo : pcrVos) {
  1109. pcrVo.setAllCount(pcrVo.getPassCount() + pcrVo.getRefuseCount());
  1110. }
  1111. return new Result(ResultCode.SUCCESS, pcrVos);
  1112. }
  1113. @Override
  1114. public Result CleanSelect(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
  1115. String farmId = paramsMap.get("farmId");
  1116. String type = paramsMap.get("type");//来访类型
  1117. String startTime = paramsMap.get("startTime");
  1118. String endTime = paramsMap.get("endTime");
  1119. String pageNum = paramsMap.get("pageNum");
  1120. String pageSize = paramsMap.get("pageSize");
  1121. if ("".equals(pageNum) || null == pageNum) {
  1122. pageNum = "1";
  1123. }
  1124. if ("".equals(pageSize) || null == pageSize) {
  1125. pageSize = "10";
  1126. }
  1127. if ("".equals(startTime) || null == startTime) {
  1128. startTime = DataUill.getTimesmorning().toString();
  1129. endTime = LocalDateTime.now() + " 23:59:59";
  1130. }
  1131. QueryWrapper<BillClean> queryWrapper = new QueryWrapper<>();
  1132. queryWrapper.eq("farm_id", farmId);
  1133. queryWrapper.between("check_date", startTime, endTime);
  1134. if ("".equals(type) || null == type) {
  1135. } else {
  1136. queryWrapper.eq("vistit_type", type);
  1137. }
  1138. Page<BillClean> page = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
  1139. return new Result(ResultCode.SUCCESS, billCleanMapper.selectPage(page, queryWrapper));
  1140. }
  1141. @Override
  1142. public void printClean(HttpServletResponse httpServletRequest, Map<String, String> paramsMap) throws Exception {
  1143. String ids = paramsMap.get("ids");
  1144. String[] split = ids.split(",");
  1145. List<BillClean> list = new ArrayList<>();
  1146. for (String s : split) {
  1147. BillClean admission = billCleanMapper.selectById(s);
  1148. list.add(admission);
  1149. }
  1150. Print.printClean(list);
  1151. }
  1152. }