|
@@ -5,21 +5,24 @@ import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.lang.UUID;
|
|
import cn.hutool.core.lang.UUID;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
-import com.baomidou.mybatisplus.extension.api.R;
|
|
|
|
|
|
+import com.huimv.farm.damsubsidy.common.exception.ExceptionEnum;
|
|
|
|
+import com.huimv.farm.damsubsidy.common.exception.MiException;
|
|
import com.huimv.farm.damsubsidy.common.token.TokenSign;
|
|
import com.huimv.farm.damsubsidy.common.token.TokenSign;
|
|
import com.huimv.farm.damsubsidy.common.utils.Result;
|
|
import com.huimv.farm.damsubsidy.common.utils.Result;
|
|
import com.huimv.farm.damsubsidy.common.utils.ResultCode;
|
|
import com.huimv.farm.damsubsidy.common.utils.ResultCode;
|
|
import com.huimv.farm.damsubsidy.common.utils.UploadImage;
|
|
import com.huimv.farm.damsubsidy.common.utils.UploadImage;
|
|
import com.huimv.farm.damsubsidy.entity.*;
|
|
import com.huimv.farm.damsubsidy.entity.*;
|
|
|
|
+import com.huimv.farm.damsubsidy.entity.Vo.BillBuyInfoVo;
|
|
|
|
+import com.huimv.farm.damsubsidy.entity.Vo.BillLandingInspection;
|
|
import com.huimv.farm.damsubsidy.mapper.BaseAnimalMapper;
|
|
import com.huimv.farm.damsubsidy.mapper.BaseAnimalMapper;
|
|
import com.huimv.farm.damsubsidy.mapper.BillBuyInfoMapper;
|
|
import com.huimv.farm.damsubsidy.mapper.BillBuyInfoMapper;
|
|
import com.huimv.farm.damsubsidy.mapper.BillLandingInspectionMapper;
|
|
import com.huimv.farm.damsubsidy.mapper.BillLandingInspectionMapper;
|
|
import com.huimv.farm.damsubsidy.mapper.SysUserMapper;
|
|
import com.huimv.farm.damsubsidy.mapper.SysUserMapper;
|
|
import com.huimv.farm.damsubsidy.service.IBillBuyInfoService;
|
|
import com.huimv.farm.damsubsidy.service.IBillBuyInfoService;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
-import jdk.nashorn.internal.parser.Token;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
import org.springframework.util.StringUtils;
|
|
import org.springframework.util.StringUtils;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
@@ -27,6 +30,7 @@ import javax.annotation.Resource;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import java.io.BufferedInputStream;
|
|
import java.io.BufferedInputStream;
|
|
import java.io.ByteArrayOutputStream;
|
|
import java.io.ByteArrayOutputStream;
|
|
|
|
+import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.io.InputStream;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
@@ -53,81 +57,13 @@ public class BillBuyInfoServiceImpl extends ServiceImpl<BillBuyInfoMapper, BillB
|
|
private BillLandingInspectionMapper billLandingInspectionMapper;
|
|
private BillLandingInspectionMapper billLandingInspectionMapper;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- @Transactional
|
|
|
|
- public Result addTransaction(HttpServletRequest httpServletRequest, MultipartFile image1, MultipartFile image2, MultipartFile image3, String inspectionNum, String seller, String buyer, String num, String eartags,String buyerPhone) {
|
|
|
|
- String imgname = "成功";
|
|
|
|
- String originalFilename = image1.getOriginalFilename();
|
|
|
|
- String filenameExtension = StringUtils.getFilenameExtension(originalFilename);
|
|
|
|
- String path = DateUtil.format(new Date(),"yyyy-MM");
|
|
|
|
- try {
|
|
|
|
- InputStream inputStream = image1.getInputStream();
|
|
|
|
- BufferedInputStream in = new BufferedInputStream(inputStream);
|
|
|
|
- ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
|
|
|
|
-
|
|
|
|
- byte[] temp = new byte[1024];
|
|
|
|
- int size = 0;
|
|
|
|
- while ((size = in.read(temp)) != -1) {
|
|
|
|
- out.write(temp, 0, size);
|
|
|
|
- }
|
|
|
|
- in.close();
|
|
|
|
- byte[] content = out.toByteArray();
|
|
|
|
- imgname = UUID.randomUUID()+"."+filenameExtension;
|
|
|
|
- UploadImage.sshSftp(content,path, imgname);
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
- String content = "https://img.ifarmcloud.com/images/"+path +"/"+imgname;
|
|
|
|
-
|
|
|
|
- String imgname2 = "成功";
|
|
|
|
- String originalFilename2 = image2.getOriginalFilename();
|
|
|
|
- String filenameExtension2 = StringUtils.getFilenameExtension(originalFilename2);
|
|
|
|
- String path2 = DateUtil.format(new Date(),"yyyy-MM");
|
|
|
|
- try {
|
|
|
|
- InputStream inputStream = image2.getInputStream();
|
|
|
|
- BufferedInputStream in = new BufferedInputStream(inputStream);
|
|
|
|
- ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
|
|
|
|
-
|
|
|
|
- byte[] temp = new byte[1024];
|
|
|
|
- int size = 0;
|
|
|
|
- while ((size = in.read(temp)) != -1) {
|
|
|
|
- out.write(temp, 0, size);
|
|
|
|
- }
|
|
|
|
- in.close();
|
|
|
|
- byte[] content2 = out.toByteArray();
|
|
|
|
- imgname2 = UUID.randomUUID()+"."+filenameExtension2;
|
|
|
|
- UploadImage.sshSftp(content2,path2, imgname2);
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
- String content2 = "https://img.ifarmcloud.com/images/"+path2 +"/"+imgname2;
|
|
|
|
-
|
|
|
|
- String imgname3 = "成功";
|
|
|
|
- String originalFilename3 = image3.getOriginalFilename();
|
|
|
|
- String filenameExtension3 = StringUtils.getFilenameExtension(originalFilename3);
|
|
|
|
- String path3 = DateUtil.format(new Date(),"yyyy-MM");
|
|
|
|
- try {
|
|
|
|
- InputStream inputStream = image3.getInputStream();
|
|
|
|
- BufferedInputStream in = new BufferedInputStream(inputStream);
|
|
|
|
- ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
|
|
|
|
-
|
|
|
|
- byte[] temp = new byte[1024];
|
|
|
|
- int size = 0;
|
|
|
|
- while ((size = in.read(temp)) != -1) {
|
|
|
|
- out.write(temp, 0, size);
|
|
|
|
- }
|
|
|
|
- in.close();
|
|
|
|
- byte[] content3 = out.toByteArray();
|
|
|
|
- imgname3 = UUID.randomUUID()+"."+filenameExtension3;
|
|
|
|
- UploadImage.sshSftp(content3,path3, imgname3);
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
- String content3 = "https://img.ifarmcloud.com/images/"+path3 +"/"+imgname3;
|
|
|
|
-
|
|
|
|
|
|
+ @Transactional(rollbackFor = RuntimeException.class)
|
|
|
|
+ public Result addTransaction(HttpServletRequest httpServletRequest, MultipartFile image1, MultipartFile image2, MultipartFile image3, String inspectionNum, String seller, String buyer, String num, String eartags,String buyerPhone) throws IOException {
|
|
BillBuyInfo billBuyInfo1 = billBuyInfoMapper.selectOne(new QueryWrapper<BillBuyInfo>().eq("create_user", TokenSign.getMemberIdByJwtToken(httpServletRequest)).eq("bill_buy_status",1));
|
|
BillBuyInfo billBuyInfo1 = billBuyInfoMapper.selectOne(new QueryWrapper<BillBuyInfo>().eq("create_user", TokenSign.getMemberIdByJwtToken(httpServletRequest)).eq("bill_buy_status",1));
|
|
SysUser sysUser = sysUserMapper.selectOne(new QueryWrapper<SysUser>().eq("phone", buyerPhone));
|
|
SysUser sysUser = sysUserMapper.selectOne(new QueryWrapper<SysUser>().eq("phone", buyerPhone));
|
|
BillLandingInspection billLandingInspection = billLandingInspectionMapper.selectOne(new QueryWrapper<BillLandingInspection>().eq("inspection_num", inspectionNum));
|
|
BillLandingInspection billLandingInspection = billLandingInspectionMapper.selectOne(new QueryWrapper<BillLandingInspection>().eq("inspection_num", inspectionNum));
|
|
|
|
|
|
|
|
+ Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint();
|
|
int sum = 0;
|
|
int sum = 0;
|
|
int total = Integer.parseInt(num);
|
|
int total = Integer.parseInt(num);
|
|
|
|
|
|
@@ -137,9 +73,9 @@ public class BillBuyInfoServiceImpl extends ServiceImpl<BillBuyInfoMapper, BillB
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (eartags.contains(",")){
|
|
if (eartags.contains(",")){
|
|
- eartags.replace(",",",");
|
|
|
|
- eartags.replace(", ",",");
|
|
|
|
- eartags.replace(", ",",");
|
|
|
|
|
|
+ eartags = eartags.replace(",",",");
|
|
|
|
+ eartags = eartags.replace(", ",",");
|
|
|
|
+ eartags = eartags.replace(", ",",");
|
|
String[] eartag = eartags.split(",");
|
|
String[] eartag = eartags.split(",");
|
|
for (String input : eartag) {
|
|
for (String input : eartag) {
|
|
if (input.contains("-")){
|
|
if (input.contains("-")){
|
|
@@ -329,9 +265,16 @@ public class BillBuyInfoServiceImpl extends ServiceImpl<BillBuyInfoMapper, BillB
|
|
sum++;
|
|
sum++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
if (total != sum){
|
|
if (total != sum){
|
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
return new Result(10001,"实际耳标数量和填写数量不符!",false);
|
|
return new Result(10001,"实际耳标数量和填写数量不符!",false);
|
|
}
|
|
}
|
|
|
|
+ String content = UploadImage.getImageCom(image1);
|
|
|
|
+ String content2 = UploadImage.getImageCom(image2);
|
|
|
|
+ String content3 = UploadImage.getImageCom(image3);
|
|
|
|
+
|
|
|
|
+
|
|
if (ObjectUtil.isEmpty(billBuyInfo1)){
|
|
if (ObjectUtil.isEmpty(billBuyInfo1)){
|
|
BillBuyInfo billBuyInfo = new BillBuyInfo();
|
|
BillBuyInfo billBuyInfo = new BillBuyInfo();
|
|
billBuyInfo.setBuyName(seller+"和"+buyer+"的交易信息");
|
|
billBuyInfo.setBuyName(seller+"和"+buyer+"的交易信息");
|