|
@@ -6,6 +6,7 @@ import cn.hutool.core.io.FileUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.http.Header;
|
|
|
import cn.hutool.http.HttpRequest;
|
|
|
+import cn.hutool.http.HttpUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONException;
|
|
@@ -15,6 +16,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
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.fasterxml.jackson.core.JsonProcessingException;
|
|
|
import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.huimv.receive.common.token.TokenSign;
|
|
@@ -96,7 +98,12 @@ public class BillPersonnelAdmissionServiceImpl extends ServiceImpl<BillPersonnel
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public Result addAdmission(HttpServletRequest httpServletRequest, String admissionType, String vistitType, String userName, String phone, String workName, String papersType, String papersCode, MultipartFile imgUrl, String img, String vistitDate, String vistitReson, String destId, String destName, String farmId, String carNum, String source, String goods, String departureId, String departureName, MultipartFile picture1, MultipartFile picture2, MultipartFile picture3) throws IOException {
|
|
|
+ public Result addAdmission(HttpServletRequest httpServletRequest, String admissionType, String vistitType,
|
|
|
+ String userName, String phone, String workName, String papersType, String papersCode,
|
|
|
+ MultipartFile imgUrl, String img, String vistitDate, String vistitReson, String destId,
|
|
|
+ String destName, String farmId, String carNum, String source, String goods,
|
|
|
+ String departureId, String departureName, MultipartFile picture1, MultipartFile picture2,
|
|
|
+ MultipartFile picture3) throws IOException {
|
|
|
Integer userId = TokenSign.getMemberIdByJwtToken(httpServletRequest);
|
|
|
if (!PhoneNumberValidator.isValidPhoneNumber(phone)) {
|
|
|
return new Result(10001, "手机号格式错误!", false);
|
|
@@ -174,11 +181,12 @@ public class BillPersonnelAdmissionServiceImpl extends ServiceImpl<BillPersonnel
|
|
|
billPersonnelAdmission.setCarNum(carNum);
|
|
|
}
|
|
|
if (ObjectUtil.isNotEmpty(imgUrl)) {
|
|
|
- if (uploadImage.getImageCom(imgUrl).equals("上传失败")) {
|
|
|
+ String s = uploadImage.getImageCom(imgUrl);
|
|
|
+ if (s.equals("上传失败")) {
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
return new Result(10001, "图片上传失败", false);
|
|
|
}
|
|
|
- billPersonnelAdmission.setImgUrl(uploadImage.getImageCom(imgUrl));
|
|
|
+ billPersonnelAdmission.setImgUrl(s);
|
|
|
}
|
|
|
if (ObjectUtil.isNotEmpty(img)) {
|
|
|
billPersonnelAdmission.setImgUrl(img);
|
|
@@ -1265,6 +1273,204 @@ public class BillPersonnelAdmissionServiceImpl extends ServiceImpl<BillPersonnel
|
|
|
return new Result(10000, "修改成功", true);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Result helpAddAdmission(HttpServletRequest httpServletRequest,MultipartFile userImgUrl,String admissionType, String vistitType,
|
|
|
+ String userName, String phone, String workName, String papersType,
|
|
|
+ String papersCode, MultipartFile imgUrl, String img, String vistitDate,
|
|
|
+ String vistitReson, String destId, String destName, String farmId, String carNum,
|
|
|
+ String source, String goods, String departureId, String departureName,
|
|
|
+ MultipartFile picture1,MultipartFile picture2,MultipartFile picture3) throws IOException {
|
|
|
+ if (!PhoneNumberValidator.isValidPhoneNumber(phone)) {
|
|
|
+ return new Result(10001, "手机号格式错误!", false);
|
|
|
+ }
|
|
|
+ if (papersType.equals("0")) {
|
|
|
+ if (!IDCardValidator.isValidIDCard(papersCode)) {
|
|
|
+ return new Result(10001, "身份证号格式错误!", false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Integer userId = TokenSign.getMemberIdByJwtToken(httpServletRequest);
|
|
|
+ SysAccountMultilevel sysAccountMultilevel1;
|
|
|
+ //先进行账号注册
|
|
|
+ QueryWrapper<SysAccountMultilevel> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("type",7).and(i->i.eq("phone", phone).or().eq("papers_code", papersCode));
|
|
|
+ SysAccountMultilevel data = sysAccountMultilevelMapper.selectOne(queryWrapper);
|
|
|
+ if (ObjectUtil.isEmpty(data)) {
|
|
|
+ SysAccountMultilevel sysAccountMultilevel = new SysAccountMultilevel();
|
|
|
+ sysAccountMultilevel.setUserName(userName);
|
|
|
+ sysAccountMultilevel.setPapersCode(papersCode);
|
|
|
+ sysAccountMultilevel.setPhone(phone);
|
|
|
+ sysAccountMultilevel.setAccount(phone);
|
|
|
+ sysAccountMultilevel.setPid(0);
|
|
|
+ sysAccountMultilevel.setPids("0");
|
|
|
+ sysAccountMultilevel.setPassword("123456");
|
|
|
+ sysAccountMultilevel.setWorkName(workName);
|
|
|
+ sysAccountMultilevel.setAccountStatus(1);
|
|
|
+ sysAccountMultilevel.setFarmIds(farmId);
|
|
|
+ sysAccountMultilevel.setLastFarmId(Integer.parseInt(farmId));
|
|
|
+ sysAccountMultilevel.setPapersType(papersType);
|
|
|
+ sysAccountMultilevel.setType(7);
|
|
|
+ String imageCom = uploadImage.getImageCom(userImgUrl);
|
|
|
+ if ("上传失败".equals(imageCom)) {
|
|
|
+ return new Result(10001, "图片上传失败!", false);
|
|
|
+ }
|
|
|
+ sysAccountMultilevel.setImgUrl(imageCom);
|
|
|
+ sysAccountMultilevelMapper.insert(sysAccountMultilevel);
|
|
|
+ sysAccountMultilevel1 = sysAccountMultilevelMapper.selectOne(new QueryWrapper<SysAccountMultilevel>().eq("papers_code", papersCode));
|
|
|
+ } else {
|
|
|
+ sysAccountMultilevel1 = data;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ BaseWashoutPoint baseWashoutPoint1 = baseWashoutPointMapper.selectOne(new QueryWrapper<BaseWashoutPoint>().lambda().eq(BaseWashoutPoint::getLocationId, departureId).like(BaseWashoutPoint::getFarmIds, farmId).eq(BaseWashoutPoint::getVisitingType, vistitType));
|
|
|
+ BaseWashoutPoint baseWashoutPoint2 = baseWashoutPointMapper.selectOne(new QueryWrapper<BaseWashoutPoint>().lambda().eq(BaseWashoutPoint::getLocationId, destId).like(BaseWashoutPoint::getFarmIds, farmId).eq(BaseWashoutPoint::getVisitingType, vistitType));
|
|
|
+ if (!departureId.equals("0")){
|
|
|
+ if (baseWashoutPoint1.getPointLevel()>=baseWashoutPoint2.getPointLevel()){
|
|
|
+ return new Result(10001, "出发地应在目的地之前!", false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
|
|
|
+ BillPersonnelAdmission billPersonnelAdmission = new BillPersonnelAdmission();
|
|
|
+ billPersonnelAdmission.setAdmissionType(Integer.parseInt(admissionType));
|
|
|
+ billPersonnelAdmission.setVistitType(Integer.parseInt(vistitType));
|
|
|
+ billPersonnelAdmission.setDestId(Integer.parseInt(destId));
|
|
|
+ billPersonnelAdmission.setDestName(destName);
|
|
|
+ billPersonnelAdmission.setDepartureName(departureName);
|
|
|
+ billPersonnelAdmission.setDepartureId(Integer.valueOf(departureId));
|
|
|
+ billPersonnelAdmission.setAdmissionUserId(userId);
|
|
|
+ billPersonnelAdmission.setAdmissionUserName(userName);
|
|
|
+ billPersonnelAdmission.setVistitDate(LocalDateTime.parse(vistitDate, dateTimeFormatter));
|
|
|
+ billPersonnelAdmission.setSubDate(LocalDateTime.now());
|
|
|
+ billPersonnelAdmission.setPhone(phone);
|
|
|
+ billPersonnelAdmission.setWorkName(workName);
|
|
|
+ billPersonnelAdmission.setPapersType(Integer.parseInt(papersType));
|
|
|
+ billPersonnelAdmission.setPapersCode(papersCode);
|
|
|
+ billPersonnelAdmission.setUserImgUrl(sysAccountMultilevel1.getImgUrl());
|
|
|
+ billPersonnelAdmission.setPicUrl(picUrl);
|
|
|
+ if (ObjectUtil.isNotEmpty(carNum)) {
|
|
|
+ billPersonnelAdmission.setCarNum(carNum);
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(imgUrl)) {
|
|
|
+ String s = uploadImage.getImageCom(imgUrl);
|
|
|
+ if (s.equals("上传失败")) {
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return new Result(10001, "图片上传失败", false);
|
|
|
+ }
|
|
|
+ billPersonnelAdmission.setImgUrl(s);
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(img)) {
|
|
|
+ billPersonnelAdmission.setImgUrl(img);
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(source)) {
|
|
|
+ billPersonnelAdmission.setSource(source);
|
|
|
+ }
|
|
|
+ billPersonnelAdmission.setVistitReson(vistitReson);
|
|
|
+ billPersonnelAdmission.setFarmId(Integer.parseInt(farmId));
|
|
|
+ BaseProcess baseProcess = new BaseProcess();
|
|
|
+ baseProcess.setDestName(destName);
|
|
|
+ baseProcess.setDestId(Integer.parseInt(destId));
|
|
|
+ baseProcess.setAdmissionUserId(userId);
|
|
|
+ baseProcess.setAdmissionUserName(userName);
|
|
|
+ baseProcess.setSubDate(DateTime.now());
|
|
|
+ baseProcess.setCurrentStatus("0");
|
|
|
+
|
|
|
+ String allLocation = departureName;
|
|
|
+ String allLocationId = "0";
|
|
|
+ String allLocationStatus = "0";
|
|
|
+ String allFlowId = "";
|
|
|
+
|
|
|
+ List<BaseWashoutPoint> baseWashoutPoints = new ArrayList<>();
|
|
|
+ if (ObjectUtil.isEmpty(baseWashoutPoint1)){
|
|
|
+ System.out.println("出发地为场外");
|
|
|
+ baseWashoutPoints = baseWashoutPointMapper.selectList(new QueryWrapper<BaseWashoutPoint>().lambda().le(BaseWashoutPoint::getPointLevel,baseWashoutPoint2.getPointLevel()).eq(BaseWashoutPoint::getVisitingType, vistitType).like(BaseWashoutPoint::getFarmIds, farmId).orderByAsc(BaseWashoutPoint::getPointLevel));
|
|
|
+ }else {
|
|
|
+ System.out.println("出发地不为场外");
|
|
|
+ baseWashoutPoints = baseWashoutPointMapper.selectList(new QueryWrapper<BaseWashoutPoint>().lambda().gt(BaseWashoutPoint::getPointLevel,baseWashoutPoint1.getPointLevel()).le(BaseWashoutPoint::getPointLevel,baseWashoutPoint2.getPointLevel()).eq(BaseWashoutPoint::getVisitingType, vistitType).like(BaseWashoutPoint::getFarmIds, farmId).orderByAsc(BaseWashoutPoint::getPointLevel));
|
|
|
+ }
|
|
|
+ System.out.println("所有洗消点:"+baseWashoutPoints);
|
|
|
+ for (BaseWashoutPoint baseWashoutPoint : baseWashoutPoints) {
|
|
|
+ allLocation = allLocation + "," + baseLocationMapper.selectById(baseWashoutPoint.getLocationId()).getLocationName();
|
|
|
+ allLocationId = allLocationId + "," + baseWashoutPoint.getLocationId();
|
|
|
+ allLocationStatus = allLocationStatus + "," + "0";
|
|
|
+ allFlowId = allFlowId + "0," + baseWashoutPoint.getFlowList();
|
|
|
+
|
|
|
+ allLocation = allLocation + "," + baseWashoutPoint.getTailLocationName();
|
|
|
+ allLocationId = allLocationId + "," + "0";
|
|
|
+ allLocationStatus = allLocationStatus + "," + "0";
|
|
|
+ if (!baseWashoutPoint.equals(baseWashoutPoints.get(baseWashoutPoints.size() - 1))) {
|
|
|
+ allFlowId = allFlowId + ",";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(admissionType.equals("1")){
|
|
|
+ baseProcess.setAllLocation(departureName);
|
|
|
+ baseProcess.setAllLocationId("0");
|
|
|
+ baseProcess.setAllLocationStatus("0");
|
|
|
+ }else {
|
|
|
+ baseProcess.setAllLocation(allLocation);
|
|
|
+ baseProcess.setAllLocationId(allLocationId);
|
|
|
+ baseProcess.setAllLocationStatus(allLocationStatus);
|
|
|
+ }
|
|
|
+
|
|
|
+ baseProcess.setAllFlowId(allFlowId+",0");
|
|
|
+ baseProcess.setCurrentFlowId("0");
|
|
|
+ baseProcess.setCurrentLocation("场外");
|
|
|
+ baseProcess.setCurrentLocationId("0");
|
|
|
+ baseProcess.setFarmId(Integer.parseInt(farmId));
|
|
|
+ baseProcessMapper.insert(baseProcess);
|
|
|
+ billPersonnelAdmission.setProcessId(baseProcess.getId());
|
|
|
+ billPersonnelAdmissionMapper.insert(billPersonnelAdmission);
|
|
|
+ ArrayList<String> phoneList = new ArrayList<>();
|
|
|
+ List<SysAccountMultilevel> safe = sysAccountMultilevelMapper.selectList(new QueryWrapper<SysAccountMultilevel>().eq("farm_ids", farmId).eq("type", 3));
|
|
|
+ for (SysAccountMultilevel sysAccountMultilevel : safe) {
|
|
|
+ phoneList.add(sysAccountMultilevel.getPhone());
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(goods)) {
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ List<BillGoodsInventory> admissionAndGoods = objectMapper.readValue(goods, new TypeReference<List<BillGoodsInventory>>() {
|
|
|
+ });
|
|
|
+ for (BillGoodsInventory good : admissionAndGoods) {
|
|
|
+ good.setBillAdmission(billPersonnelAdmission.getId());
|
|
|
+ BaseLocation baseLocation1 = baseLocationMapper.selectById(destId);
|
|
|
+ good.setTestLocation(baseLocation1.getLocationName());
|
|
|
+ good.setTestLocationId(baseLocation1.getId());
|
|
|
+ good.setCreateDate(new Date());
|
|
|
+ good.setFarmId(farmId);
|
|
|
+ billGoodsInventoryMapper.insert(good);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return Result.SUCCESS();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
/*数组排序*/
|
|
|
public static JSONArray jsonArraySort(JSONArray jsonArr, String sortKey, boolean is_desc) {
|
|
|
//存放排序结果json数组
|