Commit 0a261b69 authored by leizhan's avatar leizhan

新增农户时,填充默认值。列表支持模糊查询。删除农户时,同步删除勘察信息

parent 6eea7db5
...@@ -3,7 +3,6 @@ package com.yeejoin.amos.boot.module.hygf.biz.controller; ...@@ -3,7 +3,6 @@ package com.yeejoin.amos.boot.module.hygf.biz.controller;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils; import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.hygf.api.dto.PeasantHouseholdDtoP;
import com.yeejoin.amos.boot.module.hygf.api.dto.SurveyInformationDto; import com.yeejoin.amos.boot.module.hygf.api.dto.SurveyInformationDto;
import com.yeejoin.amos.boot.module.hygf.biz.service.impl.SurveyInformationServiceImpl; import com.yeejoin.amos.boot.module.hygf.biz.service.impl.SurveyInformationServiceImpl;
import com.yeejoin.amos.component.feign.model.FeignClientResult; import com.yeejoin.amos.component.feign.model.FeignClientResult;
...@@ -18,8 +17,8 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -18,8 +17,8 @@ import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.boot.biz.common.controller.BaseController; import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Date;
import java.util.List; import java.util.List;
import com.yeejoin.amos.boot.module.hygf.biz.service.impl.PeasantHouseholdServiceImpl; import com.yeejoin.amos.boot.module.hygf.biz.service.impl.PeasantHouseholdServiceImpl;
import org.typroject.tyboot.core.restful.utils.ResponseHelper; import org.typroject.tyboot.core.restful.utils.ResponseHelper;
...@@ -63,20 +62,23 @@ public class PeasantHouseholdController extends BaseController { ...@@ -63,20 +62,23 @@ public class PeasantHouseholdController extends BaseController {
@PostMapping(value = "/save") @PostMapping(value = "/save")
@ApiOperation(httpMethod = "POST", value = "新增农户信息", notes = "新增农户信息") @ApiOperation(httpMethod = "POST", value = "新增农户信息", notes = "新增农户信息")
public ResponseModel<PeasantHouseholdDto> save(@RequestBody PeasantHouseholdDto model) { public ResponseModel<PeasantHouseholdDto> save(@RequestBody PeasantHouseholdDto model) {
AgencyUserModel userInfo = getUserInfo();
SurveyInformationDto surveyInformationDto = new SurveyInformationDto(); SurveyInformationDto surveyInformationDto = new SurveyInformationDto();
surveyInformationServiceImpl.createWithModel(surveyInformationDto); surveyInformationServiceImpl.createWithModel(surveyInformationDto);
JSONArray regionName = getRegionName(); JSONArray regionName = getRegionName();
List<RegionModel> list = JSONArray.parseArray(regionName.toJSONString(), RegionModel.class); List<RegionModel> list = JSONArray.parseArray(regionName.toJSONString(), RegionModel.class);
// 处理地址 if(StringUtils.isEmpty(model.getProjectAddressName())){
String area = ""; // 处理地址
for (Integer reg : model.getProjectAddress()) String area = "";
for (RegionModel re : list) { for (Integer reg : model.getProjectAddress())
if (re.getRegionCode().equals(Integer.valueOf(reg))) { for (RegionModel re : list) {
area = area + re.getRegionName() + "/"; if (re.getRegionCode().equals(Integer.valueOf(reg))) {
area = area + re.getRegionName() + "/";
}
} }
model.setProjectAddressName(area.substring(0, area.length() - 2)+"/"+model.getProjectAddressDetail());
} }
model.setProjectAddressName(area.substring(0, area.length() - 2)+"/"+model.getProjectAddressDetail());
if (model.getIsPermanent().size()>0) { if (model.getIsPermanent().size()>0) {
model.setPermanentAddress(model.getProjectAddress()); model.setPermanentAddress(model.getProjectAddress());
model.setPermanentAddressDetail(model.getProjectAddressDetail()); model.setPermanentAddressDetail(model.getProjectAddressDetail());
...@@ -84,6 +86,17 @@ public class PeasantHouseholdController extends BaseController { ...@@ -84,6 +86,17 @@ public class PeasantHouseholdController extends BaseController {
model.setSurveyInformationId(surveyInformationDto.getSequenceNbr()); model.setSurveyInformationId(surveyInformationDto.getSequenceNbr());
model.setSurveyOrNot(0); model.setSurveyOrNot(0);
model.setReview(0); model.setReview(0);
if(StringUtils.isEmpty(model.getDeveloperCode())){
model.setDeveloperCode(userInfo.getAgencyCode());
}
model.setDeveloperName(userInfo.getOrgNamesWithoutRole());
if(StringUtils.isEmpty(model.getDeveloper())){
model.setDeveloper(userInfo.getRealName());
}
if(StringUtils.isEmpty((CharSequence) model.getCreationTime())){
model.setCreationTime(new Date());
}
PeasantHouseholdDto householdDto = peasantHouseholdServiceImpl.createWithModel(model); PeasantHouseholdDto householdDto = peasantHouseholdServiceImpl.createWithModel(model);
return ResponseHelper.buildResponse(householdDto); return ResponseHelper.buildResponse(householdDto);
} }
...@@ -101,15 +114,17 @@ public class PeasantHouseholdController extends BaseController { ...@@ -101,15 +114,17 @@ public class PeasantHouseholdController extends BaseController {
model.setSequenceNbr(sequenceNbr); model.setSequenceNbr(sequenceNbr);
JSONArray regionName = getRegionName(); JSONArray regionName = getRegionName();
List<RegionModel> list = JSONArray.parseArray(regionName.toJSONString(), RegionModel.class); List<RegionModel> list = JSONArray.parseArray(regionName.toJSONString(), RegionModel.class);
// 处理地址 if(StringUtils.isEmpty(model.getProjectAddressName())){
String area = ""; // 处理地址
for (Integer reg : model.getProjectAddress()) String area = "";
for (RegionModel re : list) { for (Integer reg : model.getProjectAddress())
if (re.getRegionCode().equals(Integer.valueOf(reg))) { for (RegionModel re : list) {
area = area + re.getRegionName() + "/"; if (re.getRegionCode().equals(Integer.valueOf(reg))) {
area = area + re.getRegionName() + "/";
}
} }
} model.setProjectAddressName(area.substring(0, area.length() - 2)+"/"+model.getProjectAddressDetail());
model.setProjectAddressName(area.substring(0, area.length() - 2)+"/"+model.getProjectAddressDetail()); }
if (model.getIsPermanent().size()>0) { if (model.getIsPermanent().size()>0) {
model.setPermanentAddress(model.getProjectAddress()); model.setPermanentAddress(model.getProjectAddress());
model.setPermanentAddressDetail(model.getProjectAddressDetail()); model.setPermanentAddressDetail(model.getProjectAddressDetail());
...@@ -127,7 +142,7 @@ public class PeasantHouseholdController extends BaseController { ...@@ -127,7 +142,7 @@ public class PeasantHouseholdController extends BaseController {
@DeleteMapping(value = "/{sequenceNbr}") @DeleteMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "DELETE", value = "根据sequenceNbr删除农户信息", notes = "根据sequenceNbr删除农户信息") @ApiOperation(httpMethod = "DELETE", value = "根据sequenceNbr删除农户信息", notes = "根据sequenceNbr删除农户信息")
public ResponseModel<Boolean> deleteBySequenceNbr(HttpServletRequest request, @PathVariable(value = "sequenceNbr") Long sequenceNbr){ public ResponseModel<Boolean> deleteBySequenceNbr(HttpServletRequest request, @PathVariable(value = "sequenceNbr") Long sequenceNbr){
return ResponseHelper.buildResponse(peasantHouseholdServiceImpl.removeById(sequenceNbr)); return ResponseHelper.buildResponse(peasantHouseholdServiceImpl.deletePeasantHouseholdBySequenceNbr(sequenceNbr));
} }
/** /**
...@@ -158,13 +173,14 @@ public class PeasantHouseholdController extends BaseController { ...@@ -158,13 +173,14 @@ public class PeasantHouseholdController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/page") @GetMapping(value = "/page")
@ApiOperation(httpMethod = "GET",value = "农户信息分页查询", notes = "农户信息分页查询") @ApiOperation(httpMethod = "GET",value = "农户信息分页查询", notes = "农户信息分页查询")
public ResponseModel<Page<PeasantHouseholdDto>> queryForPage(@RequestParam(value = "current") int current,@RequestParam public ResponseModel<Page<PeasantHouseholdDto>> queryForPage(@RequestParam(value = "current") int current,
(value = "size") int size) { @RequestParam(value = "size") int size,
@RequestParam(value = "ownersName",required = false)String ownersName) {
Page<PeasantHouseholdDto> page = new Page<PeasantHouseholdDto>(); Page<PeasantHouseholdDto> page = new Page<PeasantHouseholdDto>();
page.setCurrent(current); page.setCurrent(current);
page.setSize(size); page.setSize(size);
AgencyUserModel userInfo = getUserInfo(); AgencyUserModel userInfo = getUserInfo();
return ResponseHelper.buildResponse(peasantHouseholdServiceImpl.queryForPeasantHouseholdPage(page,userInfo.getAgencyCode())); return ResponseHelper.buildResponse(peasantHouseholdServiceImpl.queryForPeasantHouseholdPage(page,userInfo.getAgencyCode(),ownersName));
} }
/** /**
......
...@@ -123,8 +123,9 @@ public class SurveyInformationController extends BaseController { ...@@ -123,8 +123,9 @@ public class SurveyInformationController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "POST",value = "勘察信息数据提交", notes = "勘察信息数据提交") @ApiOperation(httpMethod = "POST",value = "勘察信息数据提交", notes = "勘察信息数据提交")
@PostMapping(value = "/surveySubmit") @PostMapping(value = "/surveySubmit")
public ResponseModel<SurveyInfoAllDto> surveySubmit(@RequestBody SurveyInfoAllDto surveyInfoAllDto ) { public ResponseModel<SurveyInfoAllDto> surveySubmit(@RequestBody SurveyInfoAllDto surveyInfoAllDto,
SurveyInfoAllDto returnDto = surveyInformationServiceImpl.saveSurveyInfo(surveyInfoAllDto); @RequestParam(value = "operationType") String operationType) {
SurveyInfoAllDto returnDto = surveyInformationServiceImpl.saveSurveyInfo(surveyInfoAllDto,operationType);
return ResponseHelper.buildResponse(returnDto); return ResponseHelper.buildResponse(returnDto);
} }
......
package com.yeejoin.amos.boot.module.hygf.biz.service.impl; package com.yeejoin.amos.boot.module.hygf.biz.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.module.hygf.api.entity.Commercial;
import com.yeejoin.amos.boot.module.hygf.api.entity.ExtendedInformation;
import com.yeejoin.amos.boot.module.hygf.api.entity.Information;
import com.yeejoin.amos.boot.module.hygf.api.entity.PeasantHousehold; import com.yeejoin.amos.boot.module.hygf.api.entity.PeasantHousehold;
import com.yeejoin.amos.boot.module.hygf.api.entity.SurveyDetails;
import com.yeejoin.amos.boot.module.hygf.api.mapper.PeasantHouseholdMapper; import com.yeejoin.amos.boot.module.hygf.api.mapper.PeasantHouseholdMapper;
import com.yeejoin.amos.boot.module.hygf.api.service.IPeasantHouseholdService; import com.yeejoin.amos.boot.module.hygf.api.service.IPeasantHouseholdService;
import com.yeejoin.amos.boot.module.hygf.api.dto.PeasantHouseholdDto; import com.yeejoin.amos.boot.module.hygf.api.dto.PeasantHouseholdDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.typroject.tyboot.core.rdbms.annotation.Condition;
import org.typroject.tyboot.core.rdbms.annotation.Operator;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
...@@ -18,11 +26,52 @@ import java.util.stream.Collectors; ...@@ -18,11 +26,52 @@ import java.util.stream.Collectors;
*/ */
@Service @Service
public class PeasantHouseholdServiceImpl extends BaseService<PeasantHouseholdDto,PeasantHousehold,PeasantHouseholdMapper> implements IPeasantHouseholdService { public class PeasantHouseholdServiceImpl extends BaseService<PeasantHouseholdDto,PeasantHousehold,PeasantHouseholdMapper> implements IPeasantHouseholdService {
@Autowired
SurveyInformationServiceImpl surveyInformationService;
@Autowired
SurveyDetailsServiceImpl surveyDetailsService;
@Autowired
InformationServiceImpl informationService;
@Autowired
ExtendedInformationServiceImpl extendedInformationService;
@Autowired
CommercialServiceImpl commercialService;
public boolean deletePeasantHouseholdBySequenceNbr(Long sequenceNbr){
PeasantHouseholdDto peasantHouseholdDto = this.queryBySeq(sequenceNbr);
Long surveyInformationId = peasantHouseholdDto.getSurveyInformationId();
//删除勘察基本信息
surveyInformationService.deleteBySeq(surveyInformationId);
//删除扩展信息
QueryWrapper<ExtendedInformation> extendedInformationDeleteWrapper = new QueryWrapper<>();
extendedInformationDeleteWrapper.lambda().eq(ExtendedInformation::getSurveyInformationId,surveyInformationId);
extendedInformationService.getBaseMapper().delete(extendedInformationDeleteWrapper);
//删除勘察明细
QueryWrapper<SurveyDetails> surveyDetailsDeleteWrapper = new QueryWrapper<>();
surveyDetailsDeleteWrapper.lambda().eq(SurveyDetails::getSurveyInformationId,surveyInformationId);
surveyDetailsService.getBaseMapper().delete(surveyDetailsDeleteWrapper);
//删除商务信息
QueryWrapper<Commercial> commercialDeleteWrapper = new QueryWrapper<>();
commercialDeleteWrapper.lambda().eq(Commercial::getSurveyInformationId,surveyInformationId);
commercialService.getBaseMapper().delete(commercialDeleteWrapper);
//删除资料归档信息
QueryWrapper<Information> informationDeleteWrapper = new QueryWrapper<>();
informationDeleteWrapper.lambda().eq(Information::getSurveyInformationId,surveyInformationId);
informationService.getBaseMapper().delete(informationDeleteWrapper);
//删除农户信息
return this.deleteBySeq(sequenceNbr);
}
/** /**
* 分页查询 * 分页查询
*/ */
public Page<PeasantHouseholdDto> queryForPeasantHouseholdPage(Page<PeasantHouseholdDto> page,String developerCode) { public Page<PeasantHouseholdDto> queryForPeasantHouseholdPage(Page<PeasantHouseholdDto> page,String developerCode,@Condition(Operator.like) String ownersName) {
Page<PeasantHouseholdDto> peasantHouseholdDtoPage = this.queryForPage(page, null, false,developerCode); Page<PeasantHouseholdDto> peasantHouseholdDtoPage = this.queryForPage(page, null, false,developerCode,ownersName);
List<PeasantHouseholdDto> records = peasantHouseholdDtoPage.getRecords(); List<PeasantHouseholdDto> records = peasantHouseholdDtoPage.getRecords();
List<PeasantHouseholdDto> newRecords = records.stream().map(item -> { List<PeasantHouseholdDto> newRecords = records.stream().map(item -> {
if (item.getSurveyOrNot() == 0) { if (item.getSurveyOrNot() == 0) {
...@@ -30,7 +79,7 @@ public class PeasantHouseholdServiceImpl extends BaseService<PeasantHouseholdDto ...@@ -30,7 +79,7 @@ public class PeasantHouseholdServiceImpl extends BaseService<PeasantHouseholdDto
} else if (item.getSurveyOrNot() == 1) { } else if (item.getSurveyOrNot() == 1) {
item.setSurveyOrNotText("已勘察"); item.setSurveyOrNotText("已勘察");
} else if (item.getSurveyOrNot() == 2) { } else if (item.getSurveyOrNot() == 2) {
item.setSurveyOrNotText("提交审核"); item.setSurveyOrNotText("提交审核");
} }
return item; return item;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
......
...@@ -71,30 +71,65 @@ public class SurveyInformationServiceImpl extends BaseService<SurveyInformationD ...@@ -71,30 +71,65 @@ public class SurveyInformationServiceImpl extends BaseService<SurveyInformationD
} }
public SurveyInfoAllDto saveSurveyInfo(SurveyInfoAllDto surveyInfoAllDto) { public SurveyInfoAllDto saveSurveyInfo(SurveyInfoAllDto surveyInfoAllDto,String operationType) {
//更新勘察基本信息
SurveyInformation surveyInformation = BeanDtoUtils.convert(surveyInfoAllDto.getSurveyInformation(), SurveyInformation.class); SurveyInformation surveyInformation = BeanDtoUtils.convert(surveyInfoAllDto.getSurveyInformation(), SurveyInformation.class);
surveyInformation.setReview(0); surveyInformation.setReview(0);
this.saveOrUpdate(surveyInformation); this.saveOrUpdate(surveyInformation);
//更新扩展信息
ExtendedInformation extendedInformation = BeanDtoUtils.convert(surveyInfoAllDto.getExtendedInformation(), ExtendedInformation.class); ExtendedInformation extendedInformation = BeanDtoUtils.convert(surveyInfoAllDto.getExtendedInformation(), ExtendedInformation.class);
extendedInformation.setSurveyInformationId(surveyInformation.getSequenceNbr()); extendedInformation.setSurveyInformationId(surveyInformation.getSequenceNbr());
extendedInformationService.saveOrUpdate(extendedInformation); extendedInformationService.saveOrUpdate(extendedInformation);
//更新勘察明细信息
SurveyDetailsDto oldSurveyDetails = surveyInfoAllDto.getSurveyDetails(); SurveyDetailsDto oldSurveyDetails = surveyInfoAllDto.getSurveyDetails();
SurveyDetails surveyDetails = BeanDtoUtils.convert(oldSurveyDetails, SurveyDetails.class); SurveyDetails surveyDetails = BeanDtoUtils.convert(oldSurveyDetails, SurveyDetails.class);
surveyDetails.setSurveyInformationId(surveyInformation.getSequenceNbr()); surveyDetails.setSurveyInformationId(surveyInformation.getSequenceNbr());
surveyDetailsService.saveOrUpdate(surveyDetails); surveyDetailsService.saveOrUpdate(surveyDetails);
//更新商务信息
CommercialDto oldCommercial = surveyInfoAllDto.getCommercial(); CommercialDto oldCommercial = surveyInfoAllDto.getCommercial();
Commercial commercial = BeanDtoUtils.convert(oldCommercial, Commercial.class); Commercial commercial = BeanDtoUtils.convert(oldCommercial, Commercial.class);
commercial.setSurveyInformationId(surveyInformation.getSequenceNbr()); commercial.setSurveyInformationId(surveyInformation.getSequenceNbr());
commercialService.saveOrUpdate(commercial); commercialService.saveOrUpdate(commercial);
//更新资料归档信息
Information information = BeanDtoUtils.convert(surveyInfoAllDto.getInformation(), Information.class); Information information = BeanDtoUtils.convert(surveyInfoAllDto.getInformation(), Information.class);
information.setSurveyInformationId(surveyInformation.getSequenceNbr()); information.setSurveyInformationId(surveyInformation.getSequenceNbr());
informationService.saveOrUpdate(information); informationService.saveOrUpdate(information);
//勘察后,更新状态
QueryWrapper<PeasantHousehold> peasantHouseholdQueryWrapper = new QueryWrapper<>();
peasantHouseholdQueryWrapper.eq("survey_information_id", surveyInformation.getSequenceNbr());
PeasantHousehold peasantHousehold = peasantHouseholdServiceImpl.getBaseMapper().selectOne(peasantHouseholdQueryWrapper);
if("submit".equals(operationType)){
peasantHousehold.setSurveyOrNot(1);
}else if("apply".equals(operationType)){
peasantHousehold.setSurveyOrNot(2);
peasantHousehold.setReview(1);
}
peasantHousehold.setOwnersName(surveyInfoAllDto.getSurveyInformation().getOwnersName());
peasantHousehold.setTelephone(surveyInfoAllDto.getSurveyInformation().getTelephone());
peasantHousehold.setIdCard(surveyInfoAllDto.getSurveyInformation().getIdCard());
peasantHousehold.setMailbox(surveyInfoAllDto.getSurveyInformation().getMailbox());
peasantHousehold.setProjectAddress(surveyInfoAllDto.getSurveyInformation().getProjectAddress());
peasantHousehold.setProjectAddressDetail(surveyInfoAllDto.getSurveyInformation().getProjectAddressDetail());
peasantHousehold.setPermanentAddress(surveyInfoAllDto.getSurveyInformation().getPermanentAddress());
peasantHousehold.setPermanentAddressDetail(surveyInfoAllDto.getSurveyInformation().getPermanentAddressDetail());
peasantHousehold.setPermanentAddressDetail(surveyInfoAllDto.getSurveyInformation().getPermanentAddressDetail());
JSONArray regionName = getRegionName();
List<RegionModel> list = JSONArray.parseArray(regionName.toJSONString(), RegionModel.class);
// 处理地址
String area = "";
for (Integer reg : surveyInfoAllDto.getSurveyInformation().getProjectAddress())
for (RegionModel re : list) {
if (re.getRegionCode().equals(Integer.valueOf(reg))) {
area = area + re.getRegionName() + "/";
}
}
peasantHousehold.setProjectAddressName(area.substring(0, area.length() - 2)+"/"+surveyInfoAllDto.getSurveyInformation().getProjectAddressDetail());
peasantHouseholdServiceImpl.saveOrUpdate(peasantHousehold);
return surveyInfoAllDto; return surveyInfoAllDto;
} }
......
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