|
@@ -7,12 +7,14 @@ import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.huimv.farm.damsubsidy.common.token.TokenSign;
|
|
|
+import com.huimv.farm.damsubsidy.common.utils.EartagUtil;
|
|
|
import com.huimv.farm.damsubsidy.common.utils.Result;
|
|
|
import com.huimv.farm.damsubsidy.common.utils.ResultCode;
|
|
|
import com.huimv.farm.damsubsidy.common.utils.UploadImage;
|
|
|
import com.huimv.farm.damsubsidy.entity.BaseAnimal;
|
|
|
import com.huimv.farm.damsubsidy.entity.BillIsolated;
|
|
|
import com.huimv.farm.damsubsidy.entity.BillLandingInspection;
|
|
|
+import com.huimv.farm.damsubsidy.entity.EartagResult;
|
|
|
import com.huimv.farm.damsubsidy.mapper.BaseAnimalMapper;
|
|
|
import com.huimv.farm.damsubsidy.mapper.BillIsolatedMapper;
|
|
|
import com.huimv.farm.damsubsidy.mapper.BillLandingInspectionMapper;
|
|
@@ -56,7 +58,7 @@ public class BillIsolatedServiceImpl extends ServiceImpl<BillIsolatedMapper, Bil
|
|
|
private UploadImage uploadImage;
|
|
|
|
|
|
@Override
|
|
|
- @Transactional
|
|
|
+ @Transactional(rollbackFor = RuntimeException.class)
|
|
|
public synchronized Result addIsolation(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) throws ParseException {
|
|
|
String inspectionNum = paramsMap.get("inspectionNum");
|
|
|
String isolatedPosition = paramsMap.get("isolatedPosition");
|
|
@@ -90,120 +92,30 @@ public class BillIsolatedServiceImpl extends ServiceImpl<BillIsolatedMapper, Bil
|
|
|
billIsolated.setCreateTime(DateTime.now());
|
|
|
billIsolated.setCreateUser(TokenSign.getMemberIdByJwtToken(httpServletRequest));
|
|
|
|
|
|
-
|
|
|
BillLandingInspection billLandingInspection = landingInspectionMapper.selectOne(new QueryWrapper<BillLandingInspection>().eq("inspection_num", inspectionNum).ne("inspection_sch", 5));
|
|
|
String eartags = billLandingInspection.getEartags();
|
|
|
- eartags = eartags.replace(",",",");
|
|
|
- eartags = eartags.replace(", ",",");
|
|
|
- eartags = eartags.replace(", ",",");
|
|
|
- if (eartags.contains(",")){
|
|
|
- String[] eartag = eartags.split(",");
|
|
|
- for (String input : eartag) {
|
|
|
- if (input.contains("-")){
|
|
|
- String start = input.substring(0, input.indexOf("-"));
|
|
|
- if (start.length() != 15){
|
|
|
- return new Result(10001,"耳标号"+input+"格式错误需输入15位数字",false);
|
|
|
- }
|
|
|
- String end = input.substring(input.indexOf("-") + 1);
|
|
|
- if (end.length() != 3){
|
|
|
- return new Result(10001,"耳标号"+input+"格式错误,-后需输入3位数字",false);
|
|
|
- }
|
|
|
- String substring1 = input.substring(start.length() - end.length(), start.length());
|
|
|
- String substring = start.substring(0, start.length() - end.length());
|
|
|
- System.out.println(substring);
|
|
|
- List<String> eartagNos = new ArrayList<>();
|
|
|
- if (Integer.parseInt(substring1) >Integer.parseInt(end) ){
|
|
|
- return new Result(10001,"耳标号"+input+"格式错误,包含-号耳标号需递增",false);
|
|
|
- }
|
|
|
- for (int i = Integer.parseInt(substring1); i <= Integer.parseInt(end); i++){
|
|
|
- String earTag = getEndEartag(substring,i);
|
|
|
- eartagNos.add(earTag);
|
|
|
- }
|
|
|
- for (String eartagNo : eartagNos) {
|
|
|
- Integer num = baseAnimalMapper.selectCount(new QueryWrapper<BaseAnimal>().eq("earatg_no", eartagNo));
|
|
|
- if (num != 0){
|
|
|
- return new Result(10001,"耳标号"+eartagNo+"重复",false);
|
|
|
- }
|
|
|
- BaseAnimal baseAnimal = new BaseAnimal();
|
|
|
- baseAnimal.setEaratgNo(eartagNo);
|
|
|
- baseAnimal.setAnimalType(billLandingInspection.getAnimalType());
|
|
|
- baseAnimal.setInspectionNum(billLandingInspection.getInspectionNum());
|
|
|
- baseAnimal.setBelongToUser(billLandingInspection.getCreateUser());
|
|
|
- baseAnimal.setCreateUser(TokenSign.getMemberIdByJwtToken(httpServletRequest));
|
|
|
- baseAnimal.setCreateTime(new Date());
|
|
|
- baseAnimalMapper.insert(baseAnimal);
|
|
|
- }
|
|
|
- }else {
|
|
|
- if (input.length() != 15){
|
|
|
- return new Result(10001,"耳标号"+input+"格式错误需输入15位数字",false);
|
|
|
- }
|
|
|
- Integer num = baseAnimalMapper.selectCount(new QueryWrapper<BaseAnimal>().eq("earatg_no", input));
|
|
|
- if (num != 0){
|
|
|
- return new Result(10001,"耳标号"+input+"重复",false);
|
|
|
- }
|
|
|
- BaseAnimal baseAnimal = new BaseAnimal();
|
|
|
- baseAnimal.setEaratgNo(input);
|
|
|
- baseAnimal.setAnimalType(billLandingInspection.getAnimalType());
|
|
|
- baseAnimal.setInspectionNum(billLandingInspection.getInspectionNum());
|
|
|
- baseAnimal.setBelongToUser(billLandingInspection.getCreateUser());
|
|
|
- baseAnimal.setCreateUser(TokenSign.getMemberIdByJwtToken(httpServletRequest));
|
|
|
- baseAnimal.setCreateTime(new Date());
|
|
|
- baseAnimalMapper.insert(baseAnimal);
|
|
|
- }
|
|
|
- }
|
|
|
- }else {
|
|
|
- if (eartags.contains("-")){
|
|
|
- String start = eartags.substring(0, eartags.indexOf("-"));
|
|
|
- if (start.length() != 15){
|
|
|
- return new Result(10001,"耳标号"+eartags+"格式错误需输入15位数字",false);
|
|
|
- }
|
|
|
- String end = eartags.substring(eartags.indexOf("-") + 1);
|
|
|
- if (end.length() != 3){
|
|
|
- return new Result(10001,"耳标号"+eartags+"格式错误,-后需输入3位数字",false);
|
|
|
- }
|
|
|
- String substring1 = eartags.substring(start.length() - end.length(), start.length());
|
|
|
- String substring = start.substring(0, start.length() - end.length());
|
|
|
- System.out.println(substring);
|
|
|
- List<String> eartagNos = new ArrayList<>();
|
|
|
- if (Integer.parseInt(substring1) >Integer.parseInt(end)){
|
|
|
- return new Result(10001,"耳标号"+eartags+"格式错误,包含-号耳标号需递增",false);
|
|
|
- }
|
|
|
- for (int i = Integer.valueOf(substring1) ; i <= Integer.valueOf(end); i++){
|
|
|
- String earTag = getEndEartag(substring,i);
|
|
|
- eartagNos.add(earTag);
|
|
|
- }
|
|
|
- for (String number : eartagNos) {
|
|
|
- Integer num = baseAnimalMapper.selectCount(new QueryWrapper<BaseAnimal>().eq("earatg_no", number));
|
|
|
- if (num != 0){
|
|
|
- return new Result(10001,"耳标号"+number+"重复",false);
|
|
|
- }
|
|
|
- BaseAnimal baseAnimal = new BaseAnimal();
|
|
|
- baseAnimal.setEaratgNo(number);
|
|
|
- baseAnimal.setAnimalType(billLandingInspection.getAnimalType());
|
|
|
- baseAnimal.setInspectionNum(billLandingInspection.getInspectionNum());
|
|
|
- baseAnimal.setBelongToUser(billLandingInspection.getCreateUser());
|
|
|
- baseAnimal.setCreateUser(TokenSign.getMemberIdByJwtToken(httpServletRequest));
|
|
|
- baseAnimal.setCreateTime(new Date());
|
|
|
- baseAnimalMapper.insert(baseAnimal);
|
|
|
- }
|
|
|
- }else {
|
|
|
- if (eartags.length() != 15){
|
|
|
- return new Result(10001,"耳标号"+eartags+"格式错误需输入15位数字",false);
|
|
|
- }
|
|
|
- Integer num = baseAnimalMapper.selectCount(new QueryWrapper<BaseAnimal>().eq("earatg_no", eartags));
|
|
|
- if (num != 0){
|
|
|
- return new Result(10001,"耳标号"+eartags+"重复",false);
|
|
|
- }
|
|
|
- BaseAnimal baseAnimal = new BaseAnimal();
|
|
|
- baseAnimal.setEaratgNo(eartags);
|
|
|
- baseAnimal.setAnimalType(billLandingInspection.getAnimalType());
|
|
|
- baseAnimal.setInspectionNum(billLandingInspection.getInspectionNum());
|
|
|
- baseAnimal.setBelongToUser(billLandingInspection.getCreateUser());
|
|
|
- baseAnimal.setCreateUser(TokenSign.getMemberIdByJwtToken(httpServletRequest));
|
|
|
- baseAnimal.setCreateTime(new Date());
|
|
|
- baseAnimalMapper.insert(baseAnimal);
|
|
|
+ EartagResult eartagCollection = EartagUtil.getEartagCollection(eartags);
|
|
|
+ if (!eartagCollection.getSuccess()) {
|
|
|
+ return new Result(10001,eartagCollection.getMsg(),false);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<String> eartagList = eartagCollection.getEartagList();
|
|
|
+ for (String eartagNo : eartagList) {
|
|
|
+ Integer num = baseAnimalMapper.selectCount(new QueryWrapper<BaseAnimal>().eq("earatg_no", eartagNo));
|
|
|
+ if (num != 0){
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return new Result(10001,"耳标号"+eartagNo+"已存在",false);
|
|
|
}
|
|
|
+ BaseAnimal baseAnimal = new BaseAnimal();
|
|
|
+ baseAnimal.setEaratgNo(eartagNo);
|
|
|
+ baseAnimal.setAnimalType(billLandingInspection.getAnimalType());
|
|
|
+ baseAnimal.setInspectionNum(billLandingInspection.getInspectionNum());
|
|
|
+ baseAnimal.setBelongToUser(billLandingInspection.getCreateUser());
|
|
|
+ baseAnimal.setCreateUser(TokenSign.getMemberIdByJwtToken(httpServletRequest));
|
|
|
+ baseAnimal.setCreateTime(new Date());
|
|
|
+ baseAnimalMapper.insert(baseAnimal);
|
|
|
}
|
|
|
+
|
|
|
billLandingInspection.setInspectionSch(3);
|
|
|
billLandingInspection.setReviewed(TokenSign.getUserName(httpServletRequest));
|
|
|
billLandingInspection.setReviewedTime(DateTime.now());
|