Sfoglia il codice sorgente

互市区同步处理

qzyReal 1 anno fa
parent
commit
76a6f0171a

+ 81 - 0
sp-core/sp-api/src/main/java/com/pj/api/dto/BorderDTO.java

@@ -0,0 +1,81 @@
+package com.pj.api.dto;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ { "borderNo":"序号",
+ "borderPutrecNo":"边民备案编号",
+ "borderName":"边民姓名",
+ "ciphertextIdno":"边民身份证号",
+ "borderAddr":"户籍地址",
+ "borderTel":"手机号码",
+ "groupId":"本系统中互助组 id"
+ }
+ *
+ */
+public class BorderDTO {
+
+    private String borderNo;
+    private String borderPutrecNo;
+    private String borderName;
+    private String ciphertextIdno;
+    private String borderAddr;
+    private String borderTel;
+    private String groupId;
+
+    public String getBorderNo() {
+        return borderNo;
+    }
+
+    public void setBorderNo(String borderNo) {
+        this.borderNo = borderNo;
+    }
+
+    public String getBorderPutrecNo() {
+        return borderPutrecNo;
+    }
+
+    public void setBorderPutrecNo(String borderPutrecNo) {
+        this.borderPutrecNo = borderPutrecNo;
+    }
+
+    public String getBorderName() {
+        return borderName;
+    }
+
+    public void setBorderName(String borderName) {
+        this.borderName = borderName;
+    }
+
+    public String getCiphertextIdno() {
+        return ciphertextIdno;
+    }
+
+    public void setCiphertextIdno(String ciphertextIdno) {
+        this.ciphertextIdno = ciphertextIdno;
+    }
+
+    public String getBorderAddr() {
+        return borderAddr;
+    }
+
+    public void setBorderAddr(String borderAddr) {
+        this.borderAddr = borderAddr;
+    }
+
+    public String getBorderTel() {
+        return borderTel;
+    }
+
+    public void setBorderTel(String borderTel) {
+        this.borderTel = borderTel;
+    }
+
+    public String getGroupId() {
+        return groupId;
+    }
+
+    public void setGroupId(String groupId) {
+        this.groupId = groupId;
+    }
+}

+ 2 - 0
sp-service/async-server/src/main/java/com/pj/task/HtByteTask.java

@@ -1,5 +1,6 @@
 package com.pj.task;
 
+import cn.hutool.json.JSONUtil;
 import cn.hutool.log.StaticLog;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson2.JSONObject;
@@ -132,6 +133,7 @@ public class HtByteTask {
                 case "001":
                     //对象转换
                     PeopleDto peopleDto = JSONObject.parseObject(body, PeopleDto.class);
+
                     //根据其内的身份证,有则新增,无则修改???
                     flag = FeignFactory.levelOneServerInterface.peopleDto(peopleDto);
                     methodHtByteTask.updateHtByteInfo(flag, item, dataDto);

+ 332 - 310
sp-service/level-one-server/src/main/java/com/pj/tb_group/TbGroupService.java

@@ -9,8 +9,10 @@ import java.util.Date;
 import java.util.List;
 import java.util.Objects;
 
+import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.pj.api.dto.BorderDTO;
 import com.pj.api.dto.GroupDto;
 import com.pj.current.satoken.StpUserUtil;
 import com.pj.enummj.DeleteStatus;
@@ -18,6 +20,9 @@ import com.pj.enummj.IsLock;
 import com.pj.tb_goods_transit.TbGoodsTransit;
 import com.pj.tb_people.TbPeople;
 import com.pj.tb_people.TbPeopleMapper;
+import com.pj.tb_people.TbPeopleService;
+import com.pj.tb_trade_area.TbTradeArea;
+import com.pj.tb_trade_area.TbTradeAreaService;
 import com.pj.utils.so.SoMap;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.hssf.usermodel.HSSFRow;
@@ -32,351 +37,368 @@ import org.springframework.transaction.annotation.Transactional;
 import com.pj.utils.sg.*;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.annotation.Resource;
 import javax.swing.filechooser.FileSystemView;
 
 /**
  * Service: tb_group -- 互助组
+ *
  * @author qzy
  */
 @Service
 @Transactional(rollbackFor = Exception.class)
 public class TbGroupService extends ServiceImpl<TbGroupMapper, TbGroup> implements IService<TbGroup> {
 
-	/**
-	 * 底层 Mapper 对象
-	 */
-	@Autowired
-	TbGroupMapper tbGroupMapper;
-	@Autowired
-	TbPeopleMapper tbPeopleMapper;
+    /**
+     * 底层 Mapper 对象
+     */
+    @Autowired
+    TbGroupMapper tbGroupMapper;
+    @Autowired
+    TbPeopleService tbPeopleService;
 
-	@Autowired
-	private MethodGroupService methodGroupService;
+    @Autowired
+    private MethodGroupService methodGroupService;
+    @Resource
+    private TbTradeAreaService tbTradeAreaService;
 
-	/**
-	 * 增
-	 */
-	void add(TbGroup t) {
-		t.setCreateTime(new Date())
-				.setCreateName(StpUserUtil.getPCLoginInfo().getLoginName())
-				.setCreateBy(Long.valueOf(StpUserUtil.getPCLoginInfo().getLoginId()))
-				.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode())
-				.setIsLock(IsLock.IS_LOCK_ON.getCode());
-		save(t);
-	}
+    /**
+     * 增
+     */
+    void add(TbGroup t) {
+        t.setCreateTime(new Date())
+                .setCreateName(StpUserUtil.getPCLoginInfo().getLoginName())
+                .setCreateBy(Long.valueOf(StpUserUtil.getPCLoginInfo().getLoginId()))
+                .setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode())
+                .setIsLock(IsLock.IS_LOCK_ON.getCode());
+        save(t);
+    }
 
-	/**
-	 * 删
-	 */
-	void delete(Long id) {
-		removeById(id);
-	}
+    /**
+     * 删
+     */
+    void delete(Long id) {
+        removeById(id);
+    }
 
-	/**
-	 * 改
-	 */
-	void update(TbGroup t) {
-		t.setUpdateTime(new Date())
-				.setUpdateName(StpUserUtil.getPCLoginInfo().getLoginName())
-				.setUpdateBy(Long.valueOf(StpUserUtil.getPCLoginInfo().getLoginId()));
-		updateById(t);
+    /**
+     * 改
+     */
+    void update(TbGroup t) {
+        t.setUpdateTime(new Date())
+                .setUpdateName(StpUserUtil.getPCLoginInfo().getLoginName())
+                .setUpdateBy(Long.valueOf(StpUserUtil.getPCLoginInfo().getLoginId()));
+        updateById(t);
 
-	}
+    }
 
-	/**
-	 * 查
-	 */
-	TbGroup getById(String id) {
-		return super.getById(id);
-	}
+    /**
+     * 查
+     */
+    TbGroup getById(String id) {
+        return super.getById(id);
+    }
 
-	/**
-	 * 查集合 - 根据条件(参数为空时代表忽略指定条件)
-	 */
-	List<TbGroup> getList(SoMap so) {
-		return tbGroupMapper.getList(so);
-	}
+    /**
+     * 查集合 - 根据条件(参数为空时代表忽略指定条件)
+     */
+    List<TbGroup> getList(SoMap so) {
+        return tbGroupMapper.getList(so);
+    }
 
-	public int setLeader(Long groupId, Long leaderId) {
-		// 获取当前登录用户id
-		Long loginId = StpUserUtil.getLoginIdAsLong();
-		// 获取互助组信息
-		TbGroup tbGroup = tbGroupMapper.selectById(groupId);
-		// 获取边民信息
-		TbPeople tbPeople = tbPeopleMapper.selectById(leaderId);
-		// 如果互助组不存在则抛异常
-		if (Objects.isNull(tbGroup)) {
-			throw new RuntimeException("该互助组不存在");
-		}
-		// 如果边民不存在
-		if (Objects.isNull(tbPeople)) {
-			throw new RuntimeException("该用户不存在");
-		}
-		// 如果互助组被锁定则抛异常
-		if (tbGroup.getIsLock() == 1) {
-			throw new RuntimeException("该互助组已被锁定");
-		}
-		// 如果边民不存在则抛异常
-		if (tbPeople.getIsLock() == 1) {
-			throw new RuntimeException("该用户已被锁定");
-		}
-		// 设置互助组组长
-		tbGroup.setLeaderId(tbPeople.getId());
-		tbGroup.setLeaderName(tbPeople.getBorderName());
-		tbGroup.setLeaderPhone(tbPeople.getBorderTel());
-		// 写入更新者id
-		tbGroup.setUpdateBy(loginId);
-		// 更新互助组
-		int line = tbGroupMapper.updateById(tbGroup);
-		return line;
-	}
+    public int setLeader(Long groupId, Long leaderId) {
+        // 获取当前登录用户id
+        Long loginId = StpUserUtil.getLoginIdAsLong();
+        // 获取互助组信息
+        TbGroup tbGroup = tbGroupMapper.selectById(groupId);
+        // 获取边民信息
+        TbPeople tbPeople = tbPeopleService.getById(leaderId);
+        // 如果互助组不存在则抛异常
+        if (Objects.isNull(tbGroup)) {
+            throw new RuntimeException("该互助组不存在");
+        }
+        // 如果边民不存在
+        if (Objects.isNull(tbPeople)) {
+            throw new RuntimeException("该用户不存在");
+        }
+        // 如果互助组被锁定则抛异常
+        if (tbGroup.getIsLock() == 1) {
+            throw new RuntimeException("该互助组已被锁定");
+        }
+        // 如果边民不存在则抛异常
+        if (tbPeople.getIsLock() == 1) {
+            throw new RuntimeException("该用户已被锁定");
+        }
+        // 设置互助组组长
+        tbGroup.setLeaderId(tbPeople.getId());
+        tbGroup.setLeaderName(tbPeople.getBorderName());
+        tbGroup.setLeaderPhone(tbPeople.getBorderTel());
+        // 写入更新者id
+        tbGroup.setUpdateBy(loginId);
+        // 更新互助组
+        int line = tbGroupMapper.updateById(tbGroup);
+        return line;
+    }
 
