|
|
@@ -1,5 +1,7 @@
|
|
|
package com.yunfeiyun.agmp.fms.service.impl;
|
|
|
|
|
|
+import com.yunfeiyun.agmp.common.constant.ErrorCode;
|
|
|
+import com.yunfeiyun.agmp.common.exception.BizException;
|
|
|
import com.yunfeiyun.agmp.common.utils.SecurityUtils;
|
|
|
import com.yunfeiyun.agmp.common.utils.StringUtils;
|
|
|
import com.yunfeiyun.agmp.common.web.system.domain.SysRes;
|
|
|
@@ -9,6 +11,7 @@ import com.yunfeiyun.agmp.fms.domain.FmsPeriod;
|
|
|
import com.yunfeiyun.agmp.fms.mapper.FmsCropMapper;
|
|
|
import com.yunfeiyun.agmp.fms.mapper.FmsPeriodMapper;
|
|
|
import com.yunfeiyun.agmp.fms.domain.reqvo.AddPeriodListReqVo;
|
|
|
+import com.yunfeiyun.agmp.fms.service.IFmsCropService;
|
|
|
import com.yunfeiyun.agmp.fms.service.IFmsPeriodService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -35,6 +38,9 @@ public class FmsPeriodServiceImpl implements IFmsPeriodService
|
|
|
@Resource
|
|
|
private FmsCropMapper fmsCropMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IFmsCropService fmsCropService;
|
|
|
+
|
|
|
/**
|
|
|
* 查询作物周期
|
|
|
*
|
|
|
@@ -64,6 +70,7 @@ public class FmsPeriodServiceImpl implements IFmsPeriodService
|
|
|
*/
|
|
|
@Override
|
|
|
public List<FmsPeriod> selectFmsPeriodList(FmsPeriod fmsPeriod) {
|
|
|
+ fmsPeriod.setTid(SecurityUtils.getTid());
|
|
|
return fmsPeriodMapper.selectFmsPeriodList(fmsPeriod);
|
|
|
}
|
|
|
|
|
|
@@ -75,11 +82,13 @@ public class FmsPeriodServiceImpl implements IFmsPeriodService
|
|
|
*/
|
|
|
@Override
|
|
|
public int insertFmsPeriod(FmsPeriod fmsPeriod) {
|
|
|
- FmsCrop fmsCrop = fmsCropMapper.selectFmsCropByCropId(fmsPeriod.getCropId(),SecurityUtils.getTid());
|
|
|
- fmsPeriod.setPeriodId(fmsPeriod.getId());
|
|
|
- if(StringUtils.isEmpty(fmsPeriod.getTid())){
|
|
|
- fmsPeriod.setTid(fmsCrop.getTid());
|
|
|
+ String tid = SecurityUtils.getTid();
|
|
|
+ FmsCrop fmsCrop = fmsCropService.selectFmsCropByCropId(fmsPeriod.getCropId(),tid);
|
|
|
+ if(fmsCrop == null){
|
|
|
+ throw new BizException(ErrorCode.INVALID_PARAMETER.getCode(),"作物不存在,请先创建作物信息");
|
|
|
}
|
|
|
+ fmsPeriod.setPeriodId(fmsPeriod.getId());
|
|
|
+ fmsPeriod.setTid(tid);
|
|
|
return fmsPeriodMapper.insertFmsPeriod(fmsPeriod);
|
|
|
}
|
|
|
|
|
|
@@ -89,7 +98,7 @@ public class FmsPeriodServiceImpl implements IFmsPeriodService
|
|
|
|
|
|
//查询生命周期列表,删除过去的图片
|
|
|
List<FmsPeriod> fmsPeriods = fmsPeriodMapper.selectFmsPeriodByCropId(reqVo.getCropId(), SecurityUtils.getTid());
|
|
|
- FmsCrop fmsCrop = fmsCropMapper.selectFmsCropByCropId(reqVo.getCropId(),SecurityUtils.getTid());
|
|
|
+ FmsCrop fmsCrop = fmsCropService.selectFmsCropByCropId(reqVo.getCropId(),SecurityUtils.getTid());
|
|
|
List<SysRes> sysResList = new ArrayList<>();
|
|
|
String[] periodIds = new String[fmsPeriods.size()];
|
|
|
for (int i = 0; i < fmsPeriods.size(); i++) {
|
|
|
@@ -110,14 +119,14 @@ public class FmsPeriodServiceImpl implements IFmsPeriodService
|
|
|
//删除过去的生长周期,保存最新的
|
|
|
fmsPeriodMapper.deleteFmsPeriodByCropId(reqVo.getCropId(),SecurityUtils.getTid());
|
|
|
|
|
|
- if (reqVo.getList().size() > 0) {
|
|
|
+ if (!reqVo.getList().isEmpty()) {
|
|
|
for (int i = 0; i < reqVo.getList().size(); i++) {
|
|
|
FmsPeriod fmsPeriod = reqVo.getList().get(i);
|
|
|
fmsPeriod.setCropId(reqVo.getCropId());
|
|
|
fmsPeriod.setPeriodId(fmsPeriod.getId());
|
|
|
fmsPeriod.setPeriodSeq(i + "");
|
|
|
fmsPeriod.setTid(fmsCrop.getTid());
|
|
|
- fmsPeriodMapper.insertFmsPeriod(fmsPeriod);
|
|
|
+ insertFmsPeriod(fmsPeriod);
|
|
|
|
|
|
String resIdsStr = reqVo.getList().get(i).getResIds();
|
|
|
if (!StringUtils.isEmpty(resIdsStr)) {
|