EasyExcel 行业清单导入 及 接口调整
EasyExcel 企业导入 30%
This commit is contained in:
parent
a4167a5ad6
commit
543e337533
|
|
@ -65,4 +65,6 @@ public interface BaseInClassMapper {
|
||||||
|
|
||||||
/*最小工作单元行业*/
|
/*最小工作单元行业*/
|
||||||
List<BaseInClass> workIndustry();
|
List<BaseInClass> workIndustry();
|
||||||
|
|
||||||
|
BaseInClass selectBaseInClassByName(@Param("industryClassName") String industryClassName);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.rzyc.mapper.ent;
|
||||||
|
|
||||||
import com.rzyc.model.ent.InEntList;
|
import com.rzyc.model.ent.InEntList;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.rzyc.model.ent.InListItem;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
|
@ -25,4 +26,12 @@ public interface InEntListMapper extends BaseMapper<InEntList> {
|
||||||
* */
|
* */
|
||||||
List<InEntList> selectByEnterpriseId(@Param("enterpriseId") String enterpriseId);
|
List<InEntList> selectByEnterpriseId(@Param("enterpriseId") String enterpriseId);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 插入清单项到企业清单项表
|
||||||
|
* @param inListItems 行业清单项
|
||||||
|
* @return int
|
||||||
|
* */
|
||||||
|
int insertList(@Param("list")List<InEntList>inListItems);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,14 +19,15 @@ import java.util.List;
|
||||||
@Repository
|
@Repository
|
||||||
public interface InListItemMapper extends BaseMapper<InListItem> {
|
public interface InListItemMapper extends BaseMapper<InListItem> {
|
||||||
|
|
||||||
List<String> SelectContents();
|
List<InListItem> SelectContents(@Param("industryId") String industryId,@Param("listId")String listId);
|
||||||
|
|
||||||
/*通过行业查询清单信息*/
|
/*通过行业查询清单信息*/
|
||||||
List<InListItem> findByIndustryId(@Param("industryId") String industryId);
|
List<InListItem> findByIndustryId(@Param("industryId") String industryId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*导入清单项
|
||||||
*
|
* @param list
|
||||||
|
* @return int
|
||||||
* */
|
* */
|
||||||
int insertItem(List<EasyExcelInList>easyExcelInLists);
|
int insertItem(@Param("list") List<EasyExcelInList>list);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ import java.util.List;
|
||||||
@Repository
|
@Repository
|
||||||
public interface InListMapper extends BaseMapper<InList> {
|
public interface InListMapper extends BaseMapper<InList> {
|
||||||
/*查询所有*/
|
/*查询所有*/
|
||||||
List<InList> findAll();
|
List<InList> findAll(String industry);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.rzyc.model.EasyExcel;
|
||||||
|
|
||||||
|
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@EqualsAndHashCode
|
||||||
|
/**
|
||||||
|
* EasyExcel导入企业
|
||||||
|
* @author Xuwanxin
|
||||||
|
* @date 2022/12/16
|
||||||
|
* */
|
||||||
|
public class EasyExcelEnterprise {
|
||||||
|
|
||||||
|
private String address;
|
||||||
|
|
||||||
|
private String industry;
|
||||||
|
|
||||||
|
private String legalPerson;
|
||||||
|
|
||||||
|
private String legalPersonPhone;
|
||||||
|
|
||||||
|
private String safeChangePerson;
|
||||||
|
|
||||||
|
private String safeChangePersonPhone;
|
||||||
|
|
||||||
|
private Integer staffNumber;
|
||||||
|
|
||||||
|
private String dateOfIncorporation;
|
||||||
|
|
||||||
|
private String businessScope;
|
||||||
|
}
|
||||||
|
|
@ -8,6 +8,11 @@ import lombok.Setter;
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@EqualsAndHashCode
|
@EqualsAndHashCode
|
||||||
|
/**
|
||||||
|
* EasyExcel导入行业清单
|
||||||
|
* @author Xuwanxin
|
||||||
|
* @date 2022/12/15
|
||||||
|
* */
|
||||||
public class EasyExcelInList {
|
public class EasyExcelInList {
|
||||||
private String industry;
|
private String industry;
|
||||||
private String listName;
|
private String listName;
|
||||||
|
|
@ -16,6 +21,9 @@ public class EasyExcelInList {
|
||||||
private Integer standard;
|
private Integer standard;
|
||||||
private Integer frequency;
|
private Integer frequency;
|
||||||
private String remark;
|
private String remark;
|
||||||
|
private Integer sortId;
|
||||||
|
|
||||||
private String industryId;
|
private String industryId;
|
||||||
private String listId;
|
private String listId;
|
||||||
|
private String itemId;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,20 @@ public class InListAddDto {
|
||||||
@TableId("name")
|
@TableId("name")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "行业id")
|
||||||
|
private String industryId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "清单排序")
|
@ApiModelProperty(value = "清单排序")
|
||||||
@TableId("sort_id")
|
|
||||||
private Integer sortId;
|
private Integer sortId;
|
||||||
|
|
||||||
|
public String getIndustryId() {
|
||||||
|
return industryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIndustryId(String industryId) {
|
||||||
|
this.industryId = industryId;
|
||||||
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,46 +5,46 @@ import io.swagger.annotations.ApiModelProperty;
|
||||||
public class InListItemDto {
|
public class InListItemDto {
|
||||||
|
|
||||||
@ApiModelProperty(value = "清单项id")
|
@ApiModelProperty(value = "清单项id")
|
||||||
private String item_id;
|
private String itemId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "行业清单id")
|
@ApiModelProperty(value = "行业清单id")
|
||||||
private String list_id;
|
private String listId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "行业id")
|
@ApiModelProperty(value = "行业id")
|
||||||
private String industry_id;
|
private String industryId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "清单内容")
|
@ApiModelProperty(value = "清单内容")
|
||||||
private String item_content;
|
private String itemContent;
|
||||||
|
|
||||||
public String getItem_content() {
|
public String getItemContent() {
|
||||||
return item_content;
|
return itemContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setItem_content(String item_content) {
|
public void setItemContent(String itemContent) {
|
||||||
this.item_content = item_content;
|
this.itemContent = itemContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getItem_id() {
|
public String getItemId() {
|
||||||
return item_id;
|
return itemId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setItem_id(String item_id) {
|
public void setItemId(String itemId) {
|
||||||
this.item_id = item_id;
|
this.itemId = itemId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getList_id() {
|
public String getListId() {
|
||||||
return list_id;
|
return listId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setList_id(String list_id) {
|
public void setListId(String listId) {
|
||||||
this.list_id = list_id;
|
this.listId = listId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIndustry_id() {
|
public String getIndustryId() {
|
||||||
return industry_id;
|
return industryId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIndustry_id(String industry_id) {
|
public void setIndustryId(String industryId) {
|
||||||
this.industry_id = industry_id;
|
this.industryId = industryId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -360,7 +360,7 @@
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="findAll" resultMap="BaseResultMap">
|
<select id="findAll" resultMap="BaseResultMap">
|
||||||
select * from BaseInClass bc
|
select * from BaseInClass bc where hidden = 1
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="findByInType" resultMap="BaseResultMap">
|
<select id="findByInType" resultMap="BaseResultMap">
|
||||||
|
|
@ -455,4 +455,11 @@
|
||||||
WHERE bc.`in_type` = 2 AND bc.`SuperInId` IS NOT NULL AND bc.`SuperInId` != ''
|
WHERE bc.`in_type` = 2 AND bc.`SuperInId` IS NOT NULL AND bc.`SuperInId` != ''
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<select id="selectBaseInClassByName" resultMap="BaseResultMap">
|
||||||
|
SELECT * FROM `BaseInClass` bc
|
||||||
|
WHERE bc.`IndustryClassName` = #{industryClassName}
|
||||||
|
limit 1
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,26 @@
|
||||||
item_basis, item_proof, item_law, sort_id,del_state, create_time, create_by, modify_time, modify_by
|
item_basis, item_proof, item_law, sort_id,del_state, create_time, create_by, modify_time, modify_by
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
|
||||||
<select id="selectByEnterpriseId" resultMap="BaseResultMap">
|
<select id="selectByEnterpriseId" resultMap="BaseResultMap">
|
||||||
select * from in_ent_list where enterprise_id = #{enterpriseId}
|
select * from in_ent_list where enterprise_id = #{enterpriseId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertList">
|
||||||
|
insert into in_ent_list (ent_list_id,item_id,list_id,item_title,item_content,standard,frequency,sort_id,del_state,create_time,create_by,enterprise_id)values
|
||||||
|
<foreach collection="list" item="list" separator=",">
|
||||||
|
(#{list.entListId},
|
||||||
|
#{list.itemId},
|
||||||
|
#{list.listId},
|
||||||
|
#{list.itemTitle},
|
||||||
|
#{list.itemContent},
|
||||||
|
#{list.standard},
|
||||||
|
#{list.frequency},
|
||||||
|
#{list.sortId},
|
||||||
|
1,
|
||||||
|
#{list.createTime},
|
||||||
|
#{list.createBy},
|
||||||
|
#{list.enterpriseId})
|
||||||
|
</foreach>
|
||||||
|
</insert>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
|
|
@ -30,11 +30,29 @@ item_basis, item_proof, item_law, sort_id, del_state,create_time, create_by, mod
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<insert id="insertItem">
|
<insert id="insertItem">
|
||||||
|
insert into in_list_item (item_id,list_id,industry_id, item_title,item_content,standard,frequency, del_state,sort_id)values
|
||||||
|
<foreach collection="list" item="list" separator=",">
|
||||||
|
(#{list.itemId},
|
||||||
|
#{list.listId},
|
||||||
|
#{list.industryId},
|
||||||
|
#{list.listItem},
|
||||||
|
#{list.listContent},
|
||||||
|
#{list.standard},
|
||||||
|
#{list.frequency},
|
||||||
|
1,
|
||||||
|
#{list.sortId})
|
||||||
|
</foreach>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<select id="SelectContents" resultMap="BaseResultMap">
|
<select id="SelectContents" resultMap="BaseResultMap">
|
||||||
select item_content from in_list_item;
|
select * from in_list_item where del_state = 1
|
||||||
|
<if test="null != industryId and '' != industryId">
|
||||||
|
and industry_id = #{industryId}
|
||||||
|
</if>
|
||||||
|
<if test="null != listId and '' != listId">
|
||||||
|
and list_id = #{listId}
|
||||||
|
</if>
|
||||||
|
order by sort_id asc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!--通过行业查询清单信息-->
|
<!--通过行业查询清单信息-->
|
||||||
|
|
|
||||||
|
|
@ -22,18 +22,23 @@
|
||||||
|
|
||||||
<!--查询清单列-->
|
<!--查询清单列-->
|
||||||
<select id="findAll" resultMap="BaseResultMap">
|
<select id="findAll" resultMap="BaseResultMap">
|
||||||
select * from in_list il order by il.sort_id asc
|
select * from in_list il where del_state = 1
|
||||||
|
<if test="null != industry and '' != industry">
|
||||||
|
and industry_id = #{industry}
|
||||||
|
</if>
|
||||||
|
order by il.sort_id asc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<insert id="insertList">
|
<insert id="insertList">
|
||||||
insert into in_list (list_id, name, del_state, create_by,create_time,industry_id)values
|
insert into in_list (list_id, name, del_state, create_by,create_time,industry_id,sort_id)values
|
||||||
<foreach collection="list" item="list" separator=",">
|
<foreach collection="list" item="list" separator=",">
|
||||||
(#{list.listId},
|
(#{list.listId},
|
||||||
#{list.name},
|
#{list.name},
|
||||||
1,
|
1,
|
||||||
#{list.createBy},
|
#{list.createBy},
|
||||||
#{list.createTime},
|
#{list.createTime},
|
||||||
#{list.industryId})
|
#{list.industryId},
|
||||||
|
#{list.sortId})
|
||||||
</foreach>
|
</foreach>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -306,11 +306,11 @@ public class UploadController extends com.rzyc.controller.BaseController {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EasyExcel读取
|
* EasyExcel读取行业清单
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
@ApiOperation(value = "EasyExcel读取", notes = "EasyExcel读取")
|
@ApiOperation(value = "EasyExcel读取行业清单", notes = "EasyExcel读取行业清单")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@RequestMapping(value = "/readEasyExcel", method = RequestMethod.GET)
|
@RequestMapping(value = "/readEasyExcel", method = RequestMethod.GET)
|
||||||
public String readEasyExcel(MultipartFile file)throws Exception{
|
public String readEasyExcel(MultipartFile file)throws Exception{
|
||||||
|
|
@ -318,6 +318,19 @@ public class UploadController extends com.rzyc.controller.BaseController {
|
||||||
return "success";
|
return "success";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* EasyExcel读取企业
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "EasyExcel读取企业", notes = "EasyExcel读取企业")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping(value = "/readEasyExcelOfEnterprise", method = RequestMethod.GET)
|
||||||
|
public String readEasyExcelOfEnterprise(MultipartFile file)throws Exception{
|
||||||
|
pcBusinessService.readEasyExcelOfEnterprise(file);
|
||||||
|
return "success";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1202,4 +1202,10 @@ public class PcBusinessService extends BaseController {
|
||||||
return singleResult;
|
return singleResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SingleResult readEasyExcelOfEnterprise(MultipartFile file)throws IOException{
|
||||||
|
SingleResult singleResult = new SingleResult();
|
||||||
|
EasyExcel.read(file.getInputStream(), EasyExcelInList.class, new InListListener(inListMapper,inListItemMapper,baseInClassMapper)).doReadAll();
|
||||||
|
return singleResult;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,8 @@ public class InListListener implements ReadListener<EasyExcelInList> {
|
||||||
|
|
||||||
private String industryId = null;
|
private String industryId = null;
|
||||||
|
|
||||||
|
private Integer listSort = 1;
|
||||||
|
|
||||||
private InListMapper inListMapper;
|
private InListMapper inListMapper;
|
||||||
|
|
||||||
private InListItemMapper inListItemMapper;
|
private InListItemMapper inListItemMapper;
|
||||||
|
|
@ -66,19 +68,26 @@ public class InListListener implements ReadListener<EasyExcelInList> {
|
||||||
@Override
|
@Override
|
||||||
public void invoke(EasyExcelInList data, AnalysisContext context) {
|
public void invoke(EasyExcelInList data, AnalysisContext context) {
|
||||||
log.info("解析到一条数据:{}", JSON.toJSONString(data));
|
log.info("解析到一条数据:{}", JSON.toJSONString(data));
|
||||||
|
|
||||||
if (data.getListName() != null){
|
if (data.getListName() != null){
|
||||||
BaseInClass base = baseInClassMapper.selectByName(data.getListName());
|
BaseInClass base = null;
|
||||||
|
if (null == data.getIndustry()) {
|
||||||
|
|
||||||
|
}else {
|
||||||
|
base = baseInClassMapper.selectBaseInClassByName(data.getIndustry());
|
||||||
industryId = base.getBaseinclassid();
|
industryId = base.getBaseinclassid();
|
||||||
|
}
|
||||||
listName = data.getListName();
|
listName = data.getListName();
|
||||||
InList inList = new InList();
|
InList inList = new InList();
|
||||||
inList.setName(data.getListName());
|
inList.setName(data.getListName());
|
||||||
listId = RandomNumber.getUUid();
|
listId = RandomNumber.getUUid();
|
||||||
inList.setListId(RandomNumber.getUUid());
|
inList.setListId(listId);
|
||||||
inList.setIndustryId(base.getBaseinclassid());
|
inList.setIndustryId(industryId);
|
||||||
inList.setCreateBy("系统导入");
|
inList.setCreateBy("系统导入");
|
||||||
inList.setCreateTime(new Date());
|
inList.setCreateTime(new Date());
|
||||||
|
|
||||||
|
inList.setSortId(listSort);
|
||||||
queryList.add(inList);
|
queryList.add(inList);
|
||||||
|
listSort++;
|
||||||
}
|
}
|
||||||
if (data.getIndustry() != null){
|
if (data.getIndustry() != null){
|
||||||
industry = data.getIndustry();
|
industry = data.getIndustry();
|
||||||
|
|
@ -87,6 +96,7 @@ public class InListListener implements ReadListener<EasyExcelInList> {
|
||||||
data.setIndustry(industry);
|
data.setIndustry(industry);
|
||||||
data.setListId(listId);
|
data.setListId(listId);
|
||||||
data.setIndustryId(industryId);
|
data.setIndustryId(industryId);
|
||||||
|
data.setItemId(RandomNumber.getUUid());
|
||||||
cachedDataList.add(data);
|
cachedDataList.add(data);
|
||||||
// 达到BATCH_COUNT了,需要去存储一次数据库,防止数据几万条数据在内存,容易OOM
|
// 达到BATCH_COUNT了,需要去存储一次数据库,防止数据几万条数据在内存,容易OOM
|
||||||
if (cachedDataList.size() >= BATCH_COUNT) {
|
if (cachedDataList.size() >= BATCH_COUNT) {
|
||||||
|
|
@ -109,6 +119,8 @@ public class InListListener implements ReadListener<EasyExcelInList> {
|
||||||
public void doAfterAllAnalysed(AnalysisContext context) {
|
public void doAfterAllAnalysed(AnalysisContext context) {
|
||||||
//这里也要保存数据,确保最后遗留的数据也存储到数据库
|
//这里也要保存数据,确保最后遗留的数据也存储到数据库
|
||||||
saveList();
|
saveList();
|
||||||
|
// 存储完成清理 list
|
||||||
|
queryList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
|
||||||
log.info("所有数据解析完成!");
|
log.info("所有数据解析完成!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -128,8 +140,6 @@ public class InListListener implements ReadListener<EasyExcelInList> {
|
||||||
private void saveList() {
|
private void saveList() {
|
||||||
log.info("{}条数据,开始存储数据库!", cachedDataList.size());
|
log.info("{}条数据,开始存储数据库!", cachedDataList.size());
|
||||||
int result = inListMapper.insertList(queryList);
|
int result = inListMapper.insertList(queryList);
|
||||||
//清空list
|
|
||||||
queryList = new ArrayList<>();
|
|
||||||
log.info("存储数据库成功!");
|
log.info("存储数据库成功!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,35 +20,5 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class ReadTest {
|
public class ReadTest {
|
||||||
|
|
||||||
@Autowired
|
|
||||||
InListMapper inListMapper;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
InListItemMapper inListItemMapper;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
BaseInClassMapper baseInClassMapper;
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void repeatedRead() {
|
|
||||||
String fileName = "导入模板.xlsx";
|
|
||||||
// 读取全部sheet
|
|
||||||
// 这里需要注意 DemoDataListener的doAfterAllAnalysed 会在每个sheet读取完毕后调用一次。然后所有sheet都会往同一个DemoDataListener里面写
|
|
||||||
EasyExcel.read(fileName, EasyExcelInList.class, new InListListener(inListMapper,inListItemMapper,baseInClassMapper)).doReadAll();
|
|
||||||
|
|
||||||
// 读取部分sheet
|
|
||||||
// fileName = TestFileUtil.getPath() + "demo" + File.separator + "demo.xlsx";
|
|
||||||
//
|
|
||||||
// // 写法1
|
|
||||||
// try (ExcelReader excelReader = EasyExcel.read(fileName).build()) {
|
|
||||||
// // 这里为了简单 所以注册了 同样的head 和Listener 自己使用功能必须不同的Listener
|
|
||||||
// ReadSheet readSheet1 =
|
|
||||||
// EasyExcel.readSheet(0).head(DemoData.class).registerReadListener(new DemoDataListener()).build();
|
|
||||||
// ReadSheet readSheet2 =
|
|
||||||
// EasyExcel.readSheet(1).head(DemoData.class).registerReadListener(new DemoDataListener()).build();
|
|
||||||
// // 这里注意 一定要把sheet1 sheet2 一起传进去,不然有个问题就是03版的excel 会读取多次,浪费性能
|
|
||||||
// excelReader.read(readSheet1, readSheet2);
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ import com.rzyc.model.check.BookEntHT;
|
||||||
import com.rzyc.model.check.ChkPerson;
|
import com.rzyc.model.check.ChkPerson;
|
||||||
import com.rzyc.model.ent.*;
|
import com.rzyc.model.ent.*;
|
||||||
import com.rzyc.model.user.*;
|
import com.rzyc.model.user.*;
|
||||||
|
import com.rzyc.utils.ObjectConversion;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.apache.poi.ss.usermodel.*;
|
import org.apache.poi.ss.usermodel.*;
|
||||||
import org.apache.poi.ss.util.CellRangeAddress;
|
import org.apache.poi.ss.util.CellRangeAddress;
|
||||||
|
|
@ -2728,6 +2729,27 @@ public class BaseController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Xu wanxin
|
||||||
|
* @param industryId
|
||||||
|
* @param companyId
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public void saveEntInList(String industryId,String companyId)throws Exception{
|
||||||
|
List<InListItem> inListItem = inListItemMapper.SelectContents(industryId,null);
|
||||||
|
List<InEntList> entLists = ObjectConversion.copy(inListItem,InEntList.class);
|
||||||
|
for (InEntList in:entLists) {
|
||||||
|
in.setEnterpriseId(companyId);
|
||||||
|
in.setEntListId(RandomNumber.getUUid());
|
||||||
|
in.setCreateBy(getUserId());
|
||||||
|
in.setCreateTime(new Date());
|
||||||
|
in.setEnterpriseId(companyId);
|
||||||
|
}
|
||||||
|
int result = inEntListMapper.insertList(entLists);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取政府机构的管辖区域的id
|
* 获取政府机构的管辖区域的id
|
||||||
* @param userId
|
* @param userId
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,7 @@ package com.rzyc.controller;
|
||||||
import com.common.utils.DateUtils;
|
import com.common.utils.DateUtils;
|
||||||
import com.common.utils.RandomNumber;
|
import com.common.utils.RandomNumber;
|
||||||
import com.common.utils.StringUtils;
|
import com.common.utils.StringUtils;
|
||||||
import com.common.utils.model.MultiResult;
|
import com.common.utils.model.*;
|
||||||
import com.common.utils.model.Pager;
|
|
||||||
import com.common.utils.model.SingleResult;
|
|
||||||
import com.github.pagehelper.Page;
|
import com.github.pagehelper.Page;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
import com.rzyc.model.dto.*;
|
import com.rzyc.model.dto.*;
|
||||||
|
|
@ -47,17 +45,11 @@ public class IndustryListController extends BaseController{
|
||||||
@ApiOperation(value = "父级行业列表", notes = "行业清单列表")
|
@ApiOperation(value = "父级行业列表", notes = "行业清单列表")
|
||||||
@GetMapping("/industrySelect")
|
@GetMapping("/industrySelect")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public MultiResult<String> industrySelect(){
|
public MultiResult<BaseInClass> industrySelect(){
|
||||||
|
|
||||||
MultiResult<String> result = new MultiResult<>();
|
MultiResult<BaseInClass> result = new MultiResult<>();
|
||||||
ArrayList<String> nameList = new ArrayList<>();
|
|
||||||
List<BaseInClass> baseInClassList = baseInClassMapper.findAll();
|
List<BaseInClass> baseInClassList = baseInClassMapper.findAll();
|
||||||
//取出对象的name字段放入集合
|
result.setData(baseInClassList);
|
||||||
for (BaseInClass baseInClass : baseInClassList) {
|
|
||||||
String industryClassName = baseInClass.getIndustryclassname();
|
|
||||||
nameList.add(industryClassName);
|
|
||||||
}
|
|
||||||
result.setData(nameList);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -71,49 +63,33 @@ public class IndustryListController extends BaseController{
|
||||||
@ApiOperation(value = "行业清单列表", notes = "行业清单列表")
|
@ApiOperation(value = "行业清单列表", notes = "行业清单列表")
|
||||||
@GetMapping("/industryListSelect")
|
@GetMapping("/industryListSelect")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public MultiResult<String> industryListSelect()throws Exception{
|
public MultiResult<InList> industryListSelect(String industry)throws Exception{
|
||||||
MultiResult<String> result = new MultiResult<>();
|
MultiResult<InList> result = new MultiResult<>();
|
||||||
ArrayList<String> nameList = new ArrayList<>();
|
List<InList> inLists = inListMapper.findAll(industry);
|
||||||
List<InList> inLists = inListMapper.findAll();
|
result.setData(inLists);
|
||||||
//取出对象的name字段放入集合
|
|
||||||
if(inLists.size() > 0){
|
|
||||||
for (InList inList : inLists) {
|
|
||||||
String name = inList.getName();
|
|
||||||
nameList.add(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
result.setData(nameList);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "新增行业清单分类", notes = "新增行业清单分类")
|
@ApiOperation(value = "新增行业清单分类", notes = "新增行业清单分类")
|
||||||
@PostMapping("/industryListAdd")
|
@PostMapping("/industryListAdd")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public MultiResult<String> industryListAdd(@Valid @RequestBody InListAddDto inListAddDto){
|
public MultiResult<String> industryListAdd(@Valid @RequestBody InListAddDto inListAddDto) throws Exception {
|
||||||
|
|
||||||
MultiResult<String> result = new MultiResult<>();
|
MultiResult<String> result = new MultiResult<>();
|
||||||
InList inList = new InList();
|
InList inList = new InList();
|
||||||
//前端数据拷贝至对象
|
//前端数据拷贝至对象
|
||||||
BeanUtils.copyProperties(inListAddDto,inList);
|
BeanUtils.copyProperties(inListAddDto,inList);
|
||||||
//industryId设null表示共有清单
|
//industryId设null表示共有清单
|
||||||
|
|
||||||
if(StringUtils.isBlank(inList.getListId())){
|
if(StringUtils.isBlank(inList.getListId())){
|
||||||
//补全对象其余字段
|
//补全对象其余字段
|
||||||
inList.setListId(RandomNumber.getUUid());
|
inList.setListId(RandomNumber.getUUid());
|
||||||
inList.setDelState(1);
|
inList.setDelState(1);
|
||||||
inList.setCreateTime(new Date());
|
inList.setCreateTime(new Date());
|
||||||
inList.setIndustryId(null);
|
inList.setCreateBy(getUserId());
|
||||||
|
|
||||||
}
|
}
|
||||||
//industryId不设Null表示公有清单
|
int num = inListMapper.insert(inList);
|
||||||
if(StringUtils.isBlank(inList.getListId())){
|
if (num <= 0){
|
||||||
//补全对象其余字段
|
result.setCode(Code.ERROR.getCode());
|
||||||
inList.setListId(RandomNumber.getUUid());
|
result.setMessage(Message.ERROR);
|
||||||
inList.setDelState(1);
|
|
||||||
inList.setCreateTime(new Date());
|
|
||||||
//暂时设定危化品父级下
|
|
||||||
inList.setIndustryId("01c2afc4-cb18-4ac1-9560-b4708877db26");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -127,13 +103,13 @@ public class IndustryListController extends BaseController{
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
@ApiOperation(value = "所属清单项列表分页", notes = "所属清单项列表分页")
|
@ApiOperation(value = "所属清单项列表分页", notes = "所属清单项列表分页")
|
||||||
@GetMapping("/industryListItemSelect")
|
@PostMapping("/industryListItemSelect")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public SingleResult<Pager<String>> industryListItemSelect(@RequestBody InListPageDto inListPageDto) throws Exception {
|
public SingleResult<Pager<String>> industryListItemSelect(@RequestBody InListPageDto inListPageDto) throws Exception {
|
||||||
SingleResult<Pager<String>> result = new SingleResult<>();
|
SingleResult<Pager<String>> result = new SingleResult<>();
|
||||||
Pager<String> pager = new Pager<>();
|
Pager<String> pager = new Pager<>();
|
||||||
PageHelper.startPage(inListPageDto.getPage(),inListPageDto.getPageSize());
|
PageHelper.startPage(inListPageDto.getPage(),inListPageDto.getPageSize());
|
||||||
Page<String> page = (Page<String>)inListItemMapper.SelectContents();
|
Page<InListItem> page = (Page<InListItem>)inListItemMapper.SelectContents(inListPageDto.getIndustryId(),inListPageDto.getListId());
|
||||||
getDatePage(pager,page);
|
getDatePage(pager,page);
|
||||||
result.setData(pager);
|
result.setData(pager);
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -149,7 +125,7 @@ public class IndustryListController extends BaseController{
|
||||||
@PostMapping("/deleteInListItem")
|
@PostMapping("/deleteInListItem")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public SingleResult<String> deleteInListItem(@Valid @RequestBody InListItemDto inListItemDto)throws Exception{
|
public SingleResult<String> deleteInListItem(@Valid @RequestBody InListItemDto inListItemDto)throws Exception{
|
||||||
inListItemMapper.deleteById(inListItemDto.getItem_id());
|
inListItemMapper.deleteById(inListItemDto.getItemId());
|
||||||
return new SingleResult<String>();
|
return new SingleResult<String>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -169,7 +145,7 @@ public class IndustryListController extends BaseController{
|
||||||
BaseInClass baseInClass = baseInClassMapper.selectByPrimaryKey(inListItemAddDto.getIndustryId());
|
BaseInClass baseInClass = baseInClassMapper.selectByPrimaryKey(inListItemAddDto.getIndustryId());
|
||||||
if(null == inList){
|
if(null == inList){
|
||||||
result.setCode(0);
|
result.setCode(0);
|
||||||
result.setMessage("用户不存在");
|
result.setMessage("清单不存在");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if(StringUtils.isBlank(inListItem.getItemId())){
|
if(StringUtils.isBlank(inListItem.getItemId())){
|
||||||
|
|
@ -187,11 +163,8 @@ public class IndustryListController extends BaseController{
|
||||||
inListItem.setModifyBy(inList.getListId());
|
inListItem.setModifyBy(inList.getListId());
|
||||||
//inListItem.setIndustryId(baseInClass.getBaseinclassid());
|
//inListItem.setIndustryId(baseInClass.getBaseinclassid());
|
||||||
inListItemMapper.updateById(inListItem);
|
inListItemMapper.updateById(inListItem);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2126,7 +2126,8 @@ public class MinWorkController extends BaseController{
|
||||||
|
|
||||||
//生成最小工作单元
|
//生成最小工作单元
|
||||||
saveEntWork(sysEnterprise.getSysenterpriseid());
|
saveEntWork(sysEnterprise.getSysenterpriseid());
|
||||||
|
//生成行业对应的企业责任清单
|
||||||
|
saveEntInList(sysEnterprise.getBaseinclassid(),sysEnterprise.getSysenterpriseid());
|
||||||
//创建或者修改企业用户
|
//创建或者修改企业用户
|
||||||
createEntUser(sysEnterprise,sysUser.getChinaname(),sysUser);
|
createEntUser(sysEnterprise,sysUser.getChinaname(),sysUser);
|
||||||
if (result > 0){
|
if (result > 0){
|
||||||
|
|
|
||||||
|
|
@ -1221,7 +1221,7 @@ public class PcPersonalController extends com.rzyc.controller.BaseController {
|
||||||
public SingleResult<String> changePerformRecord(@Valid @RequestBody AddPerformRecordDto addPerformRecordDto)throws Exception{
|
public SingleResult<String> changePerformRecord(@Valid @RequestBody AddPerformRecordDto addPerformRecordDto)throws Exception{
|
||||||
SingleResult<String> result = new SingleResult<>();
|
SingleResult<String> result = new SingleResult<>();
|
||||||
ListDetailWithBLOBs listDetail = new ListDetailWithBLOBs();
|
ListDetailWithBLOBs listDetail = new ListDetailWithBLOBs();
|
||||||
BeanUtils.copyProperties(listDetail,addPerformRecordDto);
|
org.springframework.beans.BeanUtils.copyProperties(addPerformRecordDto,listDetail);
|
||||||
|
|
||||||
//处理时间
|
//处理时间
|
||||||
listDetail.setStarttime(DateUtils.parseString2Date(addPerformRecordDto.getStartTime(),"yyyy-MM-dd"));
|
listDetail.setStarttime(DateUtils.parseString2Date(addPerformRecordDto.getStartTime(),"yyyy-MM-dd"));
|
||||||
|
|
|
||||||
|
|
@ -540,7 +540,7 @@ public class PcCompanyController extends com.rzyc.controller.BaseController {
|
||||||
* 报错No value specified for Date
|
* 报错No value specified for Date
|
||||||
* */
|
* */
|
||||||
ConvertUtils.register(new DateConverter(null), Date.class);
|
ConvertUtils.register(new DateConverter(null), Date.class);
|
||||||
BeanUtils.copyProperties(sysEnterprise,sysEnterpriseDo);
|
org.springframework.beans.BeanUtils.copyProperties(sysEnterpriseDo,sysEnterprise);
|
||||||
String token = servletRequest.getHeader("userToken");
|
String token = servletRequest.getHeader("userToken");
|
||||||
String userId = JwtUtil.getTokenMsg(token);
|
String userId = JwtUtil.getTokenMsg(token);
|
||||||
if (StringUtils.isBlank(userId)){
|
if (StringUtils.isBlank(userId)){
|
||||||
|
|
@ -591,7 +591,8 @@ public class PcCompanyController extends com.rzyc.controller.BaseController {
|
||||||
|
|
||||||
//生成最小工作单元
|
//生成最小工作单元
|
||||||
saveEntWork(sysEnterprise.getSysenterpriseid());
|
saveEntWork(sysEnterprise.getSysenterpriseid());
|
||||||
|
//生成行业对应的企业责任清单
|
||||||
|
saveEntInList(sysEnterprise.getWorkClassId(),sysEnterprise.getSysenterpriseid());
|
||||||
//创建或者修改企业用户
|
//创建或者修改企业用户
|
||||||
createEntUser(sysEnterprise,sysUser.getChinaname(),sysUser);
|
createEntUser(sysEnterprise,sysUser.getChinaname(),sysUser);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
package com.rzyc.utils;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 两个对象或集合同名属性赋值
|
||||||
|
* @author Xu wanxin
|
||||||
|
*/
|
||||||
|
public class ObjectConversion {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从List<A> copy到List<B>
|
||||||
|
* @param list List<B>
|
||||||
|
* @param clazz B
|
||||||
|
* @return List<B>
|
||||||
|
*/
|
||||||
|
public static <T> List<T> copy(List<?> list,Class<T> clazz){
|
||||||
|
String oldOb = JSON.toJSONString(list);
|
||||||
|
return JSON.parseArray(oldOb, clazz);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从对象A copy到 对象B
|
||||||
|
* @param ob A
|
||||||
|
* @param clazz B.class
|
||||||
|
* @return B
|
||||||
|
*/
|
||||||
|
public static <T> T copy(Object ob,Class<T> clazz){
|
||||||
|
String oldOb = JSON.toJSONString(ob);
|
||||||
|
return JSON.parseObject(oldOb, clazz);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
spring:
|
spring:
|
||||||
profiles:
|
profiles:
|
||||||
active: dev #设定打包配置文件
|
active: prod #设定打包配置文件
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user