-	public int AddGroupPeople(Long groupId, Long[] peopleIds) {
-		// 获取当前登录用户id
+    public int AddGroupPeople(Long groupId, Long[] peopleIds) {
+        // 获取当前登录用户id
 //		Long loginId = StpUserUtil.getLoginIdAsLong();
-		int line = 0;
-		// 获取互助组信息
-		TbGroup tbGroup = tbGroupMapper.selectById(groupId);
-		// 如果互助组不存在则抛异常
-		if (Objects.isNull(tbGroup)) {
-			throw new RuntimeException("该互助组不存在");
-		}
-		// 如果互助组被锁定则抛异常
-		if (tbGroup.getIsLock() == 1) {
-			throw new RuntimeException("该互助组已被锁定");
-		}
-		// 如果互助组被删除则抛异常
-		if (tbGroup.getDeleteStatus() == 1) {
-			throw new RuntimeException("该互助组已被删除");
-		}
-		List<Long> list = Arrays.asList(peopleIds);
-		// 把互助组信息写入边民表
-		for (Long peopleId : list) {
-			TbPeople tbPeople = tbPeopleMapper.selectById(peopleId);
-			tbPeople.setGroupId(tbGroup.getId());
-			tbPeople.setGroupName(tbGroup.getOrgName());
-			// 写入更新者id
+        int line = 0;
+        // 获取互助组信息
+        TbGroup tbGroup = tbGroupMapper.selectById(groupId);
+        // 如果互助组不存在则抛异常
+        if (Objects.isNull(tbGroup)) {
+            throw new RuntimeException("该互助组不存在");
+        }
+        // 如果互助组被锁定则抛异常
+        if (tbGroup.getIsLock() == 1) {
+            throw new RuntimeException("该互助组已被锁定");
+        }
+        // 如果互助组被删除则抛异常
+        if (tbGroup.getDeleteStatus() == 1) {
+            throw new RuntimeException("该互助组已被删除");
+        }
+        List<Long> list = Arrays.asList(peopleIds);
+        // 把互助组信息写入边民表
+        for (Long peopleId : list) {
+            TbPeople tbPeople = tbPeopleService.getById(peopleId);
+            tbPeople.setGroupId(tbGroup.getId());
+            tbPeople.setGroupName(tbGroup.getOrgName());
+            // 写入更新者id
 //			tbPeople.setUpdateBy(String.valueOf(loginId));
-			int i = tbPeopleMapper.updateById(tbPeople);
-			line = i + 1;
-		}
-		return line;
+            int i = tbPeopleService.updateById(tbPeople) ? 1 : 0;
+            line = i + 1;
+        }
+        return line;
 
-	}
+    }
 
-	public int DelGroupPeople(Long groupId, Long[] peopleIds) {
+    public int DelGroupPeople(Long groupId, Long[] peopleIds) {
 
-		// 获取当前登录用户id
-		Long loginId = StpUserUtil.getLoginIdAsLong();
-		int line = 0;
-		// 获取互助组信息
-		TbGroup tbGroup = tbGroupMapper.selectById(groupId);
-		// 如果互助组不存在则抛异常
-		if (Objects.isNull(tbGroup)) {
-			throw new RuntimeException("该互助组不存在");
-		}
-		// 如果互助组被锁定则抛异常
-		if (tbGroup.getIsLock() == 1) {
-			throw new RuntimeException("该互助组已被锁定");
-		}
-		// 如果互助组被删除则抛异常
-		if (tbGroup.getDeleteStatus() == 1) {
-			throw new RuntimeException("该互助组已被删除");
-		}
-		List<Long> list = Arrays.asList(peopleIds);
-		// 把边民表互助组信息置空
-		for (Long peopleId : list) {
-			TbPeople tbPeople = tbPeopleMapper.selectById(peopleId);
-			tbPeople.setGroupId(0L);
-			tbPeople.setGroupName("");
-			// 写入更新者id
-			tbPeople.setUpdateBy(String.valueOf(loginId));
-			int i = tbPeopleMapper.updateById(tbPeople);
-			line = i + 1;
-		}
-		return line;
-	}
+        // 获取当前登录用户id
+        Long loginId = StpUserUtil.getLoginIdAsLong();
+        int line = 0;
+        // 获取互助组信息
+        TbGroup tbGroup = tbGroupMapper.selectById(groupId);
+        // 如果互助组不存在则抛异常
+        if (Objects.isNull(tbGroup)) {
+            throw new RuntimeException("该互助组不存在");
+        }
+        // 如果互助组被锁定则抛异常
+        if (tbGroup.getIsLock() == 1) {
+            throw new RuntimeException("该互助组已被锁定");
+        }
+        // 如果互助组被删除则抛异常
+        if (tbGroup.getDeleteStatus() == 1) {
+            throw new RuntimeException("该互助组已被删除");
+        }
+        List<Long> list = Arrays.asList(peopleIds);
+        // 把边民表互助组信息置空
+        for (Long peopleId : list) {
+            TbPeople tbPeople = tbPeopleService.getById(peopleId);
+            tbPeople.setGroupId(0L);
+            tbPeople.setGroupName("");
+            // 写入更新者id
+            tbPeople.setUpdateBy(String.valueOf(loginId));
+            int i = tbPeopleService.updateById(tbPeople) ? 1 : 0;
+            line = i + 1;
+        }
+        return line;
+    }
 
-	public int isLock(TbGroupDto tbGroupDto) {
-		// 获取当前登录用户id
-		Long loginId = StpUserUtil.getLoginIdAsLong();
-		// 获取互助组信息
-		TbGroup tbGroup = tbGroupMapper.selectById(tbGroupDto.getId());
-		// 如果互助组不存在则抛异常
-		if (Objects.isNull(tbGroup)) {
-			throw new RuntimeException("该互助组不存在");
-		}
-		// 如果互助组被删除则抛异常
-		if (tbGroup.getDeleteStatus() == 1) {
-			throw new RuntimeException("该互助组已被删除");
-		}
-		BeanUtils.copyProperties(tbGroupDto, tbGroup);
-		// 写入更新者id
-		tbGroup.setUpdateBy(loginId);
-		// 更新互助组信息
-		int line = tbGroupMapper.updateById(tbGroup);
-		return line;
-	}
+    public int isLock(TbGroupDto tbGroupDto) {
+        // 获取当前登录用户id
+        Long loginId = StpUserUtil.getLoginIdAsLong();
+        // 获取互助组信息
+        TbGroup tbGroup = tbGroupMapper.selectById(tbGroupDto.getId());
+        // 如果互助组不存在则抛异常
+        if (Objects.isNull(tbGroup)) {
+            throw new RuntimeException("该互助组不存在");
+        }
+        // 如果互助组被删除则抛异常
+        if (tbGroup.getDeleteStatus() == 1) {
+            throw new RuntimeException("该互助组已被删除");
+        }
+        BeanUtils.copyProperties(tbGroupDto, tbGroup);
+        // 写入更新者id
+        tbGroup.setUpdateBy(loginId);
+        // 更新互助组信息
+        int line = tbGroupMapper.updateById(tbGroup);
+        return line;
+    }
 
-	/**
-	 * 根据互助组id查看组内成员
-	 *
-	 * @author loovi
-	 * @date
-	 */
-	public AjaxJson getMemberListByGroupId(Long id) {
-		SoMap so = SoMap.getRequestSoMap();
-		so.set("groupId",id);
-		List<TbPeople> list = tbPeopleMapper.getMemberListByGroupId(so.startPage());
-		return AjaxJson.getPageData(so.getDataCount(), list);
-	}
-	/**
-	 *组长查看互助组内成员
-	 *
-	 * @author loovi
-	 * @date
-	 */
-	public AjaxJson getMemberListByLeaderId(Long id){
-		SoMap so = SoMap.getRequestSoMap();
-		so.set("leaderId",id);
-		List<TbPeople> list = tbPeopleMapper.getMemberListByLeaderId(so.startPage());
-		return AjaxJson.getPageData(so.getDataCount(), list);
-	}
+    /**
+     * 根据互助组id查看组内成员
+     *
+     * @author loovi
+     * @date
+     */
+    public AjaxJson getMemberListByGroupId(Long id) {
+        SoMap so = SoMap.getRequestSoMap();
+        so.set("groupId", id);
+        List<TbPeople> list = tbPeopleService.getMemberListByGroupId(so.startPage());
+        return AjaxJson.getPageData(so.getDataCount(), list);
+    }
 
