12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007 |
- package com.huimv.receive.service.impl;
- import cn.hutool.core.util.ObjectUtil;
- import com.alibaba.fastjson.JSONObject;
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import com.baomidou.mybatisplus.core.toolkit.StringUtils;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
- import com.huimv.receive.common.token.TokenSign;
- import com.huimv.receive.common.utils.*;
- import com.huimv.receive.entity.*;
- import com.huimv.receive.entity.dto.PcrDto;
- import com.huimv.receive.entity.vo.PcrVo;
- import com.huimv.receive.entity.vo.PcrVo1;
- import com.huimv.receive.mapper.*;
- import com.huimv.receive.service.IBillPcrService;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import org.springframework.transaction.interceptor.TransactionAspectSupport;
- import org.springframework.web.multipart.MultipartFile;
- import javax.annotation.Resource;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import java.io.IOException;
- import java.text.DecimalFormat;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.time.LocalDateTime;
- import java.util.*;
- import java.util.concurrent.Executors;
- import java.util.concurrent.ScheduledExecutorService;
- import java.util.concurrent.TimeUnit;
- /**
- * <p>
- * pcr 表 服务实现类
- * </p>
- *
- * @author author
- * @since 2023-07-21
- */
- @Service
- public class BillPcrServiceImpl extends ServiceImpl<BillPcrMapper, BillPcr> implements IBillPcrService {
- @Resource
- private BillPcrMapper billPcrMapper;
- @Autowired
- private BillGoodsInventoryMapper inventoryMapper;
- @Override
- public Result listPersonalPcr(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
- String pageNo = paramsMap.get("pageNum");
- String pageSize = paramsMap.get("pageSize");
- String vistitType = paramsMap.get("vistitType");
- Page<BillPcr> page = new Page<>(Integer.parseInt(pageNo), Integer.parseInt(pageSize));
- 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"));
- QueryWrapper<BillPcr> queryWrapper = new QueryWrapper<>();
- queryWrapper.eq(StringUtils.isNotBlank(vistitType), "vistit_type", vistitType).eq("admission_user_id", TokenSign.getMemberIdByJwtToken(httpServletRequest)).orderByDesc("sub_date");
- return new Result(ResultCode.SUCCESS, billPcrPage, billPcrMapper.selectCount(queryWrapper));
- }
- @Override
- public Result pcrWhole(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
- String farmId = paramsMap.get("farmId");
- Date timesmorning = DataUill.getTimesmorning();
- QueryWrapper<BillPcr> queryWrapper = new QueryWrapper<>();
- queryWrapper.eq("farm_id", farmId).eq("bill_status", 1).ge("sub_date", timesmorning);//今日合格
- Integer count = billPcrMapper.selectCount(queryWrapper);
- QueryWrapper<BillPcr> queryWrapper1 = new QueryWrapper<>();
- queryWrapper1.eq("farm_id", farmId).eq("bill_status", 2).ge("sub_date", timesmorning);//今日异常
- Integer count1 = billPcrMapper.selectCount(queryWrapper1);
- QueryWrapper<BillPcr> queryWrapper2 = new QueryWrapper<>();
- queryWrapper2.eq("farm_id", farmId).eq("bill_status", 3).ge("sub_date", timesmorning);//今日失效
- Integer count2 = billPcrMapper.selectCount(queryWrapper2);
- PcrDto dto = new PcrDto();
- dto.setWholeCount(count + count1);
- dto.setPassCount(count);
- dto.setRefuseCount(count1);
- dto.setLoseCount(count2);
- return new Result(ResultCode.SUCCESS, dto);
- }
- @Override
- public Result listType(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
- String farmId = paramsMap.get("farmId");
- String type = paramsMap.get("type");
- if ("".equals(type) || null == type) {
- type = "1";
- }
- List<PcrVo> pcrVos = null;
- QueryWrapper<BillPcr> queryWrapper = new QueryWrapper<>();
- queryWrapper.eq("farm_id", farmId).in("bill_status", 1, 2);
- if ("1".equals(type)) {
- Date timesmorning = DataUill.getTimesmorning();
- queryWrapper.ge("sub_date", timesmorning);
- } else if ("2".equals(type)) {
- Calendar calendar = Calendar.getInstance();
- calendar.set(Calendar.DATE, calendar.get(Calendar.DATE) - 7);
- queryWrapper.ge("sub_date", calendar.getTime());
- } else if ("3".equals(type)) {
- Date monthmorning = DataUill.getTimesMonthmorning();
- queryWrapper.ge("sub_date", monthmorning);
- }
- pcrVos = billPcrMapper.listPcr(queryWrapper);
- for (PcrVo pcrVo : pcrVos) {
- if (pcrVo.getType().equals("0")) {
- pcrVo.setType("人员");
- } else if (pcrVo.getType().equals("1")) {
- pcrVo.setType("环保车");
- } else if (pcrVo.getType().equals("2")) {
- pcrVo.setType("拉猪车");
- } else if (pcrVo.getType().equals("3")) {
- pcrVo.setType("饲料车");
- } else if (pcrVo.getType().equals("4")) {
- pcrVo.setType("送猪车");
- } else if (pcrVo.getType().equals("5")) {
- pcrVo.setType("物资车");
- }
- }
- return new Result(ResultCode.SUCCESS, pcrVos);
- }
- @Override
- public Result listLocation(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
- String farmId = paramsMap.get("farmId");
- String type = paramsMap.get("type");
- if ("".equals(type) || null == type) {
- type = "1";
- }
- List<PcrVo> pcrVos = null;
- QueryWrapper<BillPcr> queryWrapper = new QueryWrapper<>();
- queryWrapper.eq("farm_id", farmId).in("bill_status", 1, 2);
- if ("1".equals(type)) {
- Date timesmorning = DataUill.getTimesmorning();
- queryWrapper.ge("sub_date", timesmorning);
- } else if ("2".equals(type)) {
- Calendar calendar = Calendar.getInstance();
- calendar.set(Calendar.DATE, calendar.get(Calendar.DATE) - 7);
- queryWrapper.ge("sub_date", calendar.getTime());
- } else if ("3".equals(type)) {
- Date monthmorning = DataUill.getTimesMonthmorning();
- queryWrapper.ge("sub_date", monthmorning);
- }
- pcrVos = billPcrMapper.listLocation(queryWrapper);
- return new Result(ResultCode.SUCCESS, pcrVos);
- }
- @Override
- public Result listAll(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
- String farmId = paramsMap.get("farmId");
- String personType = paramsMap.get("personType");
- String type = paramsMap.get("type");
- if ("".equals(type) || null == type) {
- type = "1";
- }
- List<PcrVo1> pcrVos = null;
- QueryWrapper<BillPcr> queryWrapper = new QueryWrapper<>();
- queryWrapper.eq("farm_id", farmId).in("bill_status", 1, 2);
- if ("".equals(personType) || null == personType) {
- } else {
- queryWrapper.eq("vistit_type", personType);
- }
- if ("1".equals(type)) {
- Date timesmorning = DataUill.getTimesmorning();
- queryWrapper.ge("sub_date", timesmorning);
- } else if ("2".equals(type)) {
- Calendar calendar = Calendar.getInstance();
- calendar.set(Calendar.DATE, calendar.get(Calendar.DATE) - 7);
- queryWrapper.ge("sub_date", calendar.getTime());
- } else if ("3".equals(type)) {
- Date monthmorning = DataUill.getTimesMonthmorning();
- queryWrapper.ge("sub_date", monthmorning);
- }
- pcrVos = billPcrMapper.listAll(queryWrapper);
- for (PcrVo1 pcrVo : pcrVos) {
- pcrVo.setAllCount(pcrVo.getPassCount() + pcrVo.getRefuseCount());
- }
- return new Result(ResultCode.SUCCESS, pcrVos);
- }
- @Override
- public Result selectList(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
- String farmId = paramsMap.get("farmId");
- String type = paramsMap.get("type");//来访类型
- String destId = paramsMap.get("destId");//目的地
- String startTime = paramsMap.get("startTime");
- String endTime = paramsMap.get("endTime");
- String pageNum = paramsMap.get("pageNum");
- String pageSize = paramsMap.get("pageSize");
- if ("".equals(pageNum) || null == pageNum) {
- pageNum = "1";
- }
- if ("".equals(pageSize) || null == pageSize) {
- pageSize = "10";
- }
- QueryWrapper<BillPcr> queryWrapper = new QueryWrapper<>();
- if (ObjectUtil.isNotEmpty(startTime)) {
- startTime = startTime + " 00:00:00";
- endTime = endTime + " 23:59:59";
- queryWrapper.between("check_date", startTime, endTime);
- }
- queryWrapper.lambda().orderByDesc(BillPcr::getId);
- queryWrapper.eq("farm_id", farmId).eq(StringUtils.isNotBlank(destId), "dest_id", destId).eq(StringUtils.isNotBlank(type), "vistit_type", type);
- Page<BillPcr> page = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
- return new Result(ResultCode.SUCCESS, billPcrMapper.selectPage(page, queryWrapper));
- }
- @Override
- public void printPcr(HttpServletResponse httpServletRequest, Map<String, String> paramsMap) throws Exception {
- String ids = paramsMap.get("ids");
- String[] split = ids.split(",");
- List<BillPcr> list = new ArrayList<>();
- for (String s : split) {
- BillPcr admission = billPcrMapper.selectById(s);
- list.add(admission);
- }
- Print.printPcr(list);
- }
- @Override
- public Result PcrList(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
- String farmId = paramsMap.get("farmId");
- QueryWrapper<BillPcr> queryWrapper = new QueryWrapper<>();
- if ("21".equals(farmId)) {
- queryWrapper.eq("farm_id", 26);
- } else {
- queryWrapper.eq("farm_id", farmId);
- }
- Integer integer = pcrMapper.selectCount(queryWrapper);//检测总数
- queryWrapper.in("bill_status", 1, 3);
- Integer integer1 = pcrMapper.selectCount(queryWrapper);//合格总数
- queryWrapper.orderByDesc("sub_date").last(" limit 10");
- DecimalFormat def = new DecimalFormat("0.00");
- String rank;
- if (integer == 0 || integer == null) {
- Double ranks = Double.valueOf("0.00");
- rank = ranks.toString();
- } else {
- Double ranks = (Double.valueOf(integer1.toString()) / Double.valueOf(integer.toString())) * 100;
- rank = def.format(ranks);
- }
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("allCount", integer);
- jsonObject.put("passCount", integer1);
- jsonObject.put("rank", rank);
- jsonObject.put("pcrList", pcrMapper.selectList(queryWrapper));
- return new Result(ResultCode.SUCCESS, jsonObject);
- }
- @Autowired
- private BillPcrMapper pcrMapper;
- @Autowired
- private BaseProcessMapper processMapper;
- @Autowired
- private BaseLocationMapper locationMapper;
- @Autowired
- private BillCleanMapper cleanMapper;
- @Autowired
- private BillGoodsInventoryMapper goodsInventoryMapper;
- @Autowired
- private ConfigurationMapper configurationMapper;
- @Autowired
- private UploadImage uploadImage;
- @Autowired
- private ExistMapper existMapper;
- @Autowired
- private DeviceListMapper deviceListMapper;
- @Autowired
- private PeopleListMapper peopleListMapper;
- @Autowired
- private BillPersonnelAdmissionMapper personnelAdmissionMapper;
- @Autowired
- private BaseWashoutPointMapper washoutPointMapper;
- @Autowired
- private BillDryMapper dryMapper;
- @Autowired
- private BillIsolateMapper isolateMapper;
- @Autowired
- private BillSamplingMapper samplingMapper;
- @Autowired
- private BillCleanBeforeMapper beforeMapper;
- @Override
- public Result list(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
- String farmId = paramsMap.get("farmId");
- String type = paramsMap.get("type");//展示类型
- String pageNum = paramsMap.get("pageNum");
- String pageSize = paramsMap.get("pageSize");
- if ("".equals(pageNum) || null == pageNum) {
- pageNum = "1";
- }
- if ("".equals(pageSize) || null == pageSize) {
- pageSize = "20";
- }
- Page<BillPcr> page = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
- String[] locationIds = TokenSign.getWorkIdByJwtToken(httpServletRequest).split(",");
- QueryWrapper<BillPcr> queryWrapper = new QueryWrapper<>();
- queryWrapper.in("test_location_id", locationIds).orderByDesc("sub_date");
- if ("0".equals(type)) {
- queryWrapper.in("bill_status", 0, 1, 2, 3, 4);
- }
- if ("1".equals(type)) {
- queryWrapper.eq("bill_status", 0);
- }
- if ("2".equals(type)) {
- queryWrapper.eq("bill_status", 1);
- }
- if ("3".equals(type)) {
- queryWrapper.in("bill_status", 2, 3);
- }
- QueryWrapper<BillPcr> queryWrapper2 = new QueryWrapper<>();
- queryWrapper2.in("test_location_id", locationIds).orderByDesc("sub_date");
- queryWrapper2.eq("bill_status", 0);
- return new Result(ResultCode.SUCCESS, pcrMapper.selectPage(page, queryWrapper), pcrMapper.selectCount(queryWrapper2));
- }
- @Override
- public Result listById(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
- String id = paramsMap.get("id");
- BillPcr billPcr = pcrMapper.selectById(id);
- return new Result(ResultCode.SUCCESS, billPcr);
- }
- @Override
- @Transactional
- public Result edit(HttpServletRequest httpServletRequest, String farmId, String id, String date, String result,
- MultipartFile img1, MultipartFile img2, MultipartFile img3, MultipartFile picture1, MultipartFile picture2, MultipartFile picture3) throws ParseException, IOException {
- //1为合格2为异常
- String s1 = "";
- String s2 = "";
- String s3 = "";
- if (ObjectUtil.isNotEmpty(img1)) {
- s1 = uploadImage.uploadImg(img1);
- if (s1.equals("上传失败")) {
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- return new Result(10001, "检测图片1上传失败", false);
- }
- }
- if (ObjectUtil.isNotEmpty(img2)) {
- String s = uploadImage.uploadImg(img2);
- s2 = "," + s;
- if (s.equals("上传失败")) {
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- return new Result(10001, "检测图片2上传失败", false);
- }
- }
- if (ObjectUtil.isNotEmpty(img3)) {
- String s = uploadImage.uploadImg(img3);
- s3 = "," + s;
- if (s.equals("上传失败")) {
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- return new Result(10001, "检测图片3上传失败", false);
- }
- }
- String s = s1 + s2 + s3;
- String picUrl = null;
- if (ObjectUtil.isNotEmpty(picture1)){
- String pic1 = uploadImage.getImageCom(picture1);
- if (pic1.equals("上传失败")){
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- return new Result(10001, "物品检测图片1上传失败", false);
- }else {
- picUrl = pic1;
- }
- }
- if (ObjectUtil.isNotEmpty(picture2)){
- String pic2 = uploadImage.getImageCom(picture2);
- if (pic2.equals("上传失败")){
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- return new Result(10001, "物品检测图片2上传失败", false);
- }else {
- picUrl = picUrl + ","+pic2;
- }
- }
- if (ObjectUtil.isNotEmpty(picture3)){
- String pic3 = uploadImage.getImageCom(picture3);
- if (pic3.equals("上传失败")){
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- return new Result(10001, "物品检测图片3上传失败", false);
- }else {
- picUrl = picUrl + ","+pic3;
- }
- }
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
- if (StringUtils.isBlank(date)) {
- date = sdf.format(new Date());
- }
- BillPcr billPcr = pcrMapper.selectById(id);
- if (billPcr.getBillStatus() != 0) {
- return new Result(10001, "此条记录已被他人修改,请退出刷新查看!", false);
- }
- billPcr.setImgUrl(s);
- billPcr.setImgStatus(1);
- if (billPcr.getVistitType() == 0){
- if (ObjectUtil.isNotEmpty(picUrl)){
- billPcr.setIsCarry(1);
- billPcr.setPicUrl(picUrl);
- }else {
- billPcr.setIsCarry(0);
- }
- }
- QueryWrapper<BaseProcess> processQueryWrapper = new QueryWrapper<>();
- processQueryWrapper.eq("farm_id", farmId).eq("id", billPcr.getProcessId());
- BaseProcess baseProcess = processMapper.selectOne(processQueryWrapper);//进程
- QueryWrapper<BaseLocation> locationQueryWrapper = new QueryWrapper<>();
- locationQueryWrapper.eq("id", billPcr.getTestLocationId());
- BaseLocation baseLocation = locationMapper.selectOne(locationQueryWrapper);//当前pcr检测所在的位置
- String allLocationId = baseProcess.getAllLocationId();//所有的位置id
- String allFlowId = baseProcess.getAllFlowId();//所有的流程id
- String currentFlowId = baseProcess.getCurrentFlowId();//当前已经完成的流程id
- String substring1 = allFlowId.substring(currentFlowId.length() + 1, allFlowId.length());
- String[] split = substring1.split(",");
- Integer nextId = Integer.parseInt(split[0]);
- if (billPcr.getBillStatus() != 0) {
- return new Result(10001, "该订单已通过,无需再次提交!", false);
- }
- if (baseProcess.getProcessType() == 2 || baseProcess.getProcessType() == 1) {
- return new Result(10001, "修改失败!该申请已提前结束或者被拒绝", false);
- } else {
- if ("1".equals(result)) {
- Integer pcrTime = washoutPointMapper.selectOne(new QueryWrapper<BaseWashoutPoint>().eq("farm_ids", farmId)
- .eq("visiting_type", billPcr.getVistitType()).eq("location_id", baseLocation.getId())).getPcrTime();
- System.out.println("pcr的下一个流程id:" + nextId);
- billPcr.setBillStatus(1);
- billPcr.setPassUserName(TokenSign.getUserNameByJwtToken(httpServletRequest));
- billPcr.setPassUserId(TokenSign.getMemberIdByJwtToken(httpServletRequest));
- billPcr.setTestLocation(baseLocation.getLocationName());
- billPcr.setTestLocationId(baseLocation.getId());
- billPcr.setCheckDate(sdf.parse(date));
- billPcr.setPassDate(sdf.parse(sdf.format(new Date())));
- billPcr.setQualifiedDate(pcrTime);
- Object newObject = getNewObject(nextId, billPcr.getDestName(), billPcr.getDestId(), billPcr.getAdmissionUserName(),
- billPcr.getAdmissionUserId(), billPcr.getVistitDate(), billPcr.getSubDate(),
- billPcr.getProcessId(), billPcr.getFarmId(), billPcr.getTestLocation(), billPcr.getTestLocationId(),
- billPcr.getVistitType(), billPcr.getPhone(), billPcr.getDepartureName(), billPcr.getDepartureId());
- System.out.println("这里是pcr通过的下一个流程id:" + nextId);
- if (nextId == 0) {
- if (split.length == 1) {
- baseProcess.setProcessType(1);
- String[] strings = allLocationId.split(",");
- String ss2 = "";
- for (int i = 0; i < strings.length; i++) {
- strings[i].replaceAll(strings[i], "2");
- if (i == strings.length - 1) {
- ss2 = ss2 + strings[i].replaceAll(strings[i], "2");
- } else {
- ss2 = strings[i].replaceAll(strings[i], "2") + "," + ss2;
- }
- }
- baseProcess.setAllLocationStatus(ss2);
- } else {
- String[] strings = allLocationId.split(",");
- Integer index = 0;
- for (int i = 0; i < strings.length; i++) {
- if ((baseLocation.getId().toString()).equals(strings[i])) {
- index = i;
- }
- }
- QueryWrapper<BaseLocation> queryWrapper = new QueryWrapper();
- queryWrapper.eq("id", strings[index + 2]);
- BaseLocation location = locationMapper.selectOne(queryWrapper);
- FlowUtil flowUtil = new FlowUtil();
- Object entity = flowUtil.getEntity(Integer.parseInt(split[1]), billPcr.getVistitType(), billPcr.getDestName()
- , billPcr.getDestId(), billPcr.getAdmissionUserId(), billPcr.getAdmissionUserName(), billPcr.getPhone(),
- billPcr.getVistitDate(), location.getId(), location.getLocationName(), Integer.parseInt(farmId)
- , baseProcess.getId(), billPcr.getDepartureName(), billPcr.getDepartureId());
- if (Integer.parseInt(split[1]) == 1) {
- //新增采样
- BillSampling billSampling = (BillSampling) entity;
- if (billPcr.getVistitType() != 0) {
- billSampling.setCarNum(billPcr.getCarNum());
- }
- if (billPcr.getVistitType() == 5) {
- billSampling.setResource(billPcr.getResource());
- billSampling.setFeedImgUrl(billPcr.getFeedImgUrl());
- billSampling.setRemark(billPcr.getRemark());
- }
- samplingMapper.insert(billSampling);
- } else if (Integer.parseInt(split[1]) == 2) {
- //新增pcr
- BillPcr billClean = (BillPcr) entity;
- if (billPcr.getVistitType() != 0) {
- billClean.setCarNum(billPcr.getCarNum());
- }
- if (billPcr.getVistitType() == 5) {
- billClean.setResource(billPcr.getResource());
- billClean.setFeedImgUrl(billPcr.getFeedImgUrl());
- billClean.setRemark(billPcr.getRemark());
- }
- pcrMapper.insert(billClean);
- } else if (Integer.parseInt(split[1]) == 3) {
- //新增洗澡
- BillClean billClean = (BillClean) entity;
- if (billPcr.getVistitType() != 0) {
- billClean.setCarNum(billPcr.getCarNum());
- }
- if (billPcr.getVistitType() == 5) {
- billClean.setResource(billPcr.getResource());
- billClean.setFeedImgUrl(billPcr.getFeedImgUrl());
- billClean.setRemark(billPcr.getRemark());
- }
- cleanMapper.insert(billClean);
- } else if (Integer.parseInt(split[1]) == 4) {
- //新增隔离
- BillIsolate pcr = (BillIsolate) entity;
- if (billPcr.getVistitType() != 0) {
- pcr.setCarNum(billPcr.getCarNum());
- }
- if (billPcr.getVistitType() == 5) {
- pcr.setResource(billPcr.getResource());
- pcr.setFeedImgUrl(billPcr.getFeedImgUrl());
- pcr.setRemark(billPcr.getRemark());
- }
- isolateMapper.insert(pcr);
- } else if (Integer.parseInt(split[1]) == 5) {
- BillDry billClean = (BillDry) entity;
- if (billPcr.getVistitType() != 0) {
- billClean.setCarNum(billPcr.getCarNum());
- }
- if (billPcr.getVistitType() == 5) {
- billClean.setResource(billPcr.getResource());
- billClean.setFeedImgUrl(billPcr.getFeedImgUrl());
- billClean.setRemark(billPcr.getRemark());
- }
- dryMapper.insert(billClean);
- //新增烘干
- } else if (Integer.parseInt(split[1]) == 6) {
- //新增洗澡前拍照
- BillCleanBefore before = (BillCleanBefore) entity;
- if (billPcr.getVistitType() != 0) {
- before.setCarNum(billPcr.getCarNum());
- }
- if (billPcr.getVistitType() == 5) {
- before.setResource(billPcr.getResource());
- before.setFeedImgUrl(billPcr.getFeedImgUrl());
- before.setRemark(billPcr.getRemark());
- }
- beforeMapper.insert(before);
- } else if (Integer.parseInt(split[1]) == 7) {
- //新增洗澡前拍照
- BillGoodsInventory before = (BillGoodsInventory) entity;
- if (billPcr.getVistitType() != 0) {
- before.setCarNum(billPcr.getCarNum());
- }
- if (billPcr.getVistitType() == 5) {
- before.setResource(billPcr.getResource());
- before.setFeedImgUrl(billPcr.getFeedImgUrl());
- before.setRemark(billPcr.getRemark());
- }
- inventoryMapper.insert(before);
- }
- baseProcess.setCurrentFlowId(baseProcess.getCurrentFlowId() + "," + nextId + "," + split[1]);
- Integer locationId = billPcr.getTestLocationId();
- String[] split2 = allLocationId.split(",");
- int a = 0;
- for (int i = 0; i < split2.length; i++) {
- if (locationId.toString().equals(split2[i])) {
- a = i + 1;
- }
- }
- int indexOf = 2 * (a - 2);//当前位置在所有流程位置中的下标
- String substring = baseProcess.getAllLocationStatus().substring(0, indexOf + 3);//截取已经过的位置状态
- String[] split1 = substring.split(",");
- String sb2 = "";
- for (int i = 0; i < split1.length; i++) {
- if (i == split1.length - 1) {
- sb2 = sb2 + split1[i].replaceAll(split1[i], "2");
- } else {
- sb2 = split1[i].replaceAll(split1[i], "2") + "," + sb2;
- }
- }
- sb2 = sb2 + baseProcess.getAllLocationStatus().substring(indexOf + 3);
- StringBuilder sb = new StringBuilder(sb2);
- sb.replace(indexOf + 4, indexOf + 5, "2");
- sb.replace(indexOf + 6, indexOf + 7, "1");
- baseProcess.setAllLocationStatus(sb.toString());
- }
- } else if (nextId == 1) {
- //新增采样
- BillSampling billSampling = (BillSampling) newObject;
- if (billPcr.getVistitType() != 0) {
- billSampling.setCarNum(billPcr.getCarNum());
- }
- if (billPcr.getVistitType() == 5) {
- billSampling.setResource(billPcr.getResource());
- billSampling.setFeedImgUrl(billPcr.getFeedImgUrl());
- billSampling.setRemark(billPcr.getRemark());
- }
- samplingMapper.insert(billSampling);
- baseProcess.setCurrentFlowId(baseProcess.getCurrentFlowId() + "," + nextId);
- } else if (nextId == 2) {
- //新增pcr
- BillPcr billClean = (BillPcr) newObject;
- if (billPcr.getVistitType() != 0) {
- billClean.setCarNum(billPcr.getCarNum());
- }
- if (billPcr.getVistitType() == 5) {
- billClean.setResource(billPcr.getResource());
- billClean.setFeedImgUrl(billPcr.getFeedImgUrl());
- billClean.setRemark(billPcr.getRemark());
- }
- pcrMapper.insert(billClean);
- baseProcess.setCurrentFlowId(baseProcess.getCurrentFlowId() + "," + nextId);
- } else if (nextId == 3) {
- //新增洗澡
- BillClean billClean = (BillClean) newObject;
- if (billPcr.getVistitType() != 0) {
- billClean.setCarNum(billPcr.getCarNum());
- }
- if (billPcr.getVistitType() == 5) {
- billClean.setResource(billPcr.getResource());
- billClean.setFeedImgUrl(billPcr.getFeedImgUrl());
- billClean.setRemark(billPcr.getRemark());
- }
- cleanMapper.insert(billClean);
- baseProcess.setCurrentFlowId(baseProcess.getCurrentFlowId() + "," + nextId);
- } else if (nextId == 4) {
- //新增隔离
- BillIsolate pcr = (BillIsolate) newObject;
- if (billPcr.getVistitType() != 0) {
- pcr.setCarNum(billPcr.getCarNum());
- }
- if (billPcr.getVistitType() == 5) {
- pcr.setResource(billPcr.getResource());
- pcr.setFeedImgUrl(billPcr.getFeedImgUrl());
- pcr.setRemark(billPcr.getRemark());
- }
- isolateMapper.insert(pcr);
- baseProcess.setCurrentFlowId(baseProcess.getCurrentFlowId() + "," + nextId);
- } else if (nextId == 5) {
- BillDry billClean = (BillDry) newObject;
- if (billPcr.getVistitType() != 0) {
- billClean.setCarNum(billPcr.getCarNum());
- }
- if (billPcr.getVistitType() == 5) {
- billClean.setResource(billPcr.getResource());
- billClean.setFeedImgUrl(billPcr.getFeedImgUrl());
- billClean.setRemark(billPcr.getRemark());
- }
- dryMapper.insert(billClean);
- baseProcess.setCurrentFlowId(baseProcess.getCurrentFlowId() + "," + nextId);
- //新增烘干
- } else if (nextId == 6) {
- //新增洗澡前拍照
- BillCleanBefore before = (BillCleanBefore) newObject;
- if (billPcr.getVistitType() != 0) {
- before.setCarNum(billPcr.getCarNum());
- }
- if (billPcr.getVistitType() == 5) {
- before.setResource(billPcr.getResource());
- before.setFeedImgUrl(billPcr.getFeedImgUrl());
- before.setRemark(billPcr.getRemark());
- }
- beforeMapper.insert(before);
- baseProcess.setCurrentFlowId(baseProcess.getCurrentFlowId() + "," + nextId);
- } else if (nextId == 7) {
- //新增洗澡前拍照
- BillGoodsInventory before = (BillGoodsInventory) newObject;
- if (billPcr.getVistitType() != 0) {
- before.setCarNum(billPcr.getCarNum());
- }
- if (billPcr.getVistitType() == 5) {
- before.setResource(billPcr.getResource());
- before.setFeedImgUrl(billPcr.getFeedImgUrl());
- before.setRemark(billPcr.getRemark());
- }
- inventoryMapper.insert(before);
- baseProcess.setCurrentFlowId(baseProcess.getCurrentFlowId() + "," + nextId);
- }
- // //通过生成门禁白名单
- // QueryWrapper<DeviceList> deviceListQueryWrapper = new QueryWrapper<>();
- // deviceListQueryWrapper.eq("farm_id", billPcr.getFarmId()).eq("location_id", baseLocation.getId());
- // List<DeviceList> deviceLists = deviceListMapper.selectList(deviceListQueryWrapper);
- // //找到对应的入场申请表
- // QueryWrapper<BillPersonnelAdmission> queryWrapper1 = new QueryWrapper<>();
- // queryWrapper1.eq("farm_id", billPcr.getFarmId()).eq("process_id", baseProcess.getId());
- // BillPersonnelAdmission billPersonnelAdmission = personnelAdmissionMapper.selectOne(queryWrapper1);
- // if (deviceLists.size() > 0) {
- // for (DeviceList deviceList : deviceLists) {
- // //通过生成门禁白名单
- // PeopleList peopleList = new PeopleList();
- // peopleList.setFarmId(billPcr.getFarmId().toString());
- // peopleList.setDeviceCode(deviceList.getDeviceCode());
- // peopleList.setUserId(billPcr.getAdmissionUserId());
- // peopleList.setUserName(billPcr.getAdmissionUserName());
- // peopleList.setPassword("123456");
- // peopleList.setType(0);
- // peopleList.setCreateTime(new Date());
- // Date date2 = new Date();
- // Calendar calendar = Calendar.getInstance();
- // calendar.setTime(date2);
- // calendar.add(Calendar.HOUR_OF_DAY, 2);
- // Date date1 = calendar.getTime();
- // peopleList.setOutTime(date1);
- // peopleListMapper.insert(peopleList);
- //
- // HashMap<String, Object> jsonObject = new HashMap<>();
- // jsonObject.put("seq", deviceList.getDeviceCode());
- //// String savePath = "D:\\works\\pig_projects\\甜妹.jpg";
- // String savePath = "/opt/huatong/test.jpg";
- // URL url = new URL(billPersonnelAdmission.getUserImgUrl());
- // HttpURLConnection connection = (HttpURLConnection) url.openConnection();
- // connection.setRequestMethod("GET");
- // int resCode = connection.getResponseCode();
- // if (resCode == HttpURLConnection.HTTP_OK) {
- // InputStream inputStream = connection.getInputStream();
- // byte[] buffer = new byte[4096];
- // int length;
- // //读取数据并写入到文件中
- // try (FileOutputStream outStream = new FileOutputStream(savePath)) {
- // while ((length = inputStream.read(buffer)) != -1) {
- // outStream.write(buffer, 0, length);
- // }
- // outStream.flush();
- // } finally {
- // inputStream.close();
- // }
- // } else {
- // System.out.println("文件下载错误码为" + resCode);
- // }
- //
- //// jsonObject.put("face", FileUtil.file("D:\\works\\pig_projects\\甜妹.jpg"));
- // jsonObject.put("face", FileUtil.file(savePath));
- // jsonObject.put("name", billPersonnelAdmission.getAdmissionUserName());
- // jsonObject.put("password", "123456");
- // jsonObject.put("timestamp", date1.getTime());
- // jsonObject.put("uid", billPersonnelAdmission.getAdmissionUserId());
- // String post = HttpRequest.post("http://39.173.90.137:8040/addDeviceUser")
- // .header(Header.CONTENT_TYPE, "multipart/form-data")
- // .form(jsonObject)
- // .timeout(30 * 1000).execute().body();
- // System.out.println(post);
- // }
- // }
- baseProcess.setUpdateDate(baseProcess.getUpdateDate() + "," + sdf.format(new Date()));
- baseProcess.setCurrentLocation(baseProcess.getCurrentLocation() + "," + baseLocation.getLocationName());
- baseProcess.setCurrentLocationId(baseProcess.getCurrentLocationId() + "," + baseLocation.getId());
- String status = baseProcess.getCurrentStatus();
- String substring = status.substring(0, status.length() - 1);
- baseProcess.setCurrentStatus(substring + "1," + 0);
- processMapper.updateById(baseProcess);
- pcrMapper.updateById(billPcr);
- return new Result(10000, "修改成功!", true);
- } else {
- billPcr.setBillStatus(2);
- billPcr.setPcrType(1);
- billPcr.setPassUserName(TokenSign.getUserNameByJwtToken(httpServletRequest));
- billPcr.setPassUserId(TokenSign.getMemberIdByJwtToken(httpServletRequest));
- billPcr.setTestLocation(baseLocation.getLocationName());
- billPcr.setTestLocationId(baseLocation.getId());
- billPcr.setCheckDate(sdf.parse(date));
- billPcr.setPassDate(sdf.parse(sdf.format(new Date())));
- baseProcess.setUpdateDate(baseProcess.getUpdateDate() + "," + sdf.format(new Date()));
- String status = baseProcess.getCurrentStatus();
- String substring = status.substring(0, status.length() - 1);
- baseProcess.setCurrentStatus(substring + "2," + 0);
- processMapper.updateById(baseProcess);
- pcrMapper.updateById(billPcr);
- return new Result(10000, "修改成功!", true);
- }
- }
- }
- public static void main(String[] args) {
- String s = "0,1,0,2,0";
- String a = "0,1,0,2,0";
- String s1 = "1";
- int i = s.indexOf(s1);
- StringBuilder sb = new StringBuilder(a);
- sb.setCharAt(i, '3');
- System.out.println(sb);
- // String s3 = a.substring(0, s.indexOf(s1) + 3);
- //// System.out.println(s.indexOf(s1));
- // String[] split = s3.split(",");
- // String s2 = "";
- // for (int i = 0; i < split.length; i++) {
- //
- // }
- // System.out.println(s2);
- // s2 = s2 + s.substring(s.indexOf(s1) + 3);
- // System.out.println(s2);
- // String[] split = s.split(",");
- // Integer index = 0;
- // for (int i = 0; i < split.length; i++) {
- // if ("1".equals(split[i])) {
- // index = i;
- // }
- // }
- // System.out.println(index);
- // System.out.println(split[index + 2]);
- // StringBuilder sb = new StringBuilder(s);
- // Integer a = s.length() - 3;
- // sb.setCharAt(a,'0');
- // System.out.println(sb.toString());
- // String s1 = "2,0,0";
- // System.out.println(s1.indexOf("2"));
- // StringBuilder sb = new StringBuilder(s1);
- // sb.setCharAt(2, '1');
- // sb.setCharAt(4, '1');
- // System.out.println(sb.toString());
- }
- private void xiugaiPro(BaseProcess baseProcess, BillPcr billPcr) {
- baseProcess.setUpdateDate(baseProcess.getUpdateDate() + "," + new Date());
- baseProcess.setCurrentLocation(baseProcess.getCurrentLocation() + "," + billPcr.getTestLocation());
- baseProcess.setCurrentLocationId(baseProcess.getCurrentLocationId() + "," + billPcr.getTestLocationId());
- baseProcess.setCurrentStatus(baseProcess.getCurrentStatus() + "," + 2);
- }
- public String add() {
- ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(10);
- Runnable task = new Runnable() {
- @Override
- public void run() {
- //这里写业务
- System.out.println();
- }
- };
- // 设定延迟时间(两小时后执行,单位为秒)
- long delay = 3;
- // 执行定时任务
- scheduler.schedule(task, delay, TimeUnit.SECONDS);
- System.out.println("完结");
- return "成功";
- }
- public static Object getNewObject(Integer id, String destName, Integer destId, String admissionUserName, Integer admissionUserId
- , LocalDateTime vistitDate, LocalDateTime subDate, Integer processId, Integer farmId, String testLocation
- , Integer testLocationId, Integer vistitType, String phone, String departureName, Integer departureId) {
- if (id == 1) {
- //采样
- BillSampling billSampling = new BillSampling();
- billSampling.setVistitType(vistitType);
- billSampling.setDestName(destName);
- billSampling.setDestId(destId);
- billSampling.setAdmissionUserName(admissionUserName);
- billSampling.setAdmissionUserId(admissionUserId);
- billSampling.setVistitDate(vistitDate);
- billSampling.setSubDate(LocalDateTime.now());
- billSampling.setPhone(phone);
- billSampling.setTestLocation(testLocation);
- billSampling.setTestLocationId(testLocationId);
- billSampling.setProcessId(processId);
- billSampling.setFarmId(String.valueOf(farmId));
- billSampling.setDepartureName(departureName);
- billSampling.setDepartureId(departureId);
- return billSampling;
- }
- if (id == 2) {
- //pcr
- BillPcr billPcr = new BillPcr();
- billPcr.setVistitType(vistitType);
- billPcr.setDestName(destName);
- billPcr.setDestId(destId);
- billPcr.setAdmissionUserId(admissionUserId);
- billPcr.setAdmissionUserName(admissionUserName);
- billPcr.setVistitDate(vistitDate);
- billPcr.setSubDate(subDate);
- billPcr.setBillStatus(0);
- billPcr.setProcessId(processId);
- billPcr.setPhone(phone);
- billPcr.setFarmId(farmId);
- billPcr.setTestLocationId(testLocationId);
- billPcr.setTestLocation(testLocation);
- billPcr.setDepartureName(departureName);
- billPcr.setDepartureId(departureId);
- return billPcr;
- }
- if (id == 3) {
- //洗消
- BillClean billPcr = new BillClean();
- billPcr.setVistitType(vistitType);
- billPcr.setDestName(destName);
- billPcr.setDestId(destId);
- billPcr.setAdmissionUserId(admissionUserId);
- billPcr.setAdmissionUserName(admissionUserName);
- billPcr.setVistitDate(vistitDate);
- billPcr.setSubDate(subDate);
- billPcr.setBillStatus(0);
- billPcr.setProcessId(processId);
- billPcr.setPhone(phone);
- billPcr.setFarmId(farmId);
- billPcr.setTestLocationId(testLocationId);
- billPcr.setTestLocation(testLocation);
- billPcr.setDepartureName(departureName);
- billPcr.setDepartureId(departureId);
- return billPcr;
- }
- if (id == 4) {
- //隔离
- BillIsolate billPcr = new BillIsolate();
- billPcr.setVistitType(vistitType);
- billPcr.setDestName(destName);
- billPcr.setDestId(destId);
- billPcr.setAdmissionUserId(admissionUserId);
- billPcr.setAdmissionUserName(admissionUserName);
- billPcr.setVistitDate(vistitDate);
- billPcr.setSubDate(subDate);
- billPcr.setBillStatus(0);
- billPcr.setProcessId(processId);
- billPcr.setFarmId(farmId);
- billPcr.setPhone(phone);
- billPcr.setIsolateLocation(testLocation);
- billPcr.setIsolateLocationId(testLocationId);
- billPcr.setDepartureName(departureName);
- billPcr.setDepartureId(departureId);
- return billPcr;
- }
- if (id == 5) {
- //烘干
- BillDry billPcr = new BillDry();
- billPcr.setVistitType(vistitType);
- billPcr.setDestName(destName);
- billPcr.setDestId(destId);
- billPcr.setAdmissionUserId(admissionUserId);
- billPcr.setAdmissionUserName(admissionUserName);
- billPcr.setVistitDate(vistitDate);
- billPcr.setSubDate(subDate);
- billPcr.setBillStatus(0);
- billPcr.setProcessId(processId);
- billPcr.setFarmId(farmId);
- billPcr.setPhone(phone);
- billPcr.setTestLocationId(testLocationId);
- billPcr.setTestLocation(testLocation);
- billPcr.setDepartureName(departureName);
- billPcr.setDepartureId(departureId);
- return billPcr;
- }
- if (id == 6) {
- //洗澡前拍照
- BillCleanBefore billCleanBefore = new BillCleanBefore();
- billCleanBefore.setVistitType(vistitType);
- billCleanBefore.setVistitType(vistitType);
- billCleanBefore.setDestName(destName);
- billCleanBefore.setDestId(destId);
- billCleanBefore.setAdmissionUserName(admissionUserName);
- billCleanBefore.setAdmissionUserId(admissionUserId);
- billCleanBefore.setVistitDate(vistitDate);
- billCleanBefore.setSubDate(LocalDateTime.now());
- billCleanBefore.setPhone(phone);
- billCleanBefore.setTestLocation(testLocation);
- billCleanBefore.setTestLocationId(testLocationId);
- billCleanBefore.setProcessId(processId);
- billCleanBefore.setFarmId(String.valueOf(farmId));
- billCleanBefore.setDepartureName(departureName);
- billCleanBefore.setDepartureId(departureId);
- return billCleanBefore;
- }
- if (id == 7) {
- //洗澡前拍照
- BillGoodsInventory billCleanBefore = new BillGoodsInventory();
- billCleanBefore.setVistitType(vistitType);
- billCleanBefore.setVistitType(vistitType);
- billCleanBefore.setDestName(destName);
- billCleanBefore.setDestId(destId);
- billCleanBefore.setAdmissionUserName(admissionUserName);
- billCleanBefore.setAdmissionUserId(admissionUserId);
- billCleanBefore.setVistitDate(vistitDate);
- billCleanBefore.setSubDate(LocalDateTime.now());
- billCleanBefore.setPhone(phone);
- billCleanBefore.setTestLocation(testLocation);
- billCleanBefore.setTestLocationId(testLocationId);
- billCleanBefore.setBillAdmission(processId);
- billCleanBefore.setFarmId(String.valueOf(farmId));
- billCleanBefore.setDepartureName(departureName);
- billCleanBefore.setDepartureId(departureId);
- billCleanBefore.setProcessId(processId);
- return billCleanBefore;
- }
- return null;
- }
- }
|