|
|
|
@ -2,6 +2,7 @@ package com.cjy.traceability.module.traceability.service.husbandryrecord; |
|
|
|
|
|
|
|
|
|
import cn.hutool.json.JSONArray; |
|
|
|
|
import cn.hutool.json.JSONObject; |
|
|
|
|
import com.cjy.traceability.module.traceability.dal.mysql.agriculturalused.AgriculturalUsedMapper; |
|
|
|
|
import jodd.util.StringUtil; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
@ -34,7 +35,8 @@ public class HusbandryRecordServiceImpl implements HusbandryRecordService { |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private HusbandryRecordMapper husbandryRecordMapper; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private AgriculturalUsedMapper agriculturalUsedMapper; |
|
|
|
|
@Override |
|
|
|
|
public Integer createHusbandryRecord(HusbandryRecordSaveReqVO createReqVO) { |
|
|
|
|
// 插入
|
|
|
|
@ -61,6 +63,18 @@ public class HusbandryRecordServiceImpl implements HusbandryRecordService { |
|
|
|
|
// 更新
|
|
|
|
|
HusbandryRecordDO updateObj = BeanUtils.toBean(updateReqVO, HusbandryRecordDO.class); |
|
|
|
|
husbandryRecordMapper.updateById(updateObj); |
|
|
|
|
// 删除已添加农资记录
|
|
|
|
|
agriculturalUsedMapper.deleteByHusbandryId(updateReqVO.getHusbandryId()); |
|
|
|
|
if (StringUtil.isNotBlank(updateReqVO.getAgriculturalJson())) { |
|
|
|
|
JSONArray jsonArray = new JSONArray(updateReqVO.getAgriculturalJson()); |
|
|
|
|
for (Object obj : jsonArray) { |
|
|
|
|
JSONObject jsonObject = new JSONObject(obj); |
|
|
|
|
jsonObject.put("creator", updateObj.getCreator()); |
|
|
|
|
jsonObject.put("updater", updateObj.getUpdater()); |
|
|
|
|
husbandryRecordMapper.insertAgriculturalUsed(updateReqVO.getHusbandryId(),jsonObject); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|