-	/**
-	 * 导入
-	 *
-	 * @param file excel文件
-	 * @return
-	 * @throws IOException
-	 */
-	public String importData(MultipartFile file) throws IOException {
-		System.out.println("\n开始执行文件上传....\n");
+    /**
+     * 组长查看互助组内成员
+     *
+     * @author loovi
+     * @date
+     */
+    public AjaxJson getMemberListByLeaderId(Long id) {
+        SoMap so = SoMap.getRequestSoMap();
+        so.set("leaderId", id);
+        List<TbPeople> list = tbPeopleService.getMemberListByLeaderId(so.startPage());
+        return AjaxJson.getPageData(so.getDataCount(), list);
+    }
 
-		//判空
-		if (file.isEmpty()) return "文件为空,无法执行上传...";
-		//获取文件上传数据
-		HSSFWorkbook wb = new HSSFWorkbook(file.getInputStream());
-		//获取第一页sheet
-		HSSFSheet sheet = wb.getSheetAt(0);
-		//定义计数器
-		int count = 0;
-		//定义行对象
-		HSSFRow row = null;
-		//解析数据封装到集合
-		count = methodGroupService.importMethod(row, sheet, count);
-		wb.close();
-		System.out.println("\n文件上传完成,共上传 " + count + "条 " + "数据...\n");
-		return "上传完成,共上传" + count + "条" + "数据。";
-	}
+    /**
+     * 导入
+     *
+     * @param file excel文件
+     * @return
+     * @throws IOException
+     */
+    public String importData(MultipartFile file) throws IOException {
+        System.out.println("\n开始执行文件上传....\n");
 
-	/**
-	 * 导出 excel文件
-	 *
-	 * @param keyword
-	 * @return
-	 */
-	public String outportExcel(String keyword, String filepath) throws IOException {
-		System.out.println("\n开始执行文件导出....\n");
-		//导出的文件的路径
-		if (filepath == null || filepath.trim().equals("")) {
-			// 获取当前用户的桌面路径
-			FileSystemView fileSystemView = FileSystemView.getFileSystemView();
-			filepath = fileSystemView.getHomeDirectory().getPath();
-		}
-		filepath = filepath + "\\互助组数据表_" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ".xlsx";
-		//根据需求查询数据
-		List<TbGroup> selectedList = tbGroupMapper.selectList(new LambdaQueryWrapper<TbGroup>().eq(StringUtils.isNoneBlank(keyword), TbGroup::getOrgName, keyword));
-		if (selectedList.size() == 0) return "没有可导出的数据。";
-		//建立excel对象封装数据
-		HSSFWorkbook workbook = new HSSFWorkbook();
-		//创建excel表格右下角的sheet页名称
-		HSSFSheet sheet = workbook.createSheet("1");
-		//创建表头
-		HSSFRow row = sheet.createRow(0);
-		row.createCell(0).setCellValue("序号");
-		row.createCell(1).setCellValue("IDs");
-		row.createCell(2).setCellValue("地址");
-		row.createCell(3).setCellValue("详细地址");
-		row.createCell(4).setCellValue("组名称");
-		row.createCell(5).setCellValue("组长ID");
-		row.createCell(6).setCellValue("组长名");
-		row.createCell(7).setCellValue("组长电话");
-		row.createCell(8).setCellValue("编码");
-		row.createCell(9).setCellValue("当天该组剩余额度");
+        //判空
+        if (file.isEmpty()) return "文件为空,无法执行上传...";
+        //获取文件上传数据
+        HSSFWorkbook wb = new HSSFWorkbook(file.getInputStream());
+        //获取第一页sheet
+        HSSFSheet sheet = wb.getSheetAt(0);
+        //定义计数器
+        int count = 0;
+        //定义行对象
+        HSSFRow row = null;
+        //解析数据封装到集合
+        count = methodGroupService.importMethod(row, sheet, count);
+        wb.close();
+        System.out.println("\n文件上传完成,共上传 " + count + "条 " + "数据...\n");
+        return "上传完成,共上传" + count + "条" + "数据。";
+    }
 
-		row.createCell(14).setCellValue("创建时间");
-		row.createCell(15).setCellValue("创建人编号");
-		row.createCell(16).setCellValue("创建人名称");
-		row.createCell(17).setCellValue("更新时间");
-		row.createCell(18).setCellValue("更新人编号");
-		row.createCell(19).setCellValue("更新人名称");
-		row.createCell(20).setCellValue("删除状态");
+    /**
+     * 导出 excel文件
+     *
+     * @param keyword
+     * @return
+     */
+    public String outportExcel(String keyword, String filepath) throws IOException {
+        System.out.println("\n开始执行文件导出....\n");
+        //导出的文件的路径
+        if (filepath == null || filepath.trim().equals("")) {
+            // 获取当前用户的桌面路径
+            FileSystemView fileSystemView = FileSystemView.getFileSystemView();
+            filepath = fileSystemView.getHomeDirectory().getPath();
+        }
+        filepath = filepath + "\\互助组数据表_" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ".xlsx";
+        //根据需求查询数据
+        List<TbGroup> selectedList = tbGroupMapper.selectList(new LambdaQueryWrapper<TbGroup>().eq(StringUtils.isNoneBlank(keyword), TbGroup::getOrgName, keyword));
+        if (selectedList.size() == 0) return "没有可导出的数据。";
+        //建立excel对象封装数据
+        HSSFWorkbook workbook = new HSSFWorkbook();
+        //创建excel表格右下角的sheet页名称
+        HSSFSheet sheet = workbook.createSheet("1");
+        //创建表头
+        HSSFRow row = sheet.createRow(0);
+        row.createCell(0).setCellValue("序号");
+        row.createCell(1).setCellValue("IDs");
+        row.createCell(2).setCellValue("地址");
+        row.createCell(3).setCellValue("详细地址");
+        row.createCell(4).setCellValue("组名称");
+        row.createCell(5).setCellValue("组长ID");
+        row.createCell(6).setCellValue("组长名");
+        row.createCell(7).setCellValue("组长电话");
+        row.createCell(8).setCellValue("编码");
+        row.createCell(9).setCellValue("当天该组剩余额度");
 
-		//定义计数器
-		int count = 0;
-		//遍历集合
-		for (int i = 0; i < selectedList.size(); i++) {
-			HSSFRow sheetRow = sheet.createRow(sheet.getLastRowNum() + 1);
-			sheetRow.createCell(0).setCellValue(i + 1);
-			sheetRow.createCell(1).setCellValue((selectedList.get(i).getAddressIds() + "").equals("null") ? "" : selectedList.get(i).getAddressIds() + "");
-			sheetRow.createCell(2).setCellValue((selectedList.get(i).getAddress() + "").equals("null") ? "" : selectedList.get(i).getAddress() + "");
-			sheetRow.createCell(3).setCellValue((selectedList.get(i).getDetailAddress() + "").equals("null") ? "" : selectedList.get(i).getDetailAddress() + "");
-			sheetRow.createCell(4).setCellValue((selectedList.get(i).getOrgName() + "").equals("null") ? "" : selectedList.get(i).getOrgName() + "");
-			sheetRow.createCell(5).setCellValue((selectedList.get(i).getLeaderId() + "").equals("null") ? "" : selectedList.get(i).getLeaderId() + "");
-			sheetRow.createCell(6).setCellValue((selectedList.get(i).getLeaderName() + "").equals("null") ? "" : selectedList.get(i).getLeaderName() + "");
-			sheetRow.createCell(7).setCellValue((selectedList.get(i).getLeaderPhone() + "").equals("null") ? "" : selectedList.get(i).getLeaderPhone() + "");
-			sheetRow.createCell(8).setCellValue((selectedList.get(i).getCode() + "").equals("null") ? "" : selectedList.get(i).getCode() + "");
-			sheetRow.createCell(9).setCellValue((selectedList.get(i).getLeftPrice() + "").equals("null") ? "" : selectedList.get(i).getLeftPrice() + "");
+        row.createCell(14).setCellValue("创建时间");
+        row.createCell(15).setCellValue("创建人编号");
+        row.createCell(16).setCellValue("创建人名称");
+        row.createCell(17).setCellValue("更新时间");
+        row.createCell(18).setCellValue("更新人编号");
+        row.createCell(19).setCellValue("更新人名称");
+        row.createCell(20).setCellValue("删除状态");
 
-			//公共字段
-			sheetRow.createCell(22).setCellValue((selectedList.get(i).getCreateTime() + "").equals("null") ? "" : selectedList.get(i).getCreateTime() + "");
-			sheetRow.createCell(23).setCellValue((selectedList.get(i).getCreateBy() + "").equals("null") ? "" : selectedList.get(i).getCreateBy() + "");
-			sheetRow.createCell(24).setCellValue((selectedList.get(i).getCreateName() + "").equals("null") ? "" : selectedList.get(i).getCreateName() + "");
-			sheetRow.createCell(25).setCellValue((selectedList.get(i).getUpdateTime() + "").equals("null") ? "" : selectedList.get(i).getUpdateTime() + "");
-			sheetRow.createCell(26).setCellValue((selectedList.get(i).getUpdateBy() + "").equals("null") ? "" : selectedList.get(i).getUpdateBy() + "");
-			sheetRow.createCell(27).setCellValue((selectedList.get(i).getUpdateName() + "").equals("null") ? "" : selectedList.get(i).getUpdateName() + "");
-			sheetRow.createCell(28).setCellValue((selectedList.get(i).getDeleteStatus() + "").equals("null") ? "" : selectedList.get(i).getDeleteStatus() + "");
-			count += 1;
-		}
-		//建立输出流,输出文件
-		FileOutputStream fos = new FileOutputStream(filepath);
+        //定义计数器
+        int count = 0;
+        //遍历集合
+        for (int i = 0; i < selectedList.size(); i++) {
+            HSSFRow sheetRow = sheet.createRow(sheet.getLastRowNum() + 1);
+            sheetRow.createCell(0).setCellValue(i + 1);
+            sheetRow.createCell(1).setCellValue((selectedList.get(i).getAddressIds() + "").equals("null") ? "" : selectedList.get(i).getAddressIds() + "");
+            sheetRow.createCell(2).setCellValue((selectedList.get(i).getAddress() + "").equals("null") ? "" : selectedList.get(i).getAddress() + "");
+            sheetRow.createCell(3).setCellValue((selectedList.get(i).getDetailAddress() + "").equals("null") ? "" : selectedList.get(i).getDetailAddress() + "");
+            sheetRow.createCell(4).setCellValue((selectedList.get(i).getOrgName() + "").equals("null") ? "" : selectedList.get(i).getOrgName() + "");
+            sheetRow.createCell(5).setCellValue((selectedList.get(i).getLeaderId() + "").equals("null") ? "" : selectedList.get(i).getLeaderId() + "");
+            sheetRow.createCell(6).setCellValue((selectedList.get(i).getLeaderName() + "").equals("null") ? "" : selectedList.get(i).getLeaderName() + "");
+            sheetRow.createCell(7).setCellValue((selectedList.get(i).getLeaderPhone() + "").equals("null") ? "" : selectedList.get(i).getLeaderPhone() + "");
+            sheetRow.createCell(8).setCellValue((selectedList.get(i).getCode() + "").equals("null") ? "" : selectedList.get(i).getCode() + "");
+            sheetRow.createCell(9).setCellValue((selectedList.get(i).getLeftPrice() + "").equals("null") ? "" : selectedList.get(i).getLeftPrice() + "");
 
-		workbook.write(fos);
-		fos.flush();
-		//关闭输出流
-		fos.close();
-		workbook.close();
-		System.out.println("\n数据导出完成!共导出 " + count + " 条数据。");
-		return "数据导出完成!共导出 " + count + " 条数据。";
-	}
+            //公共字段
+            sheetRow.createCell(22).setCellValue((selectedList.get(i).getCreateTime() + "").equals("null") ? "" : selectedList.get(i).getCreateTime() + "");
+            sheetRow.createCell(23).setCellValue((selectedList.get(i).getCreateBy() + "").equals("null") ? "" : selectedList.get(i).getCreateBy() + "");
+            sheetRow.createCell(24).setCellValue((selectedList.get(i).getCreateName() + "").equals("null") ? "" : selectedList.get(i).getCreateName() + "");
+            sheetRow.createCell(25).setCellValue((selectedList.get(i).getUpdateTime() + "").equals("null") ? "" : selectedList.get(i).getUpdateTime() + "");
+            sheetRow.createCell(26).setCellValue((selectedList.get(i).getUpdateBy() + "").equals("null") ? "" : selectedList.get(i).getUpdateBy() + "");
+            sheetRow.createCell(27).setCellValue((selectedList.get(i).getUpdateName() + "").equals("null") ? "" : selectedList.get(i).getUpdateName() + "");
+            sheetRow.createCell(28).setCellValue((selectedList.get(i).getDeleteStatus() + "").equals("null") ? "" : selectedList.get(i).getDeleteStatus() + "");
+            count += 1;
+        }
+        //建立输出流,输出文件
+        FileOutputStream fos = new FileOutputStream(filepath);
 
-	/** 远程调用方法 */
-	public boolean groupDto(GroupDto groupDto){
-		TbGroup tbGroup = new TbGroup();
-		BeanUtils.copyProperties(groupDto,tbGroup);
-		//根据编号进行事务处理
-		List<TbGroup> tbGroupList = tbGroupMapper.selectList(new LambdaQueryWrapper<TbGroup>().eq(TbGroup::getPlatSeqNo, groupDto.getPlatSeqNo()));
-		if(tbGroupList.size() == 0){
-			//新增
-			tbGroup.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode());
-			tbGroup.setCreateTime(new Date());
-			boolean save = this.save(tbGroup);
-			return save;
-		}
-		//修改
-		BeanUtils.copyProperties(tbGroupList.get(0),tbGroup);
-		int i = tbGroupMapper.updateById(tbGroup);
-		return i == 1;
-	}
+        workbook.write(fos);
+        fos.flush();
+        //关闭输出流
+        fos.close();
+        workbook.close();
+        System.out.println("\n数据导出完成!共导出 " + count + " 条数据。");
+        return "数据导出完成!共导出 " + count + " 条数据。";
+    }
 
