Commit 14b8a1b4 authored by chenzhao's avatar chenzhao

存量合同2.0开发 接口补充

parent 02ff8d8b
......@@ -7,6 +7,7 @@
hhpf.owners_name ownersName,
hhpf.peasant_household_no peasantHouseholdNo,
hhpf.province,
hhpf.sequence_nbr as sequenceNbr,
hhpf.house_address houseAddress,
hhpf.basic_grid_capacity basicGridCapacity,
IFNULL(hfih.status,'待推送') status,
......
......@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
import com.yeejoin.amos.boot.biz.common.excel.ExcelUtil;
import com.yeejoin.amos.boot.module.hygf.api.entity.HistoryPeasantHousehold;
import org.apache.commons.lang3.StringUtils;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
......@@ -170,6 +171,7 @@ public class HistoryPeasantHouseholdController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "POST",value = "存量合同电站上传", notes = "存量合同电站上传")
@PostMapping(value = "/uploadData")
@Transactional
public void upload(MultipartFile multipartFile) throws Exception {
historyPeasantHouseholdServiceImpl.uploadData(multipartFile);
......
......@@ -11,6 +11,7 @@ import com.yeejoin.amos.boot.module.hygf.api.mapper.HistoryPeasantHouseholdMappe
import com.yeejoin.amos.boot.module.hygf.api.service.IHistoryPeasantHouseholdService;
import com.yeejoin.amos.boot.module.hygf.api.dto.HistoryPeasantHouseholdDto;
import com.yeejoin.amos.boot.module.hygf.api.util.BeanDtoUtils;
import com.yeejoin.amos.component.robot.BadRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
......@@ -48,7 +49,7 @@ public class HistoryPeasantHouseholdServiceImpl extends BaseService<HistoryPeasa
public List<HistoryPeasantHouseholdDto> queryForHistoryPeasantHouseholdList() {
return this.queryForList("" , false);
}
@Transactional
public void uploadData(MultipartFile multipartFile) throws Exception {
List<HistoryPeasantHouseholdDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, HistoryPeasantHouseholdDto.class, 1);
......@@ -56,6 +57,16 @@ public class HistoryPeasantHouseholdServiceImpl extends BaseService<HistoryPeasa
for (HistoryPeasantHouseholdDto dto : excelDtoList) {
HistoryPeasantHousehold convert = BeanDtoUtils.convert(dto, HistoryPeasantHousehold.class);
convert.setStatus("待上传");
LambdaQueryWrapper<HistoryPeasantHousehold> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(HistoryPeasantHousehold::getPeasantHouseholdNo,convert.getPeasantHouseholdNo());
List<HistoryPeasantHousehold> list1 = this.getBaseMapper().selectList(wrapper);
if (CollectionUtil.isNotEmpty(list1)){
throw new BadRequest(convert.getPeasantHouseholdNo()+ "编号重复");
}
list.add(convert);
}
this.saveBatch(list);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment