Commit 32534ce5 authored by xixinzhao's avatar xixinzhao

feat(jg): 告知新增

parent cf8dffaa
package com.yeejoin.amos.boot.module.jg.api.dto;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
*
......@@ -76,9 +80,11 @@ public class JgInstallationNoticeDto extends BaseDto {
private String installLeaderPhone;
@ApiModelProperty(value = "安装开始日期")
@JsonFormat(pattern = "yyyy-MM-dd")
private Date installStartDate;
@ApiModelProperty(value = "安装竣工日期")
@JsonFormat(pattern = "yyyy-MM-dd")
private Date installEndDate;
@ApiModelProperty(value = "产权单位id")
......@@ -157,10 +163,16 @@ public class JgInstallationNoticeDto extends BaseDto {
private String inputUnitNo;
@ApiModelProperty(value = "安装委托书图片")
private String proxyStatementAttachment;
private List<Map<String, String>> proxyStatementAttachmentList;
@ApiModelProperty(value = "安装合同照片")
private String installContractAttachment;
private List<Map<String, String>> installContractAttachmentList;
@ApiModelProperty(value = "安装委托书图片")
private String proxyStatementAttachment;
@ApiModelProperty(value = "安装合同照片")
private String installContractAttachment;
@ApiModelProperty(value = "是否西咸")
private String isXixian;
......@@ -171,4 +183,18 @@ public class JgInstallationNoticeDto extends BaseDto {
@ApiModelProperty(value = "流程实例id")
private String instanceId;
@ApiModelProperty(value = "区名字")
private String countyName;
@ApiModelProperty(value = "市名字")
private String cityName;
@ApiModelProperty(value = "省名字")
private String provinceName;
@TableField(exist = false)
@ApiModelProperty(value = "告知设备列表")
private List<Map<String, Object>> deviceList;
}
......@@ -3,10 +3,14 @@ package com.yeejoin.amos.boot.module.jg.api.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import com.yeejoin.amos.boot.module.jg.api.dto.JgInstallationNoticeDto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
*
......@@ -83,18 +87,36 @@ public class JgInstallationNotice extends BaseEntity {
private String province;
/**
* 安装地点_省
*/
@TableField("province_name")
private String provinceName;
/**
* 安装地点_市
*/
@TableField("city")
private String city;
/**
* 安装地点_市
*/
@TableField("city_name")
private String cityName;
/**
* 设备使用地点_区(县)
*/
@TableField("county")
private String county;
/**
* 设备使用地点_区(县)
*/
@TableField("county_name")
private String countyName;
/**
* 安装地点_街道(镇)
*/
@TableField("street")
......
......@@ -40,4 +40,7 @@ public class JgRelationEquip extends BaseEntity {
@TableField("equip_id")
private String equipId;
@TableField(exist = false)
private String applyNo;
}
package com.yeejoin.amos.boot.module.jg.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import java.util.Collection;
import java.util.List;
/**
* @author DELL
*/
public interface CustomBaseMapper<T> extends BaseMapper<T> {
Integer insertBatchSomeColumn(List<T> entityList);
}
package com.yeejoin.amos.boot.module.jg.api.mapper;
import com.yeejoin.amos.boot.module.jg.api.dto.JgInstallationNoticeDto;
import com.yeejoin.amos.boot.module.jg.api.entity.JgInstallationNotice;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.Collection;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jg.api.dto.JgInstallationNoticeDto;
import com.yeejoin.amos.boot.module.jg.api.entity.JgInstallationNotice;
import org.apache.ibatis.annotations.Param;
/**
* Mapper 接口
* Mapper 接口
*
* @author system_generator
* @date 2023-12-12
*/
public interface JgInstallationNoticeMapper extends BaseMapper<JgInstallationNotice> {
public interface JgInstallationNoticeMapper extends CustomBaseMapper<JgInstallationNotice> {
Page<JgInstallationNotice> queryForPage(Page<JgInstallationNotice> page, @Param("param") JgInstallationNoticeDto model, @Param("type") String type);
}
......@@ -9,6 +9,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* @author system_generator
* @date 2023-12-12
*/
public interface JgRelationEquipMapper extends BaseMapper<JgRelationEquip> {
public interface JgRelationEquipMapper extends CustomBaseMapper<JgRelationEquip> {
}
package com.yeejoin.amos.boot.module.jg.api.service;
import com.yeejoin.amos.boot.module.jg.api.dto.JgInstallationNoticeDto;
/**
* 接口类
*
......@@ -9,4 +11,9 @@ package com.yeejoin.amos.boot.module.jg.api.service;
*/
public interface IJgInstallationNoticeService {
/**
* 保存安装告知单
* @param model
*/
void saveNotice(JgInstallationNoticeDto model);
}
package com.yeejoin.amos.boot.module.jg.biz.config;
import com.baomidou.mybatisplus.annotation.DbType;
import com.yeejoin.amos.boot.module.jg.biz.utils.SqlInjectorUtils;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.springframework.context.annotation.Primary;
@Configuration(value="MybatisPlusConfig")
public class MybatisPlusConfigs {
......@@ -17,4 +19,9 @@ public class MybatisPlusConfigs {
paginationInterceptor.setDialectType(DbType.POSTGRE_SQL.getDb());
return paginationInterceptor;
}
@Bean
public SqlInjectorUtils sqlInjectorUtils() {
return new SqlInjectorUtils();
}
}
package com.yeejoin.amos.boot.module.jg.biz.controller;
import com.yeejoin.amos.boot.module.jg.api.entity.JgInstallationNotice;
import org.springframework.web.bind.annotation.RequestMapping;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.jg.api.dto.JgInstallationNoticeDto;
......@@ -38,12 +43,12 @@ public class JgInstallationNoticeController extends BaseController {
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/save")
@ApiOperation(httpMethod = "POST", value = "新增安装告知", notes = "新增安装告知")
public ResponseModel<JgInstallationNoticeDto> save(@RequestBody JgInstallationNoticeDto model) {
model = jgInstallationNoticeServiceImpl.createWithModel(model);
return ResponseHelper.buildResponse(model);
}
@PostMapping(value = "/save")
@ApiOperation(httpMethod = "POST", value = "新增安装告知", notes = "新增安装告知")
public ResponseModel<JgInstallationNoticeDto> save(@RequestBody JgInstallationNoticeDto model) {
jgInstallationNoticeServiceImpl.saveNotice(model);
return ResponseHelper.buildResponse(model);
}
/**
* 根据sequenceNbr更新
......
package com.yeejoin.amos.boot.module.jg.biz.service.impl;
import com.yeejoin.amos.boot.module.jg.api.entity.JgInstallationNotice;
import com.yeejoin.amos.boot.module.jg.api.entity.JgRelationEquip;
import com.yeejoin.amos.boot.module.jg.api.enums.FlowStatusEnum;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgInstallationNoticeMapper;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgRelationEquipMapper;
import com.yeejoin.amos.boot.module.jg.api.service.IJgInstallationNoticeService;
import com.yeejoin.amos.boot.module.jg.api.dto.JgInstallationNoticeDto;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;
/**
* 服务实现类
......@@ -25,6 +29,10 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
@Autowired
private JgInstallationNoticeMapper jgInstallationNoticeMapper;
@Autowired
JgRelationEquipMapper jgRelationEquipMapper;
/**
* 分页查询
*/
......@@ -54,4 +62,121 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
public List<JgInstallationNoticeDto> queryForJgInstallationNoticeList() {
return this.queryForList("", false);
}
@Override
public void saveNotice(JgInstallationNoticeDto model) {
// 字段转换
convertField(model);
// 获取告知设备列表
List<Map<String, Object>> deviceList = model.getDeviceList();
// 获取告知单号
// 调用方法
List<String> applyNoList = new ArrayList<>();
Random random = new Random();
for (int i = 0 ; i< deviceList.size(); i++) {
applyNoList.add(String.valueOf(random.nextInt()));
}
List<JgInstallationNotice> list = new ArrayList<>();
List<JgRelationEquip> equipList = new ArrayList<>();
deviceList.forEach(obj -> {
JgRelationEquip jgRelationEquip = new JgRelationEquip();
JgInstallationNotice dto = new JgInstallationNotice();
BeanUtils.copyProperties(model, dto);
int i = deviceList.indexOf(obj);
String applyNo = applyNoList.get(i);
dto.setApplyNo(applyNo);
dto.setEquList(String.valueOf(obj.get("sequenceNbr")));
jgRelationEquip.setEquipId(String.valueOf(obj.get("sequenceNbr")));
jgRelationEquip.setApplyNo(applyNo);
jgRelationEquip.setBusinessType("GZ");
list.add(dto);
equipList.add(jgRelationEquip);
});
jgInstallationNoticeMapper.insertBatchSomeColumn(list);
List<JgRelationEquip> jgRelationEquipList = equipList.stream().map(jgRelationEquip -> {
List<JgInstallationNotice> collect = list.stream().filter(jgInstallationNotice -> jgRelationEquip.getApplyNo().equals(jgInstallationNotice.getApplyNo())).collect(Collectors.toList());
Long sequenceNbr = collect.get(0).getSequenceNbr();
return jgRelationEquip.setBusinessId(String.valueOf(sequenceNbr));
}).collect(Collectors.toList());
jgRelationEquipMapper.insertBatchSomeColumn(jgRelationEquipList);
}
private void convertField(JgInstallationNoticeDto model) {
// 处理图片
String proxyStatementAttachment = convertImageUrl(model.getInstallContractAttachmentList());
String installContractAttachment =convertImageUrl(model.getProxyStatementAttachmentList());
model.setProxyStatementAttachment(proxyStatementAttachment);
model.setInstallContractAttachment(installContractAttachment);
// 分割省市区字段
String province = model.getProvince();
if (!ObjectUtils.isEmpty(province)) {
String[] provinceList = province.split("_");
if (provinceList.length > 1) {
model.setProvince(provinceList[0]);
model.setProvinceName(provinceList[1]);
}
}
String city = model.getCity();
if (!ObjectUtils.isEmpty(city)) {
String[] cityList = city.split("_");
if (cityList.length > 1) {
model.setCity(cityList[0]);
model.setCityName(cityList[1]);
}
}
String county = model.getCounty();
if (!ObjectUtils.isEmpty(county)) {
String[] countyList = county.split("_");
if (countyList.length > 1) {
model.setCounty(countyList[0]);
model.setCountyName(countyList[1]);
}
}
// 分割单位
String useUnitId = model.getUseUnitId();
if (!ObjectUtils.isEmpty(useUnitId)) {
String[] useUnitList = useUnitId.split("_");
if (useUnitList.length > 1) {
model.setUseUnitId(useUnitList[0]);
model.setUseUnitName(useUnitList[1]);
}
}
String receiveOrgId = model.getReceiveOrgId();
if (!ObjectUtils.isEmpty(receiveOrgId)) {
String[] receiveOrgIdList = receiveOrgId.split("_");
if (receiveOrgIdList.length > 1) {
model.setReceiveOrgId(receiveOrgIdList[0]);
model.setReceiveOrgName(receiveOrgIdList[1]);
}
}
String inspectUnitId = model.getInspectUnitId();
if (!ObjectUtils.isEmpty(inspectUnitId)) {
String[] inspectUnitIdList = inspectUnitId.split("_");
if (inspectUnitIdList.length > 1) {
model.setInspectUnitId(inspectUnitIdList[0]);
model.setInspectUnitName(inspectUnitIdList[1]);
}
}
}
private String convertImageUrl (List<Map<String, String>> urlList) {
String urls = "";
if (!CollectionUtils.isEmpty(urlList)) {
urls = urlList.stream().map(map -> map.get("url")).collect(Collectors.joining(","));
}
return urls;
}
}
\ No newline at end of file
package com.yeejoin.amos.boot.module.jg.biz.utils;
import com.baomidou.mybatisplus.core.injector.AbstractMethod;
import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
import com.baomidou.mybatisplus.extension.injector.methods.additional.InsertBatchSomeColumn;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @author DELL
*/
@Component
public class SqlInjectorUtils extends DefaultSqlInjector {
@Override
public List<AbstractMethod> getMethodList(Class<?> mapperClass) {
List<AbstractMethod> methodList = super.getMethodList(mapperClass);
// 添加批量插入方法
methodList.add(new InsertBatchSomeColumn());
return methodList;
}
}
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