-	/** 远程调用方法 获取边民组的基本信息*/
-	GroupDto getRpcById(String id) {
-		TbGroup byId = super.getById(id);
-		GroupDto groupDto = new GroupDto();
-		BeanUtils.copyProperties(byId,groupDto);
-		return groupDto;
-	}
+    /**
+     * 远程调用方法
+     */
+    public boolean groupDto(GroupDto groupDto) {
+        TbTradeArea tbTradeArea = tbTradeAreaService.updateHandler(groupDto.getFieldCode(), "");
+        TbGroup tbGroup = new TbGroup();
+        BeanUtils.copyProperties(groupDto, tbGroup);
+        //根据编号进行事务处理
+        List<TbGroup> tbGroupList = tbGroupMapper.selectList(new LambdaQueryWrapper<TbGroup>().eq(TbGroup::getPlatSeqNo, groupDto.getPlatSeqNo()));
+        if (tbGroupList.size() == 0) {
+            //新增
+            tbGroup.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode());
+            tbGroup.setCreateTime(new Date()).setTradeAreaId(tbTradeArea.getId()).setTradeAreaName(tbTradeArea.getName());
+         this.save(tbGroup);
+        }
+        List<BorderDTO> borderDTOList = JSONUtil.toList(groupDto.getBorderList(), BorderDTO.class);
+        borderDTOList.forEach(borderDTO -> {
+            TbPeople tbPeople = tbPeopleService.findByIdCarNo(borderDTO.getCiphertextIdno());
+            if (tbPeople==null){
+                tbPeople=new TbPeople();
+            }
+            //todo 继续同步边民信息
+        });
+        //修改
+        BeanUtils.copyProperties(tbGroupList.get(0), tbGroup);
+        int i = tbGroupMapper.updateById(tbGroup);
+        return i == 1;
+    }
+
+    /**
+     * 远程调用方法 获取边民组的基本信息
+     */
+    GroupDto getRpcById(String id) {
+        TbGroup byId = super.getById(id);
+        GroupDto groupDto = new GroupDto();
+        BeanUtils.copyProperties(byId, groupDto);
+        return groupDto;
+    }
 
 }
 

+ 14 - 0
sp-service/level-one-server/src/main/java/com/pj/tb_people/TbPeopleService.java

@@ -611,4 +611,18 @@ public class TbPeopleService extends ServiceImpl<TbPeopleMapper, TbPeople> imple
 		return null;
 	}
 
+	public List<TbPeople> getMemberListByGroupId(SoMap startPage) {
+		return tbPeopleMapper.getMemberListByGroupId(startPage);
+	}
+
+	public List<TbPeople> getMemberListByLeaderId(SoMap startPage) {
+		return tbPeopleMapper.getMemberListByLeaderId(startPage);
+	}
+
+	public TbPeople findByIdCarNo(String idNo) {
+		QueryWrapper<TbPeople>ew=new QueryWrapper<>();
+		ew.lambda().eq(TbPeople::getIdCardNo,idNo);
+		List<TbPeople>list=list(ew);
+		return list.isEmpty()?null:list.get(0);
+	}
 }

+ 241 - 210
sp-service/level-one-server/src/main/java/com/pj/tb_shop/TbShopService.java

@@ -17,6 +17,8 @@ import com.pj.enummj.*;
 import com.pj.project4sp.SP;
 import com.pj.tb_enterprise.TbEnterprise;
 import com.pj.tb_enterprise.TbEnterpriseMapper;
+import com.pj.tb_trade_area.TbTradeArea;
+import com.pj.tb_trade_area.TbTradeAreaService;
 import com.pj.utils.so.SoMap;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.hssf.usermodel.HSSFRow;
@@ -31,245 +33,274 @@ import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.annotation.Resource;
 import javax.swing.filechooser.FileSystemView;
 
 /**
  * Service: tb_shop -- 铺位
- * @author qzy 
+ *
+ * @author qzy
  */
 @Service
 @Transactional(rollbackFor = Exception.class)
-public class TbShopService extends ServiceImpl<TbShopMapper, TbShop> implements IService<TbShop>{
+public class TbShopService extends ServiceImpl<TbShopMapper, TbShop> implements IService<TbShop> {
 
-	/** 底层 Mapper 对象 */
-	@Autowired
-	TbShopMapper tbShopMapper;
+    /**
+     * 底层 Mapper 对象
+     */
+    @Autowired
+    TbShopMapper tbShopMapper;
 
-	@Autowired
-	private MethodShopService methodShopService;
+    @Autowired
+    private MethodShopService methodShopService;
 
-	@Autowired
-	private TbEnterpriseMapper tbEnterpriseMapper;
+    @Autowired
+    private TbEnterpriseMapper tbEnterpriseMapper;
 
-	@Autowired
-	private AdminInterface adminInterface;
+    @Autowired
+    private AdminInterface adminInterface;
+    @Resource
+    private TbTradeAreaService tbTradeAreaService;
 
-	/** 增 */
-	void add(TbShop t){
-		save(t);
-	}
+    /**
+     * 增
+     */
+    void add(TbShop t) {
+        save(t);
+    }
 
-	/** 删 */
-	void delete(Long id){
-		removeById(id);
-	}
+    /**
+     * 删
+     */
+    void delete(Long id) {
+        removeById(id);
+    }
 
-	/** 改 */
-	void update(TbShop t){
-		updateById(t);
+    /**
+     * 改
+     */
+    void update(TbShop t) {
+        updateById(t);
 
-	}
+    }
 
-	/** 查 */
-	TbShop getById(String id){
-		return super.getById(id);
-	}
+    /**
+     * 查
+     */
+    TbShop getById(String id) {
+        return super.getById(id);
+    }
 
-	/** 查集合 - 根据条件(参数为空时代表忽略指定条件) */  
-	List<TbShop> getList(SoMap so) { 
-		return tbShopMapper.getList(so);	
-	}
+    /**
+     * 查集合 - 根据条件(参数为空时代表忽略指定条件)
+     */
+    List<TbShop> getList(SoMap so) {
+        return tbShopMapper.getList(so);
+    }
 
 
-	/**
-	 * 导入
-	 * @param file excel文件
-	 * @return
-	 * @throws IOException
-	 */
-	public String importData(MultipartFile file) throws IOException {
-		System.out.println("\n开始执行文件上传....\n");
+    /**
+     * 导入
+     *
+     * @param file excel文件
+     * @return
+     * @throws IOException
+     */
+    public String importData(MultipartFile file) throws IOException {
+        System.out.println("\n开始执行文件上传....\n");
 
-		//判空
-		if(file.isEmpty()) return "文件为空,无法执行上传...";
-		//获取文件上传数据
-		HSSFWorkbook wb = new HSSFWorkbook(file.getInputStream());
-		//获取第一页sheet
-		HSSFSheet sheet = wb.getSheetAt(0);
-		//定义计数器
-		int count = 0;
-		//定义行对象
-		HSSFRow row = null;
-		//解析数据封装到集合
-		count = methodShopService.importMethod(row, sheet, count);
-		wb.close();
-		System.out.println("\n文件上传完成,共上传 " + count + "条 " + "数据...\n");
-		return "上传完成,共上传"  + count + "条"  + "数据。";
-	}
+        //判空
+        if (file.isEmpty()) return "文件为空,无法执行上传...";
+        //获取文件上传数据
+        HSSFWorkbook wb = new HSSFWorkbook(file.getInputStream());
+        //获取第一页sheet
+        HSSFSheet sheet = wb.getSheetAt(0);
+        //定义计数器
+        int count = 0;
+        //定义行对象
+        HSSFRow row = null;
+        //解析数据封装到集合
+        count = methodShopService.importMethod(row, sheet, count);
+        wb.close();
+        System.out.println("\n文件上传完成,共上传 " + count + "条 " + "数据...\n");
+        return "上传完成,共上传" + count + "条" + "数据。";
+    }
 
-	/**
-	 * 导出 excel文件
-	 * @param keyword
-	 * @return
-	 */
-	public String outportExcel(String keyword,String filepath) throws IOException {
-		System.out.println("\n开始执行文件导出....\n");
-		//导出的文件的路径
-		if(filepath == null || filepath.trim().equals("")){
-			// 获取当前用户的桌面路径
-			FileSystemView fileSystemView = FileSystemView.getFileSystemView();
-			filepath = fileSystemView.getHomeDirectory().getPath();
-		}
-		filepath = filepath + "\\铺位数据表_" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ".xlsx";
-		//根据需求查询数据
-		List<TbShop> selectedList = tbShopMapper.selectList(new LambdaQueryWrapper<TbShop>().eq(StringUtils.isNoneBlank(keyword), TbShop::getShopName, keyword));
-		if(selectedList.size() == 0)return "没有可导出的数据。";
-		//建立excel对象封装数据
-		HSSFWorkbook workbook = new HSSFWorkbook();
-		//创建excel表格右下角的sheet页名称
-		HSSFSheet sheet = workbook.createSheet("1");
-		//创建表头
-		HSSFRow row = sheet.createRow(0);
-		row.createCell(0).setCellValue("序号");
-		row.createCell(1).setCellValue("enterprise_id");
-		row.createCell(2).setCellValue("交易地区ID");
-		row.createCell(3).setCellValue("交易地区名称");
-		row.createCell(4).setCellValue("地址");
-		row.createCell(5).setCellValue("地址ID");
-		row.createCell(6).setCellValue("名称");
-		row.createCell(7).setCellValue("编号");
-		row.createCell(8).setCellValue("区域");
-		row.createCell(9).setCellValue("是否可用");
-		row.createCell(10).setCellValue("备注");
-		row.createCell(11).setCellValue("enterprise_name");
+    /**
+     * 导出 excel文件
+     *
+     * @param keyword
+     * @return
+     */
+    public String outportExcel(String keyword, String filepath) throws IOException {
+        System.out.println("\n开始执行文件导出....\n");
+        //导出的文件的路径
+        if (filepath == null || filepath.trim().equals("")) {
+            // 获取当前用户的桌面路径
+            FileSystemView fileSystemView = FileSystemView.getFileSystemView();
+            filepath = fileSystemView.getHomeDirectory().getPath();
+        }
+        filepath = filepath + "\\铺位数据表_" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ".xlsx";
+        //根据需求查询数据
+        List<TbShop> selectedList = tbShopMapper.selectList(new LambdaQueryWrapper<TbShop>().eq(StringUtils.isNoneBlank(keyword), TbShop::getShopName, keyword));
+        if (selectedList.size() == 0) return "没有可导出的数据。";
+        //建立excel对象封装数据
+        HSSFWorkbook workbook = new HSSFWorkbook();
+        //创建excel表格右下角的sheet页名称
+        HSSFSheet sheet = workbook.createSheet("1");
+        //创建表头
+        HSSFRow row = sheet.createRow(0);
+        row.createCell(0).setCellValue("序号");
+        row.createCell(1).setCellValue("enterprise_id");
+        row.createCell(2).setCellValue("交易地区ID");
+        row.createCell(3).setCellValue("交易地区名称");
+        row.createCell(4).setCellValue("地址");
+        row.createCell(5).setCellValue("地址ID");
+        row.createCell(6).setCellValue("名称");
+        row.createCell(7).setCellValue("编号");
+        row.createCell(8).setCellValue("区域");
+        row.createCell(9).setCellValue("是否可用");
+        row.createCell(10).setCellValue("备注");
+        row.createCell(11).setCellValue("enterprise_name");
 
-		row.createCell(28).setCellValue("创建时间");
-		row.createCell(29).setCellValue("创建人编号");
-		row.createCell(30).setCellValue("创建人名称");
-		row.createCell(31).setCellValue("更新时间");
-		row.createCell(32).setCellValue("更新人编号");
-		row.createCell(33).setCellValue("更新人名称");
-		row.createCell(34).setCellValue("删除状态");
+        row.createCell(28).setCellValue("创建时间");
+        row.createCell(29).setCellValue("创建人编号");
+        row.createCell(30).setCellValue("创建人名称");
+        row.createCell(31).setCellValue("更新时间");
+        row.createCell(32).setCellValue("更新人编号");
+        row.createCell(33).setCellValue("更新人名称");
+        row.createCell(34).setCellValue("删除状态");
 
-		//定义计数器
-		int count = 0;
-		//遍历集合
-		for (int i = 0; i < selectedList.size(); i++) {
-			HSSFRow sheetRow = sheet.createRow(sheet.getLastRowNum() + 1);
-			sheetRow.createCell(0).setCellValue(i + 1);
-			sheetRow.createCell(1).setCellValue((selectedList.get(i).getEnterpriseId() + "").equals("null")? "": selectedList.get(i).getEnterpriseId() + "");
-			sheetRow.createCell(2).setCellValue((selectedList.get(i).getTradeAreaId() + "").equals("null")? "": selectedList.get(i).getTradeAreaId() + "");
-			sheetRow.createCell(3).setCellValue((selectedList.get(i).getTradeAreaName() + "").equals("null")? "": selectedList.get(i).getTradeAreaName() + "");
-			sheetRow.createCell(4).setCellValue((selectedList.get(i).getAddress() + "").equals("null")? "": selectedList.get(i).getAddress() + "");
-			sheetRow.createCell(5).setCellValue((selectedList.get(i).getAddressIds() + "").equals("null")? "": selectedList.get(i).getAddressIds() + "");
-			sheetRow.createCell(6).setCellValue((selectedList.get(i).getShopName() + "").equals("null")? "": selectedList.get(i).getShopName() + "");
-			sheetRow.createCell(7).setCellValue((selectedList.get(i).getShopNo() + "").equals("null")? "": selectedList.get(i).getShopNo() + "");
-			sheetRow.createCell(8).setCellValue((selectedList.get(i).getArea() + "" ).equals("null")? "": selectedList.get(i).getArea() + "");
-			sheetRow.createCell(9).setCellValue((selectedList.get(i).getStatus() + "").equals("null")? "": selectedList.get(i).getStatus() + "");
-			sheetRow.createCell(10).setCellValue((selectedList.get(i).getRemark() + "").equals("null")? "": selectedList.get(i).getRemark() + "");
-			sheetRow.createCell(11).setCellValue((selectedList.get(i).getEnterpriseName() + "").equals("null")? "": selectedList.get(i).getEnterpriseName() + "");
-			//公共字段
-			sheetRow.createCell(12).setCellValue((selectedList.get(i).getCreateTime() + "").equals("null")? "": selectedList.get(i).getCreateTime() + "");
-			sheetRow.createCell(13).setCellValue((selectedList.get(i).getCreateBy() + "").equals("null")? "": selectedList.get(i).getCreateBy() + "");
-			sheetRow.createCell(14).setCellValue((selectedList.get(i).getCreateName() + "").equals("null")? "": selectedList.get(i).getCreateName() + "");
-			sheetRow.createCell(15).setCellValue((selectedList.get(i).getUpdateTime() + "").equals("null")? "": selectedList.get(i).getUpdateTime() + "");
-			sheetRow.createCell(16).setCellValue((selectedList.get(i).getUpdateBy() + "").equals("null")? "": selectedList.get(i).getUpdateBy() + "");
-			sheetRow.createCell(17).setCellValue((selectedList.get(i).getUpdateName() + "").equals("null")? "": selectedList.get(i).getUpdateName() + "");
-			sheetRow.createCell(18).setCellValue((selectedList.get(i).getDeleteStatus() + "").equals("null")? "": selectedList.get(i).getDeleteStatus() + "");
-			count += 1;
-		}
-		//建立输出流,输出文件
-		FileOutputStream fos = new FileOutputStream(filepath);
+        //定义计数器
+        int count = 0;
+        //遍历集合
+        for (int i = 0; i < selectedList.size(); i++) {
+            HSSFRow sheetRow = sheet.createRow(sheet.getLastRowNum() + 1);
+            sheetRow.createCell(0).setCellValue(i + 1);
+            sheetRow.createCell(1).setCellValue((selectedList.get(i).getEnterpriseId() + "").equals("null") ? "" : selectedList.get(i).getEnterpriseId() + "");
+            sheetRow.createCell(2).setCellValue((selectedList.get(i).getTradeAreaId() + "").equals("null") ? "" : selectedList.get(i).getTradeAreaId() + "");
+            sheetRow.createCell(3).setCellValue((selectedList.get(i).getTradeAreaName() + "").equals("null") ? "" : selectedList.get(i).getTradeAreaName() + "");
+            sheetRow.createCell(4).setCellValue((selectedList.get(i).getAddress() + "").equals("null") ? "" : selectedList.get(i).getAddress() + "");
+            sheetRow.createCell(5).setCellValue((selectedList.get(i).getAddressIds() + "").equals("null") ? "" : selectedList.get(i).getAddressIds() + "");
+            sheetRow.createCell(6).setCellValue((selectedList.get(i).getShopName() + "").equals("null") ? "" : selectedList.get(i).getShopName() + "");
+            sheetRow.createCell(7).setCellValue((selectedList.get(i).getShopNo() + "").equals("null") ? "" : selectedList.get(i).getShopNo() + "");
+            sheetRow.createCell(8).setCellValue((selectedList.get(i).getArea() + "").equals("null") ? "" : selectedList.get(i).getArea() + "");
+            sheetRow.createCell(9).setCellValue((selectedList.get(i).getStatus() + "").equals("null") ? "" : selectedList.get(i).getStatus() + "");
+            sheetRow.createCell(10).setCellValue((selectedList.get(i).getRemark() + "").equals("null") ? "" : selectedList.get(i).getRemark() + "");
+            sheetRow.createCell(11).setCellValue((selectedList.get(i).getEnterpriseName() + "").equals("null") ? "" : selectedList.get(i).getEnterpriseName() + "");
+            //公共字段
+            sheetRow.createCell(12).setCellValue((selectedList.get(i).getCreateTime() + "").equals("null") ? "" : selectedList.get(i).getCreateTime() + "");
+            sheetRow.createCell(13).setCellValue((selectedList.get(i).getCreateBy() + "").equals("null") ? "" : selectedList.get(i).getCreateBy() + "");
+            sheetRow.createCell(14).setCellValue((selectedList.get(i).getCreateName() + "").equals("null") ? "" : selectedList.get(i).getCreateName() + "");
+            sheetRow.createCell(15).setCellValue((selectedList.get(i).getUpdateTime() + "").equals("null") ? "" : selectedList.get(i).getUpdateTime() + "");
+            sheetRow.createCell(16).setCellValue((selectedList.get(i).getUpdateBy() + "").equals("null") ? "" : selectedList.get(i).getUpdateBy() + "");
+            sheetRow.createCell(17).setCellValue((selectedList.get(i).getUpdateName() + "").equals("null") ? "" : selectedList.get(i).getUpdateName() + "");
+            sheetRow.createCell(18).setCellValue((selectedList.get(i).getDeleteStatus() + "").equals("null") ? "" : selectedList.get(i).getDeleteStatus() + "");
+            count += 1;
+        }
+        //建立输出流,输出文件
+        FileOutputStream fos = new FileOutputStream(filepath);
 
-		workbook.write(fos);
-		fos.flush();
-		//关闭输出流
-		fos.close();
-		workbook.close();
-		System.out.println("\n数据导出完成!共导出 " + count + " 条数据。");
-		return "数据导出完成!共导出 " + count + " 条数据。";
-	}
+        workbook.write(fos);
+        fos.flush();
+        //关闭输出流
+        fos.close();
+        workbook.close();
+        System.out.println("\n数据导出完成!共导出 " + count + " 条数据。");
+        return "数据导出完成!共导出 " + count + " 条数据。";
+    }
 
-	/** 远程调用方法 */
-	public boolean shopDto(ShopDto shopDto) throws Exception {
-		TbShop tbShop = new TbShop();
-		BeanUtils.copyProperties(shopDto,tbShop);
-		//根据编号进行事务处理
-		List<TbShop> tbShopList = tbShopMapper.selectList(new LambdaQueryWrapper<TbShop>().eq(TbShop::getPlatSeqNo, shopDto.getPlatSeqNo()));
-		if(tbShopList.size() == 0){
-			//去重
-			List<TbShop> tbShops = tbShopMapper.selectList(new LambdaQueryWrapper<TbShop>().eq(TbShop::getPlatSeqNo, shopDto.getPlatSeqNo()));
-			if(tbShops.size() != 0)throw new ServiceException("\n该店铺已存在。platSeqNo = " + shopDto.getPlatSeqNo() + "\n");
-			//无则新增商铺
-			tbShop.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode()); // 默认可用
-			tbShop.setCreateTime(new Date()); // 创建时间
-			tbShop.setCreateName("航通"); // 创建人
-			tbShop.setStatus(Status.STATUS_ONE.getCode()); // 可用状态
-			int insert = tbShopMapper.insert(tbShop);
-			long primarykey = SP.publicMapper.getPrimarykey();
-			//新增外籍商户
-			if(insert == 1){
-				//去重
-				List<TbEnterprise> tbEnterpriseList = tbEnterpriseMapper.selectList(new LambdaQueryWrapper<TbEnterprise>().eq(TbEnterprise::getPlatSeqNo, shopDto.getPlatSeqNo()));
-				if(tbEnterpriseList.size() != 0)throw new ServiceException("\n该外籍商户信息已存在。 platSeqNo = " + shopDto.getPlatSeqNo() + "\n");
-				TbEnterprise enterprise = new TbEnterprise();
-				BeanUtils.copyProperties(tbShop,enterprise);
-				//设置基本属性
-				enterprise.setOwnerName(shopDto.getOwnerName()); // 个人姓名
-				enterprise.setDeleteStatus(Long.valueOf(DeleteStatus.DELETE_STATUS_ON.getCode())); // 逻辑删除,默认未删除
-				enterprise.setJudgeStatus(JudgeStatus.JUDGE_STATUS_ONE.getCode());  // 审核状态,默认审核通过
-				enterprise.setJudgeTime(new Date()); // 审核时间
-				enterprise.setShopId(primarykey); // 关联自己旗下的店铺  店铺ID
-				enterprise.setShopName(shopDto.getShopName()); // 店铺ID
-				enterprise.setBankAccount(shopDto.getBankAccount()); // 银行账户
-				enterprise.setBank(shopDto.getBank()); // 银行名称
-				enterprise.setAddress(shopDto.getAddress()); // 地址
-				enterprise.setType(null);  //  商户分类(自营商铺=自营商铺,劳务商铺=劳务商铺)
-				enterprise.setIsLock(IsLock.IS_LOCK_ON.getCode()); // 默认未被锁定
-				//保存
-				int insert1 = tbEnterpriseMapper.insert(enterprise);
-				if(insert1 == 1){
-					//创建商家保存对象
-					EnterpriseDto enterpriseDto = new EnterpriseDto();
-					//查询数据库内的商家
-					List<TbEnterprise> tbEnterprises = tbEnterpriseMapper.selectList(new LambdaQueryWrapper<TbEnterprise>().eq(TbEnterprise::getPlatSeqNo, enterprise.getPlatSeqNo()));
-					//将数据拷贝至enterpriseDto
-					BeanUtils.copyProperties(tbEnterprises.get(0),enterpriseDto);
-					//远程调用生成商家账户方法
-					int i = 1;
-					i = adminInterface.generateEnterpriseAccount(enterpriseDto);
+    /**
+     * 远程调用方法
+     */
+    public boolean shopDto(ShopDto shopDto) throws Exception {
+        String tradeCode = shopDto.getFieldCode();
+       TbTradeArea tbTradeArea= tbTradeAreaService.updateHandler(tradeCode,shopDto.getFieldName());
+        TbShop tbShop = new TbShop();
+        BeanUtils.copyProperties(shopDto, tbShop);
+        //根据编号进行事务处理
+        List<TbShop> tbShopList = tbShopMapper.selectList(new LambdaQueryWrapper<TbShop>().eq(TbShop::getPlatSeqNo, shopDto.getPlatSeqNo()));
+        if (tbShopList.size() == 0) {
+            //去重
+            List<TbShop> tbShops = tbShopMapper.selectList(new LambdaQueryWrapper<TbShop>().eq(TbShop::getPlatSeqNo, shopDto.getPlatSeqNo()));
+            if (tbShops.size() != 0)
+                throw new ServiceException("\n该店铺已存在。platSeqNo = " + shopDto.getPlatSeqNo() + "\n");
+            //无则新增商铺
+            tbShop.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode()); // 默认可用
+            tbShop.setCreateTime(new Date())
+                    .setTradeAreaId(tbTradeArea.getId())
+                    .setTradeAreaName(tbTradeArea.getName()); // 创建时间
+            tbShop.setCreateName("航通"); // 创建人
+            tbShop.setStatus(Status.STATUS_ONE.getCode()); // 可用状态
+            int insert = tbShopMapper.insert(tbShop);
+            long primarykey = SP.publicMapper.getPrimarykey();
+            //新增外籍商户
+            if (insert == 1) {
+                //去重
+                List<TbEnterprise> tbEnterpriseList = tbEnterpriseMapper.selectList(new LambdaQueryWrapper<TbEnterprise>().eq(TbEnterprise::getPlatSeqNo, shopDto.getPlatSeqNo()));
+                if (tbEnterpriseList.size() != 0)
+                    throw new ServiceException("\n该外籍商户信息已存在。 platSeqNo = " + shopDto.getPlatSeqNo() + "\n");
+                TbEnterprise enterprise = new TbEnterprise();
+                BeanUtils.copyProperties(tbShop, enterprise);
+                //设置基本属性
+                enterprise.setOwnerName(shopDto.getOwnerName()); // 个人姓名
+                enterprise.setDeleteStatus(Long.valueOf(DeleteStatus.DELETE_STATUS_ON.getCode())); // 逻辑删除,默认未删除
+                enterprise.setJudgeStatus(JudgeStatus.JUDGE_STATUS_ONE.getCode());  // 审核状态,默认审核通过
+                enterprise.setJudgeTime(new Date()); // 审核时间
+                enterprise.setShopId(primarykey); // 关联自己旗下的店铺  店铺ID
+                enterprise.setShopName(shopDto.getShopName()); // 店铺ID
+                enterprise.setBankAccount(shopDto.getBankAccount()); // 银行账户
+                enterprise.setBank(shopDto.getBank()); // 银行名称
+                enterprise.setAddress(shopDto.getAddress()); // 地址
+                enterprise.setType(null);  //  商户分类(自营商铺=自营商铺,劳务商铺=劳务商铺)
+                enterprise.setIsLock(IsLock.IS_LOCK_ON.getCode()); // 默认未被锁定
+                enterprise.setTradeAreaId(tbTradeArea.getId()).setTradeAreaName(tbTradeArea.getName());
+                //保存
+                int insert1 = tbEnterpriseMapper.insert(enterprise);
+                if (insert1 == 1) {
+                    //创建商家保存对象
+                    EnterpriseDto enterpriseDto = new EnterpriseDto();
+                    //查询数据库内的商家
+                    List<TbEnterprise> tbEnterprises = tbEnterpriseMapper.selectList(new LambdaQueryWrapper<TbEnterprise>().eq(TbEnterprise::getPlatSeqNo, enterprise.getPlatSeqNo()));
+                    //将数据拷贝至enterpriseDto
+                    BeanUtils.copyProperties(tbEnterprises.get(0), enterpriseDto);
+                    //远程调用生成商家账户方法
+                    int i = 1;
+                    i = adminInterface.generateEnterpriseAccount(enterpriseDto);
 
-					if(i != 1)
-						throw new RuntimeException("\n添加商铺时,保存店铺内的外籍商户信息错误。 id = " + tbEnterprises.get(0).getId() + "\n");
-					return true;
-				}
-			}
-		}
-		//修改
-		// todo: 现在同步生成外籍商户信息和appUser信息,当商铺电话发生修改时,对应的外籍商户电话和appUser账号同步修改???
-		BeanUtils.copyProperties(tbShopList.get(0),tbShop);
-		BeanUtils.copyProperties(shopDto,tbShop);
-		int i = tbShopMapper.updateById(tbShop);
-		return i == 1;
-	}
+                    if (i != 1)
+                        throw new RuntimeException("\n添加商铺时,保存店铺内的外籍商户信息错误。 id = " + tbEnterprises.get(0).getId() + "\n");
+                    return true;
+                }
+            }
+        }
+        //修改
+        // todo: 现在同步生成外籍商户信息和appUser信息,当商铺电话发生修改时,对应的外籍商户电话和appUser账号同步修改???
+        BeanUtils.copyProperties(tbShopList.get(0), tbShop);
+        BeanUtils.copyProperties(shopDto, tbShop);
+        int i = tbShopMapper.updateById(tbShop);
+        return i == 1;
+    }
 
-	/** 远程调用: 根据电话查询商铺 */
-	public List<ShopDto> getShopDtoListByPhone(String phone){
-		List<TbShop> tbShopList = tbShopMapper.selectList(new LambdaQueryWrapper<TbShop>()
-				.eq(TbShop::getOwnerTel, phone)
+    /**
+     * 远程调用: 根据电话查询商铺
+     */
+    public List<ShopDto> getShopDtoListByPhone(String phone) {
+        List<TbShop> tbShopList = tbShopMapper.selectList(new LambdaQueryWrapper<TbShop>()
+                        .eq(TbShop::getOwnerTel, phone)
 //				.eq(TbShop::getStatus, Status.STATUS_ONE.getCode())
 //				.eq(TbShop::getDeleteStatus,DeleteStatus.DELETE_STATUS_ON.getCode())
 //				.eq(TbShop::getEDStatus, HtDeleteStatus.DELETE_STATUS_ONE.getCode())
-		);
-		List<ShopDto> result = new ArrayList<>();
-		if(tbShopList.size() > 0){
-			tbShopList.forEach(item -> {
-				ShopDto shopDto = new ShopDto();
-				BeanUtils.copyProperties(item,shopDto);
-				result.add(shopDto);
-			});
-		}
-		return result;
-	}
+        );
+        List<ShopDto> result = new ArrayList<>();
+        if (tbShopList.size() > 0) {
+            tbShopList.forEach(item -> {
+                ShopDto shopDto = new ShopDto();
+                BeanUtils.copyProperties(item, shopDto);
+                result.add(shopDto);
+            });
+        }
+        return result;
+    }
 
 }

+ 1 - 0
sp-service/level-one-server/src/main/java/com/pj/tb_trade_area/TbTradeArea.java

@@ -79,6 +79,7 @@ public class TbTradeArea extends Model<TbTradeArea> implements Serializable {
 	 * 创建者id 
 	 */
 	private String createBy;	
+	private String code;
 
 	/**
 	 * 创建者名称 

+ 236 - 198
sp-service/level-one-server/src/main/java/com/pj/tb_trade_area/TbTradeAreaService.java

@@ -7,7 +7,9 @@ import java.time.format.DateTimeFormatter;
 import java.util.*;
 import java.util.stream.Collectors;
 
+import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.pj.api.consts.FeignFactory;
 import com.pj.api.dto.DistrictDTO;
 import com.pj.current.satoken.StpUserUtil;
@@ -31,208 +33,244 @@ import javax.swing.filechooser.FileSystemView;
 
 /**
  * Service: tb_trade_area -- 贸易区域
- * @author qzy 
+ *
+ * @author qzy
  */
 @Service
 @Transactional(rollbackFor = Exception.class)
-public class TbTradeAreaService extends ServiceImpl<TbTradeAreaMapper, TbTradeArea> implements IService<TbTradeArea>{
-
-	/** 底层 Mapper 对象 */
-	@Autowired
-	TbTradeAreaMapper tbTradeAreaMapper;
-	@Autowired
-	TbGoodsMapper tbGoodsMapper;
-	@Autowired
-	private MethodTradeAreaService methodTradeAreaService;
-
-	/** 增 */
-	void add(TbTradeArea t){
-		List<DistrictDTO>districtDTOS= FeignFactory.adminInterface.getDistrictList(t.getAddressIds());
-		t.setAddress(districtDTOS.stream().map(DistrictDTO::getDistrict).collect(Collectors.joining()))
-				.setCreateTime(new Date()).setCreateName(StpUserUtil.getPCLoginInfo().getLoginName());
-		save(t);
-	}
-
-	/** 删 */
-	void delete(Long id){
-		removeById(id);
-	}
-
-	/** 改 */
-	void update(TbTradeArea t){
-		List<DistrictDTO>districtDTOS= FeignFactory.adminInterface.getDistrictList(t.getAddressIds());
-		t.setAddress(districtDTOS.stream().map(DistrictDTO::getDistrict).collect(Collectors.joining()))
-				.setUpdateTime(new Date()).setUpdateName(StpUserUtil.getPCLoginInfo().getLoginName());
-		updateById(t);
-
-	}
-
-	/** 查 */
-	TbTradeArea getById(String id){
-		return super.getById(id);
-	}
-
-	/** 查集合 - 根据条件(参数为空时代表忽略指定条件) */  
-	List<TbTradeArea> getList(SoMap so) { 
-		return tbTradeAreaMapper.getList(so);	
-	}
-
-	/**
-	 *
-	 *向商品分类添加商品
-	 * @author loovi
-	 * @date
-	 */
-	public int addGoodsToTradeArea(Long tradeAreaId,Long [] goodsIds){
-		// 获取当前登录用户id
+public class TbTradeAreaService extends ServiceImpl<TbTradeAreaMapper, TbTradeArea> implements IService<TbTradeArea> {
+
+    /**
+     * 底层 Mapper 对象
+     */
+    @Autowired
+    TbTradeAreaMapper tbTradeAreaMapper;
+    @Autowired
+    TbGoodsMapper tbGoodsMapper;
+    @Autowired
+    private MethodTradeAreaService methodTradeAreaService;
+
+    /**
+     * 增
+     */
+    void add(TbTradeArea t) {
+        List<DistrictDTO> districtDTOS = FeignFactory.adminInterface.getDistrictList(t.getAddressIds());
+        t.setAddress(districtDTOS.stream().map(DistrictDTO::getDistrict).collect(Collectors.joining()))
+                .setCreateTime(new Date()).setCreateName(StpUserUtil.getPCLoginInfo().getLoginName());
+        save(t);
+    }
+
+    /**
+     * 删
+     */
+    void delete(Long id) {
+        removeById(id);
+    }
+
+    /**
+     * 改
+     */
+    void update(TbTradeArea t) {
+        List<DistrictDTO> districtDTOS = FeignFactory.adminInterface.getDistrictList(t.getAddressIds());
+        t.setAddress(districtDTOS.stream().map(DistrictDTO::getDistrict).collect(Collectors.joining()))
+                .setUpdateTime(new Date()).setUpdateName(StpUserUtil.getPCLoginInfo().getLoginName());
+        updateById(t);
+
+    }
+
+    /**
+     * 查
+     */
+    TbTradeArea getById(String id) {
+        return super.getById(id);
+    }
+
+    /**
+     * 查集合 - 根据条件(参数为空时代表忽略指定条件)
+     */
+    List<TbTradeArea> getList(SoMap so) {
+        return tbTradeAreaMapper.getList(so);
+    }
+
+    /**
+     * 向商品分类添加商品
+     *
+     * @author loovi
+     * @date
+     */
+    public int addGoodsToTradeArea(Long tradeAreaId, Long[] goodsIds) {
+        // 获取当前登录用户id
 //		Long loginId = StpUserUtil.getLoginIdAsLong();
-		int line = 0;
-		// 获取互市区信息
-		TbTradeArea tbTradeArea = tbTradeAreaMapper.selectById(tradeAreaId);
-		// 如果互市区不存在则抛异常
-		if (Objects.isNull(tbTradeArea)){
-			throw new RuntimeException("该商品类型不存在");
-		}
-		List<Long> list = Arrays.asList(goodsIds);
-		// 添加商品到互市区
-		for (Long goodsId : list) {
-			TbGoods tbGoods = tbGoodsMapper.selectById(goodsId);
-			if(Objects.isNull(tbGoods)){
-				throw new RuntimeException("该商品不存在");
-			}
-			int i =tbTradeAreaMapper.addGoodsToTradeArea(tradeAreaId,goodsId);
-			line = i+1;
-		}
-		return line;
-
-	}
-	/**
-	 *删除商品分类中的商品
-	 *
-	 * @author loovi
-	 * @date
-	 */
-	public int delGoodsFromTradeArea(Long tradeAreaId,Long [] goodsIds){
-
-		// 获取当前登录用户id
+        int line = 0;
+        // 获取互市区信息
+        TbTradeArea tbTradeArea = tbTradeAreaMapper.selectById(tradeAreaId);
+        // 如果互市区不存在则抛异常
+        if (Objects.isNull(tbTradeArea)) {
+            throw new RuntimeException("该商品类型不存在");
+        }
+        List<Long> list = Arrays.asList(goodsIds);
+        // 添加商品到互市区
+        for (Long goodsId : list) {
+            TbGoods tbGoods = tbGoodsMapper.selectById(goodsId);
+            if (Objects.isNull(tbGoods)) {
+                throw new RuntimeException("该商品不存在");
+            }
+            int i = tbTradeAreaMapper.addGoodsToTradeArea(tradeAreaId, goodsId);
+            line = i + 1;
+        }
+        return line;
+
+    }
+
+    /**
+     * 删除商品分类中的商品
+     *
+     * @author loovi
+     * @date
+     */
+    public int delGoodsFromTradeArea(Long tradeAreaId, Long[] goodsIds) {
+
+        // 获取当前登录用户id
 //		Long loginId = StpUserUtil.getLoginIdAsLong();
-		int line = 0;
-		// 获取互市区信息
-		TbTradeArea tbTradeArea = tbTradeAreaMapper.selectById(tradeAreaId);
-		// 如果互市区不存在则抛异常
-		if (Objects.isNull(tbTradeArea)){
-			throw new RuntimeException("该商品类型不存在");
-		}
-		List<Long> list = Arrays.asList(goodsIds);
-		// 从互市区删除商品
-		for (Long goodsId : list) {
-			TbGoods tbGoods = tbGoodsMapper.selectById(goodsId);
-			if(Objects.isNull(tbGoods)){
-				throw new RuntimeException("该商品不存在");
-			}
-			int i =tbTradeAreaMapper.delGoodsFromTradeArea(tradeAreaId,goodsId);
-			line = i+1;
-		}
-		return line;
-	}
-
-
-
-
-	/**
-	 * 导入
-	 * @param file excel文件
-	 * @return
-	 * @throws IOException
-	 */
-	public String importData(MultipartFile file) throws IOException {
-		System.out.println("\n开始执行文件上传....\n");
-
-		//判空
-		if(file.isEmpty()) return "文件为空,无法执行上传...";
-		//获取文件上传数据
-		HSSFWorkbook wb = new HSSFWorkbook(file.getInputStream());
-		//获取第一页sheet
-		HSSFSheet sheet = wb.getSheetAt(0);
-		//定义计数器
-		int count = 0;
-		//定义行对象
-		HSSFRow row = null;
-		//解析数据封装到集合
-		count = methodTradeAreaService.importMethod(row, sheet, count);
-		wb.close();
-		System.out.println("\n文件上传完成,共上传 " + count + "条 " + "数据...\n");
-		return "上传完成,共上传"  + count + "条"  + "数据。";
-	}
-
-	/**
-	 * 导出 excel文件
-	 * @param keyword
-	 * @return
-	 */
-	public String outportExcel(String keyword,String filepath) throws IOException {
-		System.out.println("\n开始执行文件导出....\n");
-		//导出的文件的路径
-		if(filepath == null || filepath.trim().equals("")){
-			// 获取当前用户的桌面路径
-			FileSystemView fileSystemView = FileSystemView.getFileSystemView();
-			filepath = fileSystemView.getHomeDirectory().getPath();
-		}
-		filepath = filepath + "\\贸易区域审核数据表_" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ".xlsx";
-		//根据需求查询数据
-		List<TbTradeArea> selectedList = tbTradeAreaMapper.selectList(new LambdaQueryWrapper<TbTradeArea>().eq(StringUtils.isNoneBlank(keyword), TbTradeArea::getName, keyword));
-		if(selectedList.size() == 0)return "没有可导出的数据。";
-		//建立excel对象封装数据
-		HSSFWorkbook workbook = new HSSFWorkbook();
-		//创建excel表格右下角的sheet页名称
-		HSSFSheet sheet = workbook.createSheet("1");
-		//创建表头
-		HSSFRow row = sheet.createRow(0);
-		row.createCell(0).setCellValue("序号");
-		row.createCell(1).setCellValue("区域名称");
-		row.createCell(2).setCellValue("区域IDs");
-		row.createCell(3).setCellValue("地址详情");
-		row.createCell(4).setCellValue("地址");
-
-		row.createCell(28).setCellValue("创建时间");
-		row.createCell(29).setCellValue("创建人编号");
-		row.createCell(30).setCellValue("创建人名称");
-		row.createCell(31).setCellValue("更新时间");
-		row.createCell(32).setCellValue("更新人编号");
-		row.createCell(33).setCellValue("更新人名称");
-		row.createCell(34).setCellValue("删除状态");
-
-		//定义计数器
-		int count = 0;
-		//遍历集合
-		for (int i = 0; i < selectedList.size(); i++) {
-			HSSFRow sheetRow = sheet.createRow(sheet.getLastRowNum() + 1);
-			sheetRow.createCell(0).setCellValue(i + 1);
-			sheetRow.createCell(1).setCellValue((selectedList.get(i).getName() + "").equals("null")? "": selectedList.get(i).getName() + "");
-			sheetRow.createCell(2).setCellValue((selectedList.get(i).getAddressIds() + "").equals("null")? "": selectedList.get(i).getAddressIds() + "");
-			sheetRow.createCell(3).setCellValue((selectedList.get(i).getDetailAddress() + "").equals("null")? "": selectedList.get(i).getDetailAddress() + "");
-			sheetRow.createCell(4).setCellValue((selectedList.get(i).getAddress() + "").equals("null")? "": selectedList.get(i).getAddress() + "");
-
-			//公共字段
-			sheetRow.createCell(22).setCellValue((selectedList.get(i).getCreateTime() + "").equals("null")? "": selectedList.get(i).getCreateTime() + "");
-			sheetRow.createCell(23).setCellValue((selectedList.get(i).getCreateBy() + "").equals("null")? "": selectedList.get(i).getCreateBy() + "");
-			sheetRow.createCell(24).setCellValue((selectedList.get(i).getCreateName() + "").equals("null")? "": selectedList.get(i).getCreateName() + "");
-			sheetRow.createCell(25).setCellValue((selectedList.get(i).getUpdateTime() + "").equals("null")? "": selectedList.get(i).getUpdateTime() + "");
-			sheetRow.createCell(26).setCellValue((selectedList.get(i).getUpdateBy() + "").equals("null")? "": selectedList.get(i).getUpdateBy() + "");
-			sheetRow.createCell(27).setCellValue((selectedList.get(i).getUpdateName() + "").equals("null")? "": selectedList.get(i).getUpdateName() + "");
-			sheetRow.createCell(28).setCellValue((selectedList.get(i).getDeleteStatus() + "").equals("null")? "": selectedList.get(i).getDeleteStatus() + "");
-			count += 1;
-		}
-		//建立输出流,输出文件
-		FileOutputStream fos = new FileOutputStream(filepath);
-
-		workbook.write(fos);
-		fos.flush();
-		//关闭输出流
-		fos.close();
-		workbook.close();
-		System.out.println("\n数据导出完成!共导出 " + count + " 条数据。");
-		return "数据导出完成!共导出 " + count + " 条数据。";
-	}
+        int line = 0;
+        // 获取互市区信息
+        TbTradeArea tbTradeArea = tbTradeAreaMapper.selectById(tradeAreaId);
+        // 如果互市区不存在则抛异常
+        if (Objects.isNull(tbTradeArea)) {
+            throw new RuntimeException("该商品类型不存在");
+        }
+        List<Long> list = Arrays.asList(goodsIds);
+        // 从互市区删除商品
+        for (Long goodsId : list) {
+            TbGoods tbGoods = tbGoodsMapper.selectById(goodsId);
+            if (Objects.isNull(tbGoods)) {
+                throw new RuntimeException("该商品不存在");
+            }
+            int i = tbTradeAreaMapper.delGoodsFromTradeArea(tradeAreaId, goodsId);
+            line = i + 1;
+        }
+        return line;
+    }
+
+
+    /**
+     * 导入
+     *
+     * @param file excel文件
+     * @return
+     * @throws IOException
+     */
+    public String importData(MultipartFile file) throws IOException {
+        System.out.println("\n开始执行文件上传....\n");
+
+        //判空
+        if (file.isEmpty()) return "文件为空,无法执行上传...";
+        //获取文件上传数据
+        HSSFWorkbook wb = new HSSFWorkbook(file.getInputStream());
+        //获取第一页sheet
+        HSSFSheet sheet = wb.getSheetAt(0);
+        //定义计数器
+        int count = 0;
+        //定义行对象
+        HSSFRow row = null;
+        //解析数据封装到集合
+        count = methodTradeAreaService.importMethod(row, sheet, count);
+        wb.close();
+        System.out.println("\n文件上传完成,共上传 " + count + "条 " + "数据...\n");
+        return "上传完成,共上传" + count + "条" + "数据。";
+    }
+
+    /**
+     * 导出 excel文件
+     *
+     * @param keyword
+     * @return
+     */
+    public String outportExcel(String keyword, String filepath) throws IOException {
+        System.out.println("\n开始执行文件导出....\n");
+        //导出的文件的路径
+        if (filepath == null || filepath.trim().equals("")) {
+            // 获取当前用户的桌面路径
+            FileSystemView fileSystemView = FileSystemView.getFileSystemView();
+            filepath = fileSystemView.getHomeDirectory().getPath();
+        }
+        filepath = filepath + "\\贸易区域审核数据表_" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ".xlsx";
+        //根据需求查询数据
+        List<TbTradeArea> selectedList = tbTradeAreaMapper.selectList(new LambdaQueryWrapper<TbTradeArea>().eq(StringUtils.isNoneBlank(keyword), TbTradeArea::getName, keyword));
+        if (selectedList.size() == 0) return "没有可导出的数据。";
+        //建立excel对象封装数据
+        HSSFWorkbook workbook = new HSSFWorkbook();
+        //创建excel表格右下角的sheet页名称
+        HSSFSheet sheet = workbook.createSheet("1");
+        //创建表头
+        HSSFRow row = sheet.createRow(0);
+        row.createCell(0).setCellValue("序号");
+        row.createCell(1).setCellValue("区域名称");
+        row.createCell(2).setCellValue("区域IDs");
+        row.createCell(3).setCellValue("地址详情");
+        row.createCell(4).setCellValue("地址");
+
+        row.createCell(28).setCellValue("创建时间");
+        row.createCell(29).setCellValue("创建人编号");
+        row.createCell(30).setCellValue("创建人名称");
+        row.createCell(31).setCellValue("更新时间");
+        row.createCell(32).setCellValue("更新人编号");
+        row.createCell(33).setCellValue("更新人名称");
+        row.createCell(34).setCellValue("删除状态");
+
+        //定义计数器
+        int count = 0;
+        //遍历集合
+        for (int i = 0; i < selectedList.size(); i++) {
+            HSSFRow sheetRow = sheet.createRow(sheet.getLastRowNum() + 1);
+            sheetRow.createCell(0).setCellValue(i + 1);
+            sheetRow.createCell(1).setCellValue((selectedList.get(i).getName() + "").equals("null") ? "" : selectedList.get(i).getName() + "");
+            sheetRow.createCell(2).setCellValue((selectedList.get(i).getAddressIds() + "").equals("null") ? "" : selectedList.get(i).getAddressIds() + "");
+            sheetRow.createCell(3).setCellValue((selectedList.get(i).getDetailAddress() + "").equals("null") ? "" : selectedList.get(i).getDetailAddress() + "");
+            sheetRow.createCell(4).setCellValue((selectedList.get(i).getAddress() + "").equals("null") ? "" : selectedList.get(i).getAddress() + "");
+
+            //公共字段
+            sheetRow.createCell(22).setCellValue((selectedList.get(i).getCreateTime() + "").equals("null") ? "" : selectedList.get(i).getCreateTime() + "");
+            sheetRow.createCell(23).setCellValue((selectedList.get(i).getCreateBy() + "").equals("null") ? "" : selectedList.get(i).getCreateBy() + "");
+            sheetRow.createCell(24).setCellValue((selectedList.get(i).getCreateName() + "").equals("null") ? "" : selectedList.get(i).getCreateName() + "");
+            sheetRow.createCell(25).setCellValue((selectedList.get(i).getUpdateTime() + "").equals("null") ? "" : selectedList.get(i).getUpdateTime() + "");
+            sheetRow.createCell(26).setCellValue((selectedList.get(i).getUpdateBy() + "").equals("null") ? "" : selectedList.get(i).getUpdateBy() + "");
+            sheetRow.createCell(27).setCellValue((selectedList.get(i).getUpdateName() + "").equals("null") ? "" : selectedList.get(i).getUpdateName() + "");
+            sheetRow.createCell(28).setCellValue((selectedList.get(i).getDeleteStatus() + "").equals("null") ? "" : selectedList.get(i).getDeleteStatus() + "");
+            count += 1;
+        }
+        //建立输出流,输出文件
+        FileOutputStream fos = new FileOutputStream(filepath);
+
+        workbook.write(fos);
+        fos.flush();
+        //关闭输出流
+        fos.close();
+        workbook.close();
+        System.out.println("\n数据导出完成!共导出 " + count + " 条数据。");
+        return "数据导出完成!共导出 " + count + " 条数据。";
+    }
+
+    public TbTradeArea findByCode(String tradeCode) {
+        QueryWrapper<TbTradeArea> ew = new QueryWrapper<>();
+        ew.lambda().eq(TbTradeArea::getCode, tradeCode);
+        List<TbTradeArea> list = this.list(ew);
+        return list.isEmpty() ? null : list.get(0);
+    }
 
+    public TbTradeArea updateHandler(String tradeCode, String fieldName) {
+        TbTradeArea tbTradeArea = this.findByCode(tradeCode);
+        if (tbTradeArea == null) {
+            tbTradeArea = new TbTradeArea();
+            tbTradeArea.setCode(tradeCode).setName(fieldName).setCreateTime(new Date()).setCreateBy("async");
+            this.save(tbTradeArea);
+        } else {
+            if (!StrUtil.isEmpty(fieldName)){
+                tbTradeArea.setName(fieldName)
+                        .setUpdateTime(new Date()).setUpdateBy("async");
+                this.updateById(tbTradeArea);
+            }
+        }
+        return tbTradeArea;
+    }
 }