Переглянути джерело

边民、互助组、合作社、商店、商品同步,优化部分功能

qzyReal 2 роки тому
батько
коміт
e10defca48
29 змінених файлів з 1085 додано та 845 видалено
  1. 7 6
      sp-core/sp-api/src/main/java/com/pj/api/client/admin/AdminInterface.java
  2. 16 15
      sp-core/sp-api/src/main/java/com/pj/api/client/level_one_server/LevelOneServerInterface.java
  3. 9 8
      sp-core/sp-base/src/main/java/com/pj/utils/sg/AjaxJson.java
  4. 4 2
      sp-core/sp-base/src/main/java/com/pj/utils/so/SoMap.java
  5. 2 1
      sp-service/level-one-server/src/main/java/com/pj/ht_trade_settlement/HtTradeSettlementController.java
  6. 1 1
      sp-service/level-one-server/src/main/java/com/pj/tb_goods/MethodGoodsService.java
  7. 1 1
      sp-service/level-one-server/src/main/java/com/pj/tb_goods/TbGoods.java
  8. 226 198
      sp-service/level-one-server/src/main/java/com/pj/tb_goods/TbGoodsService.java
  9. 1 1
      sp-service/level-one-server/src/main/java/com/pj/tb_goods_type/TbGoodsTypeController.java
  10. 120 99
      sp-service/level-one-server/src/main/java/com/pj/tb_goods_type/TbGoodsTypeService.java
  11. 144 0
      sp-service/level-one-server/src/main/java/com/pj/tb_goods_units/BtUnitType.java
  12. 3 2
      sp-service/level-one-server/src/main/java/com/pj/tb_goods_units/TbGoodsUnitsAppController.java
  13. 110 96
      sp-service/level-one-server/src/main/java/com/pj/tb_goods_units/TbGoodsUnitsController.java
  14. 1 1
      sp-service/level-one-server/src/main/java/com/pj/tb_goods_units/TbGoodsUnitsMapper.xml
  15. 137 113
      sp-service/level-one-server/src/main/java/com/pj/tb_goods_units/TbGoodsUnitsService.java
  16. 1 1
      sp-service/level-one-server/src/main/java/com/pj/tb_group/TbGroupController.java
  17. 265 250
      sp-service/level-one-server/src/main/java/com/pj/tb_group/TbGroupService.java
  18. 5 5
      sp-service/level-one-server/src/main/java/com/pj/tb_order/TbOrderAppController.java
  19. 2 2
      sp-service/level-one-server/src/main/java/com/pj/tb_people/TbPeopleController.java
  20. 1 1
      sp-service/level-one-server/src/main/java/com/pj/tb_port_news/TbPortNews.java
  21. 4 22
      sp-service/level-one-server/src/main/java/com/pj/tb_port_news/TbPortNewsService.java
  22. 1 1
      sp-service/level-one-server/src/main/java/com/pj/tb_shop/TbShopAppController.java
  23. 2 3
      sp-service/level-one-server/src/main/java/com/pj/tb_shop/TbShopController.java
  24. 1 1
      sp-service/level-one-server/src/main/java/com/pj/tb_trade_area/TbTradeAreaController.java
  25. 5 1
      sp-service/level-one-server/src/main/java/com/pj/tb_trade_area/TbTradeAreaService.java
  26. 6 7
      sp-service/sp-admin/src/main/java/com/pj/project/app_user/AppUserController.java
  27. 7 4
      sp-service/sp-admin/src/main/java/com/pj/project/app_user/AppUserService.java
  28. 2 2
      sp-service/sp-admin/src/main/java/com/pj/project4sp/admin4login/SpAccAdminService.java
  29. 1 1
      sp-service/transport-server/src/main/java/com/pj/project/tb_logistics/TbLogisticsAppController.java

+ 7 - 6
sp-core/sp-api/src/main/java/com/pj/api/client/admin/AdminInterface.java

@@ -4,6 +4,7 @@ import com.pj.api.FeignInterceptor;
 import com.pj.api.consts.FeignConsts;
 import com.pj.api.dto.*;
 import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
@@ -26,7 +27,7 @@ public interface AdminInterface {
     /**
      * 收购商认证 步骤2
      */
-    @RequestMapping("/AppUser/rpc/saveAppUserInfo")
+    @PostMapping("/AppUser/rpc/saveAppUserInfo")
     public Boolean saveAppUserInfo(@RequestBody AppUserDto appUser);
 
     /**
@@ -38,7 +39,7 @@ public interface AdminInterface {
     /**
      * 启/停边民的app账号登陆限制
      */
-    @RequestMapping("/AppUser/rpc/isLock")
+    @PostMapping("/AppUser/rpc/isLock")
     int isLock(@RequestParam("id") String id,
                @RequestParam("type") Integer type,
                @RequestParam("status") Integer status);
@@ -50,10 +51,10 @@ public interface AdminInterface {
     AppUserDto getAppUserById(@RequestParam("id") Long id);
 
 
-    @RequestMapping("/TbMessage/rpc/save")
+    @PostMapping("/TbMessage/rpc/save")
     public void messageSave(@RequestBody MessageDto dto);
 
-    @RequestMapping("/AppUser/rpc/audit")
+    @PostMapping("/AppUser/rpc/audit")
     public boolean audit(@RequestBody EnterpriseAuditDto dto);
 
     /**
@@ -77,13 +78,13 @@ public interface AdminInterface {
     /**
      * 同步航通边民信息时,自动给边民注册app账号
      */
-    @RequestMapping("/AppUser/rpc/generatePeopleAccount")
+    @PostMapping("/AppUser/rpc/generatePeopleAccount")
     public boolean generatePeopleAccount(@RequestBody HtPeopleDto peopleDto) throws Exception;
 
     /**
      * 同步航通边民信息时,自动给外籍商户注册app账号
      */
-    @RequestMapping("/AppUser/rpc/generateEnterpriseAccount")
+    @PostMapping("/AppUser/rpc/generateEnterpriseAccount")
     public int generateEnterpriseAccount(@RequestBody EnterpriseDto enterpriseDto) throws Exception ;
 
 }

+ 16 - 15
sp-core/sp-api/src/main/java/com/pj/api/client/level_one_server/LevelOneServerInterface.java

@@ -4,6 +4,7 @@ import com.pj.api.FeignInterceptor;
 import com.pj.api.consts.FeignConsts;
 import com.pj.api.dto.*;
 import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
@@ -24,19 +25,19 @@ public interface LevelOneServerInterface {
 
 
     /** 远程调用: 添加大订单时同事生成小定单 */
-    @RequestMapping("/HtTradeSettlement/rpc/tradeSettlementDto")
+    @PostMapping("/HtTradeSettlement/rpc/tradeSettlementDto")
     public boolean tradeSettlementDto(@RequestBody TradeSettlementDto tradeSettlementDto);
 
     /** 远程调用: 对合作社信息进行事务处理 */
-    @RequestMapping("/TbCooperative/rpc/cooperativeDto")
+    @PostMapping("/TbCooperative/rpc/cooperativeDto")
     public boolean cooperativeDto(@RequestBody HtCooperativeDto cooperativeDto);
 
     /** 商铺信息处理 */
-    @RequestMapping("/TbShop/rpc/shopDto")
+    @PostMapping("/TbShop/rpc/shopDto")
     public boolean shopDto(@RequestBody HtShopDTO shopDto);
 
     /** 远程调用  修改订单的叫车状态 */
-    @RequestMapping("/app/TbOrder/rpc/updateOrderCallCarStatus")
+    @PostMapping("/app/TbOrder/rpc/updateOrderCallCarStatus")
     public boolean updateOrderCallCarStatus(@RequestBody OrderDto orderDto);
 
     /** 根据ID获取一级市场商户信息 */
@@ -71,27 +72,27 @@ public interface LevelOneServerInterface {
     public GroupDto getRpcById(@RequestParam("id") String id);
 
     /** 添加商家身份信息 */
-    @RequestMapping("/TbEnterprise/rpc/enterpriseDto")
+    @PostMapping("/TbEnterprise/rpc/enterpriseDto")
     public boolean enterpriseDto(@RequestBody EnterpriseDto enterpriseDto);
 
     /** 添加组长信息 */
-    @RequestMapping("/TbGroup/rpc/groupDto")
+    @PostMapping("/TbGroup/rpc/groupDto")
     public boolean groupDto(@RequestBody HtGroupDto groupDto);
 
     /** 添加普通边民信息 */
-    @RequestMapping("/TbPeople/rpc/peopleDto")
+    @PostMapping("/TbPeople/rpc/peopleDto")
     public boolean peopleDto(@RequestBody HtPeopleDto peopleDto);
 
-    @RequestMapping("/AppUser/rpc/audit")
+    @PostMapping("/AppUser/rpc/audit")
     public boolean audit(@RequestBody EnterpriseAuditDto dto);
 
     @RequestMapping("/app/TbCooperative/rpc/getCooperativeById")
     public CooperativeDto getCooperativeById(@RequestParam("id")Long cooperativeId);
 
-    @RequestMapping("/app/TbOrder/rpc/updateResaleStatus")
+    @PostMapping("/app/TbOrder/rpc/updateResaleStatus")
     public boolean updateResaleStatus(@RequestParam("id") Long orderId);
 
-    @RequestMapping("/app/TbOrder/rpc/updateBeingOrder")
+    @PostMapping("/app/TbOrder/rpc/updateBeingOrder")
     public boolean updateBeingOrder(@RequestParam("id") Long levelOneOrderId);
 
     @RequestMapping("/app/TbGoodsType/rpc/getGoodsIds")
@@ -107,7 +108,7 @@ public interface LevelOneServerInterface {
     public List<ShopDto> getShopDtoListByPhone(@RequestParam("phone") String phone);
 
     /** 远程调用: 同步航通海关监管商品信息 */
-    @RequestMapping("/TbGoods/rpc/goodsDto")
+    @PostMapping("/TbGoods/rpc/goodsDto")
     public boolean goodsDto(@RequestBody HtGoodsDto goodsDto);
 
     /** 根据航通主键查询appUser */
@@ -115,19 +116,19 @@ public interface LevelOneServerInterface {
     public AppUserDto getAppUserByBorderPutrecNo(@RequestParam("borderPutrecNo") String borderPutrecNo);
 
     /** 系统接收到航通接口信息:车辆已出一级市场 ,修改相对应的一级市场订单状态 **/
-    @RequestMapping("/TbOrder/rpc/orderFinish")
+    @PostMapping("/TbOrder/rpc/orderFinish")
     public boolean orderFinish(@RequestParam("billCode") String billCode);
 
 
     /** 边民保存银行卡信息 */
-    @RequestMapping("/app/TbPeople/rpc/saveBankInfo")
+    @PostMapping("/app/TbPeople/rpc/saveBankInfo")
     public boolean saveBankByPeople(@RequestParam("id")Long id, @RequestParam("bankName")String bankName, @RequestParam("bankAccount")String bankAccount);
 
     /** 商户保存银行卡信息 */
-    @RequestMapping("/app/TbEnterprise/rpc/saveBankInfo")
+    @PostMapping("/app/TbEnterprise/rpc/saveBankInfo")
     public boolean saveBankByEnterprise(@RequestParam("id")Long id, @RequestParam("bankName")String bankName, @RequestParam("bankAccount")String bankAccount);
 
     /** 合作社保存银行卡信息 */
-    @RequestMapping("/app/TbCooperative/rpc/saveBankInfo")
+    @PostMapping("/app/TbCooperative/rpc/saveBankInfo")
     public boolean saveBankByCooperative(@RequestParam("id")Long id, @RequestParam("bankName")String bankName, @RequestParam("bankAccount")String bankAccount);
 }

+ 9 - 8
sp-core/sp-base/src/main/java/com/pj/utils/sg/AjaxJson.java

@@ -6,6 +6,7 @@ import java.util.Map;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.pj.utils.so.SoMap;
+import io.swagger.models.auth.In;
 
 
 /**
@@ -79,7 +80,7 @@ public class AjaxJson extends LinkedHashMap<String, Object> implements Serializa
 	}
 
 	/** 给dataCount(数据总数)赋值,连缀风格 */
-	public AjaxJson setDataCount(Long dataCount) {
+	public AjaxJson setDataCount(Integer dataCount) {
 		this.put("dataCount", dataCount);
 		// 如果提供了数据总数,则尝试计算page信息
 		if(dataCount != null && dataCount >= 0) {		
@@ -102,7 +103,7 @@ public class AjaxJson extends LinkedHashMap<String, Object> implements Serializa
 	}
 	
 	/** 设置pageNo 和 pageSize,并计算出startIndex于pageCount */
-	public AjaxJson setPageNoAndSize(long pageNo, long pageSize) {
+	public AjaxJson setPageNoAndSize(int pageNo, int pageSize) {
 		this.put("pageNo", pageNo);
 		this.put("pageSize", pageSize);
 		return this;
@@ -110,11 +111,11 @@ public class AjaxJson extends LinkedHashMap<String, Object> implements Serializa
 
 	/** 根据 pageSize dataCount,计算startIndex 与 pageCount */
 	public AjaxJson initPageInfo() {
-		long pageNo = (long)this.get("pageNo");
-		long pageSize = (long)this.get("pageSize");
-		long dataCount = (long)this.get("dataCount");
+		int pageNo = Integer.parseInt(this.get("pageNo")+"");
+		int pageSize = Integer.parseInt(this.get("pageSize")+"");
+		int dataCount =Integer.parseInt(this.get("dataCount")+"");
 		this.set("startIndex", (pageNo - 1) * pageSize);
-		long pc = dataCount / pageSize;
+		int pc = dataCount / pageSize;
 		this.set("pageCount", (dataCount % pageSize == 0 ?  pc : pc + 1));
 		return this;
 	}
@@ -137,7 +138,7 @@ public class AjaxJson extends LinkedHashMap<String, Object> implements Serializa
 	
 	// ============================  构建  ================================== 
 	
-	public AjaxJson(int code, String msg, Object data, Long dataCount) {
+	public AjaxJson(int code, String msg, Object data, Integer dataCount) {
 		this.setCode(code);
 		this.setMsg(msg);
 		this.setData(data);
@@ -191,7 +192,7 @@ public class AjaxJson extends LinkedHashMap<String, Object> implements Serializa
 	}
 	
 	/** 返回分页和数据的  */
-	public static AjaxJson getPageData(Long dataCount, Object data){
+	public static AjaxJson getPageData(Integer dataCount, Object data){
 		return new AjaxJson(CODE_SUCCESS, "ok", data, dataCount);
 	}
 	

+ 4 - 2
sp-core/sp-base/src/main/java/com/pj/utils/so/SoMap.java

@@ -14,6 +14,7 @@ import java.util.regex.Pattern;
 
 import javax.servlet.http.HttpServletRequest;
 
+import io.swagger.models.auth.In;
 import org.springframework.web.context.request.RequestContextHolder;
 import org.springframework.web.context.request.ServletRequestAttributes;
 
@@ -650,11 +651,12 @@ public class SoMap extends LinkedHashMap<String, Object> {
 		return this;
 	}
 	/** 获取上次分页的记录总数 */
-	public long getDataCount() {
+	public int getDataCount() {
 		if(pagePlug == null) {
 			return -1;
 		}
-		return pagePlug.getTotal();
+
+		return Math.toIntExact(pagePlug.getTotal());
 	}
 	/** 分页插件 - 结束分页, 返回总条数 (该方法已过时,请调用更加符合语义化的getDataCount() ) */
 	@Deprecated

+ 2 - 1
sp-service/level-one-server/src/main/java/com/pj/ht_trade_settlement/HtTradeSettlementController.java

@@ -6,6 +6,7 @@ import com.pj.project4sp.SP;
 import com.pj.utils.sg.AjaxJson;
 import com.pj.utils.so.SoMap;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
@@ -79,7 +80,7 @@ public class HtTradeSettlementController {
 	/*-----           正常业务逻辑👆👆    rpc远程调用👇👇 -----*/
 
 	/** 远程调用: 添加大订单时同事生成小定单 */
-	@RequestMapping("rpc/tradeSettlementDto")
+	@PostMapping("rpc/tradeSettlementDto")
 	public boolean tradeSettlementDto(@RequestBody TradeSettlementDto tradeSettlementDto){
 		boolean b = htTradeSettlementService.tradeSettlementDto(tradeSettlementDto);
 		return b;

+ 1 - 1
sp-service/level-one-server/src/main/java/com/pj/tb_goods/MethodGoodsService.java

@@ -69,7 +69,7 @@ public class MethodGoodsService {
 
             HSSFCell cell11 = row.createCell(10);
             if (cell11 != null && (cell11.getCellType() == CellType.NUMERIC || cell11.getCellType() == CellType.FORMULA))
-                tbGoods.setSinglePrice(row.getCell(11).getNumericCellValue());
+                tbGoods.setSinglePrice(row.getCell(11).getStringCellValue());
 
             if(row.getCell(11) != null)
                 tbGoods.setTaxNo(row.getCell(11).getStringCellValue());

+ 1 - 1
sp-service/level-one-server/src/main/java/com/pj/tb_goods/TbGoods.java

@@ -106,7 +106,7 @@ public class TbGoods extends Model<TbGoods> implements Serializable {
 	/**
 	 * 维护价格
 	 */
-	private Double singlePrice;
+	private String singlePrice;
 
 	/**
 	 *

+ 226 - 198
sp-service/level-one-server/src/main/java/com/pj/tb_goods/TbGoodsService.java

@@ -9,6 +9,7 @@ import java.util.Date;
 import java.util.List;
 import java.util.stream.Collectors;
 
+import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@@ -18,9 +19,13 @@ import com.pj.enummj.DeleteStatus;
 import com.pj.enummj.Status;
 import com.pj.tb_goods_type.TbGoodsType;
 import com.pj.tb_goods_type.TbGoodsTypeMapper;
+import com.pj.tb_goods_type.TbGoodsTypeService;
+import com.pj.tb_goods_units.TbGoodsUnits;
+import com.pj.tb_goods_units.TbGoodsUnitsService;
 import com.pj.tb_trade_area.TbTradeArea;
 import com.pj.tb_trade_area.TbTradeAreaService;
 import com.pj.utils.so.SoMap;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.hssf.usermodel.HSSFRow;
 import org.apache.poi.hssf.usermodel.HSSFSheet;
@@ -38,226 +43,249 @@ import javax.swing.filechooser.FileSystemView;
 
 /**
  * Service: tb_goods -- 商品
+ *
  * @author qzy
  */
 @Service
 @Transactional(rollbackFor = Exception.class)
-public class TbGoodsService extends ServiceImpl<TbGoodsMapper, TbGoods> implements IService<TbGoods>{
+@Slf4j
+public class TbGoodsService extends ServiceImpl<TbGoodsMapper, TbGoods> implements IService<TbGoods> {
 
-	/** 底层 Mapper 对象 */
-	@Autowired
-	TbGoodsMapper tbGoodsMapper;
-	@Autowired
-	TbGoodsTypeMapper tbGoodsTypeMapper;
-	@Resource
-	private TbTradeAreaService tbTradeAreaService;
+    /**
+     * 底层 Mapper 对象
+     */
+    @Autowired
+    TbGoodsMapper tbGoodsMapper;
+    @Autowired
+    TbGoodsTypeMapper tbGoodsTypeMapper;
+    @Resource
+    private TbGoodsTypeService tbGoodsTypeService;
+    @Resource
+    private TbTradeAreaService tbTradeAreaService;
 
-	@Autowired
-	private MethodGoodsService methodGoodsService;
+    @Autowired
+    private MethodGoodsService methodGoodsService;
+    @Resource
+    private TbGoodsUnitsService tbGoodsUnitsService;
 
-	/** 增 */
-	void add(TbGoods t){
-		save(t);
-	}
+    /**
+     * 增
+     */
+    void add(TbGoods t) {
+        save(t);
+    }
 
-	/** 删 */
-	void delete(Long id){
-		removeById(id);
-	}
+    /**
+     * 删
+     */
+    void delete(Long id) {
+        removeById(id);
+    }
 
-	/** 改 */
-	void update(TbGoods t){
-		updateById(t);
-	}
+    /**
+     * 改
+     */
+    void update(TbGoods t) {
+        updateById(t);
+    }
 
 
+    /**
+     * 查
+     */
+    TbGoods getById(String id) {
+        return super.getById(id);
+    }
 
-	/** 查 */
-	TbGoods getById(String id){
-		return super.getById(id);
-	}
+    /**
+     * 查集合 - 根据条件(参数为空时代表忽略指定条件)
+     */
+    List<TbGoods> getList(SoMap so) {
+        return tbGoodsMapper.getList(so);
+    }
 
-	/** 查集合 - 根据条件(参数为空时代表忽略指定条件) */
-	List<TbGoods> getList(SoMap so) {
-		return tbGoodsMapper.getList(so);
-	}
+    /**
+     * 查集合 - 根据互市区Id
+     */
+    List<TbGoods> getByTradeArea(SoMap so) {
+        return tbGoodsMapper.getByTradeArea(so);
+    }
 
-	/** 查集合 - 根据互市区Id */
-	List<TbGoods> getByTradeArea(SoMap so) {
-		return tbGoodsMapper.getByTradeArea(so);
-	}
 
+    /**
+     * 远程调用: 同步航通海关监管商品信息
+     */
+    public boolean goodsDto(HtGoodsDto goodsDto) {
+        log.info("收到商品同步信息:{}", JSONUtil.toJsonStr(goodsDto));
+        //操作类型:01 新增,02,修改,03 删除
+        if ("03".equals(goodsDto.getOpType())) {
+            boolean del = update(new LambdaUpdateWrapper<TbGoods>()
+                    .set(TbGoods::getDeleteStatus, DeleteStatus.DELETE_STATUS_OFF.getCode())
+                    .eq(TbGoods::getCode, goodsDto.getHsCode()));
+            return del;
+        }
+        TbTradeArea tbTradeArea = tbTradeAreaService.updateHandler(goodsDto.getFieldCode(), "");
+        //商品分类
+        TbGoodsType goodsType = tbGoodsTypeService.findByCode(goodsDto.getThrItemCode());
+        Date now = new Date();
+        if (goodsType == null) {
+            goodsType = new TbGoodsType();
+            goodsType.setCreateTime(now)
+                    .setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode())
+                    .setNo(goodsDto.getThrItemCode());
+        }
+        goodsType.setName(goodsDto.getThrItemName()).setUpdateTime(now);
+        tbGoodsTypeService.saveOrUpdate(goodsType);
 
-	/** 远程调用: 同步航通海关监管商品信息 */
-	public boolean goodsDto(HtGoodsDto goodsDto){
-		//操作类型:01 新增,02,修改,03 删除
-		if("03".equals(goodsDto.getOpType())) {
-			boolean del = update(new LambdaUpdateWrapper<TbGoods>()
-					.set(TbGoods::getDeleteStatus,DeleteStatus.DELETE_STATUS_OFF.getCode())
-					.eq(TbGoods::getCode,goodsDto.getHsCode()));
-			return del;
-		}
-		TbTradeArea tbTradeArea = tbTradeAreaService.updateHandler(goodsDto.getFieldCode(), "");
+        TbGoods tbGoods = findByCode(goodsDto.getHsCode());
+        if (tbGoods == null) {
+            //新增
+            tbGoods = new TbGoods();
+            BeanUtils.copyProperties(goodsDto, tbGoods);
+            //设计基本信息
+            tbGoods.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode()); // 默认未删除
+            tbGoods.setStatus(Status.STATUS_ONE.getCode()); // 默认可用
+            tbGoods.setCreateTime(now).setSinglePrice(goodsDto.getGoodsPrice());
+            tbGoods.setCreateName("航通");
+        }
+        tbGoods.setName(goodsDto.getgName())
+                .setCode(goodsDto.getHsCode())
+                .setTradeAreaId(tbTradeArea.getId())
+                .setTradeAreaName(tbTradeArea.getName())
+                .setTypeNames(goodsType.getName())
+                .setTypeIds(goodsType.getId() + "");
+        TbGoodsUnits tbGoodsUnits = tbGoodsUnitsService.findByCode(goodsDto.getgUnit());
+        if (tbGoodsUnits != null) {
+            tbGoods.setUnit(tbGoodsUnits.getUnits());
+        }
+        this.saveOrUpdate(tbGoods);
+        return true;
+    }
 
-		TbGoods tbGoods = new TbGoods();
-		List<TbGoods> tbGoodsList = tbGoodsMapper.selectList(new LambdaQueryWrapper<TbGoods>().eq(TbGoods::getCode, goodsDto.getHsCode()));
-		//数据库没有就是新增
-		if(tbGoodsList.size() == 0){
-			BeanUtils.copyProperties(goodsDto,tbGoods);
-			//设计基本信息
-			tbGoods.setName(goodsDto.getgName());
-			tbGoods.setUnit(goodsDto.getgUnit());
-			tbGoods.setCode(goodsDto.getHsCode());
-			tbGoods.setTradeAreaId(tbTradeArea.getId());
-			tbGoods.setTradeAreaName(tbTradeArea.getName());
-			tbGoods.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode()); // 默认未删除
-			tbGoods.setStatus(Status.STATUS_ONE.getCode()); // 默认可用
-			tbGoods.setCreateTime(new Date());
-			tbGoods.setCreateName("航通");
-			int insert = tbGoodsMapper.insert(tbGoods);
-			return insert == 1;
-		}
-		//修改
-		TbGoods goods = tbGoodsList.stream().sorted(Comparator.comparing(TbGoods::getId).reversed()).collect(Collectors.toList()).get(0);
-		BeanUtils.copyProperties(goods,tbGoods);
-		BeanUtils.copyProperties(goodsDto,tbGoods);
-		int i = tbGoodsMapper.updateById(tbGoods);
+    /**
+     * 导入
+     *
+     * @param file excel文件
+     * @return
+     * @throws IOException
+     */
+    public String importData(MultipartFile file) throws IOException {
+        System.out.println("\n开始执行文件上传....\n");
 
-		//新增商品类目表
-		List<TbGoodsType> typeList = tbGoodsTypeMapper.selectList(new LambdaQueryWrapper<TbGoodsType>().eq(TbGoodsType::getNo, goodsDto.getThrItemCode()));
-		if(typeList.size() == 0) {
-			TbGoodsType goodsType = new TbGoodsType();
-			goodsType.setNo(goodsDto.getThrItemCode());
-			goodsType.setName(goodsDto.getThrItemName());
-			goodsType.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode()); // 默认未删除
-			goodsType.setCreateTime(new Date());
-			goodsType.setCreateName("航通");
-			tbGoodsTypeMapper.insert(goodsType);
-		}
+        //判空
+        if (file.isEmpty()) return "文件为空,无法执行上传...";
+        //获取文件上传数据
+        HSSFWorkbook wb = new HSSFWorkbook(file.getInputStream());
+        //获取第一页sheet
+        HSSFSheet sheet = wb.getSheetAt(0);
+        //定义计数器
+        int count = 0;
+        //定义行对象
+        HSSFRow row = null;
+        //解析数据封装到集合
+        count = methodGoodsService.importMethod(row, sheet, count);
+        wb.close();
+        System.out.println("\n文件上传完成,共上传 " + count + "条 " + "数据...\n");
+        return "上传完成,共上传" + count + "条" + "数据。";
+    }
 
-		return i == 1;
-	}
+    /**
+     * 导出 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<TbGoods> selectedList = tbGoodsMapper.selectList(new LambdaQueryWrapper<TbGoods>().eq(StringUtils.isNoneBlank(keyword), TbGoods::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("主图");
+        row.createCell(3).setCellValue("分类");
+        row.createCell(4).setCellValue("分类名称");
+        row.createCell(5).setCellValue("编号");
+        row.createCell(6).setCellValue("备注");
+        row.createCell(7).setCellValue("原产地");
+        row.createCell(8).setCellValue("状态");
+        row.createCell(9).setCellValue("unit");
+        row.createCell(10).setCellValue("single_price");
+        row.createCell(11).setCellValue("tax_no");
+        row.createCell(12).setCellValue("创建时间");
+        row.createCell(13).setCellValue("创建人编号");
+        row.createCell(14).setCellValue("创建人名称");
+        row.createCell(15).setCellValue("更新时间");
+        row.createCell(16).setCellValue("更新人编号");
+        row.createCell(17).setCellValue("更新人名称");
+        row.createCell(18).setCellValue("删除状态");
 
-	/**
-	 * 导入
-	 * @param file excel文件
-	 * @return
-	 * @throws IOException
-	 */
-	public String importData(MultipartFile file) throws IOException {
-		System.out.println("\n开始执行文件上传....\n");
+        //定义计数器
+        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).getAvatar() + "").equals("null") ? "" : selectedList.get(i).getAvatar() + "");
+            sheetRow.createCell(3).setCellValue((selectedList.get(i).getTypeIds() + "").equals("null") ? "" : selectedList.get(i).getTypeIds() + "");
+            sheetRow.createCell(4).setCellValue((selectedList.get(i).getTypeNames() + "").equals("null") ? "" : selectedList.get(i).getTypeNames() + "");
+            sheetRow.createCell(5).setCellValue((selectedList.get(i).getCode() + "").equals("null") ? "" : selectedList.get(i).getCode() + "");
+            sheetRow.createCell(6).setCellValue((selectedList.get(i).getRemark() + "").equals("null") ? "" : selectedList.get(i).getRemark() + "");
+            sheetRow.createCell(7).setCellValue((selectedList.get(i).getSource() + "").equals("null") ? "" : selectedList.get(i).getSource() + "");
+            sheetRow.createCell(8).setCellValue((selectedList.get(i).getStatus() + "").equals("null") ? "" : selectedList.get(i).getStatus() + "");
+            sheetRow.createCell(9).setCellValue((selectedList.get(i).getUnit() + "").equals("null") ? "" : selectedList.get(i).getUnit() + "");
+            sheetRow.createCell(10).setCellValue((selectedList.get(i).getSinglePrice() + "").equals("null") ? "" : selectedList.get(i).getSinglePrice() + "");
+            sheetRow.createCell(11).setCellValue((selectedList.get(i).getTaxNo() + "").equals("null") ? "" : selectedList.get(i).getTaxNo() + "");
+            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);
 
-		//判空
-		if(file.isEmpty()) return "文件为空,无法执行上传...";
-		//获取文件上传数据
-		HSSFWorkbook wb = new HSSFWorkbook(file.getInputStream());
-		//获取第一页sheet
-		HSSFSheet sheet = wb.getSheetAt(0);
-		//定义计数器
-		int count = 0;
-		//定义行对象
-		HSSFRow row = null;
-		//解析数据封装到集合
-		count = methodGoodsService.importMethod(row, sheet, count);
-		wb.close();
-		System.out.println("\n文件上传完成,共上传 " + count + "条 " + "数据...\n");
-		return "上传完成,共上传"  + count + "条"  + "数据。";
-	}
+        workbook.write(fos);
+        fos.flush();
+        //关闭输出流
+        fos.close();
+        workbook.close();
+        System.out.println("\n数据导出完成!共导出 " + count + " 条数据。");
+        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<TbGoods> selectedList = tbGoodsMapper.selectList(new LambdaQueryWrapper<TbGoods>().eq(StringUtils.isNoneBlank(keyword), TbGoods::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("主图");
-		row.createCell(3).setCellValue("分类");
-		row.createCell(4).setCellValue("分类名称");
-		row.createCell(5).setCellValue("编号");
-		row.createCell(6).setCellValue("备注");
-		row.createCell(7).setCellValue("原产地");
-		row.createCell(8).setCellValue("状态");
-		row.createCell(9).setCellValue("unit");
-		row.createCell(10).setCellValue("single_price");
-		row.createCell(11).setCellValue("tax_no");
-		row.createCell(12).setCellValue("创建时间");
-		row.createCell(13).setCellValue("创建人编号");
-		row.createCell(14).setCellValue("创建人名称");
-		row.createCell(15).setCellValue("更新时间");
-		row.createCell(16).setCellValue("更新人编号");
-		row.createCell(17).setCellValue("更新人名称");
-		row.createCell(18).setCellValue("删除状态");
+    /**
+     * 远程调用
+     */
+    GoodsDto selectById(Long id) {
+        TbGoods byId = super.getById(id);
+        GoodsDto goodsDto = new GoodsDto();
+        BeanUtils.copyProperties(byId, goodsDto);
+        return goodsDto;
 
-		//定义计数器
-		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).getAvatar() + "").equals("null")? "": selectedList.get(i).getAvatar() + "");
-			sheetRow.createCell(3).setCellValue((selectedList.get(i).getTypeIds() + "").equals("null")? "": selectedList.get(i).getTypeIds() + "");
-			sheetRow.createCell(4).setCellValue((selectedList.get(i).getTypeNames() + "").equals("null")? "": selectedList.get(i).getTypeNames() + "");
-			sheetRow.createCell(5).setCellValue((selectedList.get(i).getCode() + "").equals("null")? "": selectedList.get(i).getCode() + "");
-			sheetRow.createCell(6).setCellValue((selectedList.get(i).getRemark() + "").equals("null")? "": selectedList.get(i).getRemark() + "");
-			sheetRow.createCell(7).setCellValue((selectedList.get(i).getSource() + "").equals("null")? "": selectedList.get(i).getSource() + "");
-			sheetRow.createCell(8).setCellValue((selectedList.get(i).getStatus() + "" ).equals("null")? "": selectedList.get(i).getStatus() + "");
-			sheetRow.createCell(9).setCellValue((selectedList.get(i).getUnit() + "").equals("null")? "": selectedList.get(i).getUnit() + "");
-			sheetRow.createCell(10).setCellValue((selectedList.get(i).getSinglePrice() + "").equals("null")? "": selectedList.get(i).getSinglePrice() + "");
-			sheetRow.createCell(11).setCellValue((selectedList.get(i).getTaxNo() + "").equals("null")? "": selectedList.get(i).getTaxNo() + "");
-			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 + " 条数据。";
-	}
-
-	/** 远程调用 */
-	GoodsDto selectById(Long id){
-		TbGoods byId = super.getById(id);
-		GoodsDto goodsDto = new GoodsDto();
-		BeanUtils.copyProperties(byId,goodsDto);
-		return goodsDto;
-
-	}
-
-	public TbGoods findByCode(String codeTs) {
-		QueryWrapper<TbGoods>ew=new QueryWrapper<>();
-		ew.lambda().eq(TbGoods::getCode,codeTs);
-		List<TbGoods>list=list(ew);
-		return list.isEmpty()?null:list.get(0);
-	}
+    public TbGoods findByCode(String codeTs) {
+        QueryWrapper<TbGoods> ew = new QueryWrapper<>();
+        ew.lambda().eq(TbGoods::getCode, codeTs);
+        List<TbGoods> list = list(ew);
+        return list.isEmpty() ? null : list.get(0);
+    }
 }

+ 1 - 1
sp-service/level-one-server/src/main/java/com/pj/tb_goods_type/TbGoodsTypeController.java

@@ -83,7 +83,7 @@ public class TbGoodsTypeController {
 		// 转为tree结构,并返回 
 		List<SoMap> listMap = SoMap.getSoMapByList(list);
 		List<SoMap> listTree = SoMap.listToTree(listMap, "id", "parentId", "children");
-		return AjaxJson.getPageData(Long.valueOf(listMap.size()), listTree);
+		return AjaxJson.getPageData(listMap.size(), listTree);
 	}
 	
 	

+ 120 - 99
sp-service/level-one-server/src/main/java/com/pj/tb_goods_type/TbGoodsTypeService.java

@@ -17,109 +17,130 @@ import org.springframework.transaction.annotation.Transactional;
 
 /**
  * Service: tb_goods_type -- 商品分类
+ *
  * @author qzy
  */
 @Service
 @Transactional(rollbackFor = Exception.class)
-public class TbGoodsTypeService extends ServiceImpl<TbGoodsTypeMapper, TbGoodsType> implements IService<TbGoodsType>{
-
-	/** 底层 Mapper 对象 */
-	@Autowired
-	TbGoodsTypeMapper tbGoodsTypeMapper;
-	@Autowired
-	TbGoodsMapper tbGoodsMapper;
-
-	/** 增 */
-	void add(TbGoodsType t){
-		save(t);
-	}
-
-	/** 删 */
-	void delete(Long id){
-		removeById(id);
-	}
-
-	/** 改 */
-	void update(TbGoodsType t){
-		updateById(t);
-
-	}
-
-	/** 查 */
-	TbGoodsType getById(String id){
-		return super.getById(id);
-	}
-
-	/** 查集合 - 根据条件(参数为空时代表忽略指定条件) */
-	List<TbGoodsType> getList(SoMap so) {
-		return tbGoodsTypeMapper.getList(so);
-	}
-
-	/**
-	*
-	*向商品分类添加商品
-	* @author loovi
-	* @date
-	*/
-	public int addGoodsToGoodsType(Long goodsTypeId,Long [] goodsIds){
-		// 获取当前登录用户id
+public class TbGoodsTypeService extends ServiceImpl<TbGoodsTypeMapper, TbGoodsType> implements IService<TbGoodsType> {
+
+    /**
+     * 底层 Mapper 对象
+     */
+    @Autowired
+    TbGoodsTypeMapper tbGoodsTypeMapper;
+    @Autowired
+    TbGoodsMapper tbGoodsMapper;
+
+    /**
+     * 增
+     */
+    void add(TbGoodsType t) {
+        save(t);
+    }
+
+    /**
+     * 删
+     */
+    void delete(Long id) {
+        removeById(id);
+    }
+
+    /**
+     * 改
+     */
+    void update(TbGoodsType t) {
+        updateById(t);
+
+    }
+
+    /**
+     * 查
+     */
+    TbGoodsType getById(String id) {
+        return super.getById(id);
+    }
+
+    /**
+     * 查集合 - 根据条件(参数为空时代表忽略指定条件)
+     */
+    List<TbGoodsType> getList(SoMap so) {
+        return tbGoodsTypeMapper.getList(so);
+    }
+
+    /**
+     * 向商品分类添加商品
+     *
+     * @author loovi
+     * @date
+     */
+    public int addGoodsToGoodsType(Long goodsTypeId, Long[] goodsIds) {
+        // 获取当前登录用户id
 //		Long loginId = StpUserUtil.getLoginIdAsLong();
-		int line = 0;
-		// 获取商品类型信息
-		com.pj.tb_goods_type.TbGoodsType tbGoodsType = tbGoodsTypeMapper.selectById(goodsTypeId);
-		// 如果商品类型不存在则抛异常
-		if (Objects.isNull(tbGoodsType)){
-			throw new RuntimeException("该商品类型不存在");
-		}
-		List<Long> list = Arrays.asList(goodsIds);
-		// 把商品与类型关联id写入商品类型商品关系表
-		for (Long goodsId : list) {
-			TbGoods tbGoods = tbGoodsMapper.selectById(goodsId);
-			if(Objects.isNull(tbGoods)){
-				throw new RuntimeException("该商品不存在");
-			}
-			int i =tbGoodsTypeMapper.addGoodsToGoodsType(goodsTypeId,goodsId);
-			line = i+1;
-		}
-		return line;
-
-	}
-	/**
-	*删除商品分类中的商品
-	*
-	* @author loovi
-	* @date
-	*/
-	public int delGoodsFromGoodsType(Long goodsTypeId,Long [] goodsIds){
-
-		// 获取当前登录用户id
+        int line = 0;
+        // 获取商品类型信息
+        com.pj.tb_goods_type.TbGoodsType tbGoodsType = tbGoodsTypeMapper.selectById(goodsTypeId);
+        // 如果商品类型不存在则抛异常
+        if (Objects.isNull(tbGoodsType)) {
+            throw new RuntimeException("该商品类型不存在");
+        }
+        List<Long> list = Arrays.asList(goodsIds);
+        // 把商品与类型关联id写入商品类型商品关系表
+        for (Long goodsId : list) {
+            TbGoods tbGoods = tbGoodsMapper.selectById(goodsId);
+            if (Objects.isNull(tbGoods)) {
+                throw new RuntimeException("该商品不存在");
+            }
+            int i = tbGoodsTypeMapper.addGoodsToGoodsType(goodsTypeId, goodsId);
+            line = i + 1;
+        }
+        return line;
+
+    }
+
+    /**
+     * 删除商品分类中的商品
+     *
+     * @author loovi
+     * @date
+     */
+    public int delGoodsFromGoodsType(Long goodsTypeId, Long[] goodsIds) {
+
+        // 获取当前登录用户id
 //		Long loginId = StpUserUtil.getLoginIdAsLong();
-		int line = 0;
-		// 获取商品类型信息
-		com.pj.tb_goods_type.TbGoodsType tbGoodsType = tbGoodsTypeMapper.selectById(goodsTypeId);
-		// 如果商品类型不存在则抛异常
-		if (Objects.isNull(tbGoodsType)){
-			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 =tbGoodsTypeMapper.delGoodsFromGoodsType(goodsTypeId,goodsId);
-			line = i+1;
-		}
-		return line;
-	}
-
-	public List<Long> getGoodsIds(String typeCode) {
-		LambdaQueryWrapper<TbGoods> wrapper = new LambdaQueryWrapper<>();
-		wrapper.eq(TbGoods::getThrItemCode, typeCode);
-		List<TbGoods> goodsList = tbGoodsMapper.selectList(wrapper);
-
-		List<Long> goodsIds = goodsList.stream().map(TbGoods::getId).collect(Collectors.toList());
-		return goodsIds;
-	}
+        int line = 0;
+        // 获取商品类型信息
+        com.pj.tb_goods_type.TbGoodsType tbGoodsType = tbGoodsTypeMapper.selectById(goodsTypeId);
+        // 如果商品类型不存在则抛异常
+        if (Objects.isNull(tbGoodsType)) {
+            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 = tbGoodsTypeMapper.delGoodsFromGoodsType(goodsTypeId, goodsId);
+            line = i + 1;
+        }
+        return line;
+    }
+
+    public List<Long> getGoodsIds(String typeCode) {
+        LambdaQueryWrapper<TbGoods> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(TbGoods::getThrItemCode, typeCode);
+        List<TbGoods> goodsList = tbGoodsMapper.selectList(wrapper);
+
+        List<Long> goodsIds = goodsList.stream().map(TbGoods::getId).collect(Collectors.toList());
+        return goodsIds;
+    }
+
+    public TbGoodsType findByCode(String typeCode) {
+        LambdaQueryWrapper<TbGoodsType> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(TbGoodsType::getNo, typeCode);
+        List<TbGoodsType> typeList = this.list(wrapper);
+        return typeList.isEmpty() ? null : typeList.get(0);
+    }
 }

+ 144 - 0
sp-service/level-one-server/src/main/java/com/pj/tb_goods_units/BtUnitType.java

@@ -0,0 +1,144 @@
+package com.pj.tb_goods_units;
+
+
+public enum BtUnitType {
+	 UNIT_TYPE_001("001","台"),
+	 UNIT_TYPE_002("002","座"),
+	 UNIT_TYPE_003("003","辆"),
+	 UNIT_TYPE_004("004","艘"),
+	 UNIT_TYPE_005("005","架"),
+	 UNIT_TYPE_006("006","套"),
+	 UNIT_TYPE_007("007","个"),
+	 UNIT_TYPE_008("008","只"),
+	 UNIT_TYPE_009("009","头"),
+	 UNIT_TYPE_010("010","张"),
+	 UNIT_TYPE_011("011","件"),
+	 UNIT_TYPE_012("012","支"),
+	 UNIT_TYPE_013("013","枝"),
+	 UNIT_TYPE_014("014","根"),
+	 UNIT_TYPE_015("015","条"),
+	 UNIT_TYPE_016("016","把"),
+	 UNIT_TYPE_017("017","块"),
+	 UNIT_TYPE_018("018","卷"),
+	 UNIT_TYPE_019("019","副"),
+	 UNIT_TYPE_020("020","片"),
+	 UNIT_TYPE_021("021","组"),
+	 UNIT_TYPE_022("022","份"),
+	 UNIT_TYPE_023("023","幅"),
+	 UNIT_TYPE_025("025","双"),
+	 UNIT_TYPE_026("026","对"),
+	 UNIT_TYPE_027("027","棵"),
+	 UNIT_TYPE_028("028","株"),
+	 UNIT_TYPE_029("029","井"),
+	 UNIT_TYPE_030("030","米"),
+	 UNIT_TYPE_031("031","盘"),
+	 UNIT_TYPE_032("032","平方米"),
+	 UNIT_TYPE_033("033","立方米"),
+	 UNIT_TYPE_034("034","筒"),
+	 UNIT_TYPE_035("035","千克"),
+	 UNIT_TYPE_036("036","克"),
+	 UNIT_TYPE_037("037","盆"),
+	 UNIT_TYPE_038("038","万个"),
+	 UNIT_TYPE_039("039","具"),
+	 UNIT_TYPE_040("040","百副"),
+	 UNIT_TYPE_041("041","百支"),
+	 UNIT_TYPE_042("042","百把"),
+	 UNIT_TYPE_043("043","百个"),
+	 UNIT_TYPE_044("044","百片"),
+	 UNIT_TYPE_045("045","刀"),
+	 UNIT_TYPE_046("046","疋"),
+	 UNIT_TYPE_047("047","公担"),
+	 UNIT_TYPE_048("048","扇"),
+	 UNIT_TYPE_049("049","百枝"),
+	 UNIT_TYPE_050("050","千只"),
+	 UNIT_TYPE_051("051","千块"),
+	 UNIT_TYPE_052("052","千盒"),
+	 UNIT_TYPE_053("053","千枝"),
+	 UNIT_TYPE_054("054","千个"),
+	 UNIT_TYPE_055("055","亿支"),
+	 UNIT_TYPE_056("056","亿个"),
+	 UNIT_TYPE_057("057","万套"),
+	 UNIT_TYPE_058("058","千张"),
+	 UNIT_TYPE_059("059","万张"),
+	 UNIT_TYPE_060("060","千伏安"),
+	 UNIT_TYPE_061("061","千瓦"),
+	 UNIT_TYPE_062("062","千瓦时"),
+	 UNIT_TYPE_063("063","千升"),
+	 UNIT_TYPE_067("067","英尺"),
+	 UNIT_TYPE_070("070","吨"),
+	 UNIT_TYPE_071("071","长吨"),
+	 UNIT_TYPE_072("072","短吨"),
+	 UNIT_TYPE_073("073","司马担"),
+	 UNIT_TYPE_074("074","司马斤"),
+	 UNIT_TYPE_075("075","斤"),
+	 UNIT_TYPE_076("076","磅"),
+	 UNIT_TYPE_077("077","担"),
+	 UNIT_TYPE_078("078","英担"),
+	 UNIT_TYPE_079("079","短担"),
+	 UNIT_TYPE_080("080","两"),
+	 UNIT_TYPE_081("081","市担"),
+	 UNIT_TYPE_083("083","盎司"),
+	 UNIT_TYPE_084("084","克拉"),
+	 UNIT_TYPE_085("085","市尺"),
+	 UNIT_TYPE_086("086","码"),
+	 UNIT_TYPE_088("088","英寸"),
+	 UNIT_TYPE_089("089","寸"),
+	 UNIT_TYPE_095("095","升"),
+	 UNIT_TYPE_096("096","毫升"),
+	 UNIT_TYPE_097("097","英加仑"),
+	 UNIT_TYPE_098("098","美加仑"),
+	 UNIT_TYPE_099("099","立方英尺"),
+	 UNIT_TYPE_101("101","立方尺"),
+	 UNIT_TYPE_110("110","平方码"),
+	 UNIT_TYPE_111("111","平方英尺"),
+	 UNIT_TYPE_112("112","平方尺"),
+	 UNIT_TYPE_115("115","英制马力"),
+	 UNIT_TYPE_116("116","公制马力"),
+	 UNIT_TYPE_118("118","令"),
+	 UNIT_TYPE_120("120","箱"),
+	 UNIT_TYPE_121("121","批"),
+	 UNIT_TYPE_122("122","罐"),
+	 UNIT_TYPE_123("123","桶"),
+	 UNIT_TYPE_124("124","扎"),
+	 UNIT_TYPE_125("125","包"),
+	 UNIT_TYPE_126("126","箩"),
+	 UNIT_TYPE_127("127","打"),
+	 UNIT_TYPE_128("128","筐"),
+	 UNIT_TYPE_129("129","罗"),
+	 UNIT_TYPE_130("130","匹"),
+	 UNIT_TYPE_131("131","册"),
+	 UNIT_TYPE_132("132","本"),
+	 UNIT_TYPE_133("133","发"),
+	 UNIT_TYPE_134("134","枚"),
+	 UNIT_TYPE_135("135","捆"),
+	 UNIT_TYPE_136("136","袋"),
+	 UNIT_TYPE_139("139","粒"),
+	 UNIT_TYPE_140("140","盒"),
+	 UNIT_TYPE_141("141","合"),
+	 UNIT_TYPE_142("142","瓶"),
+	 UNIT_TYPE_143("143","千支"),
+	 UNIT_TYPE_144("144","万双"),
+	 UNIT_TYPE_145("145","万粒"),
+	 UNIT_TYPE_146("146","千粒"),
+	 UNIT_TYPE_147("147","千米"),
+	 UNIT_TYPE_148("148","千英尺"),
+	 UNIT_TYPE_149("149","百万贝可"),
+	 UNIT_TYPE_163("163","部"),
+	 UNIT_TYPE_164("164","亿株"),
+	 UNIT_TYPE_9999T("9999T","UNIT"),
+	;
+	
+	
+	BtUnitType(String code, String name) {
+        this.code = code;
+        this.name = name;
+    }
+    private final String code;
+    private final String name;
+    public String getCode() {
+        return code;
+    }
+    public String getName() {
+        return name;
+    }
+}

+ 3 - 2
sp-service/level-one-server/src/main/java/com/pj/tb_goods_units/TbGoodsUnitsAppController.java

@@ -31,8 +31,9 @@ public class TbGoodsUnitsAppController {
 	/** 查集合 - 根据条件(参数为空时代表忽略指定条件) */
 	@RequestMapping("getList")
 	public AjaxJson getList() {
-		List<TbGoodsUnits> list = tbGoodsUnitsService.getList(new SoMap());
-		return AjaxJson.getPageData(Long.valueOf(list.size()), list);
+		SoMap soMap=SoMap.getRequestSoMap();
+		List<TbGoodsUnits> list = tbGoodsUnitsService.getList(soMap.startPage());
+		return AjaxJson.getPageData(soMap.getDataCount(), list);
 	}
 
 

+ 110 - 96
sp-service/level-one-server/src/main/java/com/pj/tb_goods_units/TbGoodsUnitsController.java

@@ -1,7 +1,10 @@
 package com.pj.tb_goods_units;
 
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
+
 import com.pj.utils.so.SoMap;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -15,107 +18,118 @@ import org.springframework.web.multipart.MultipartFile;
 
 /**
  * Controller: tb_goods_units -- 商品单位
- * @author qzy 
+ *
+ * @author qzy
  */
 @RestController
 @RequestMapping("/TbGoodsUnits/")
 public class TbGoodsUnitsController {
 
-	/** 底层 Service 对象 */
-	@Autowired
-	TbGoodsUnitsService tbGoodsUnitsService;
-
-	/** 增 */  
-	@RequestMapping("add")
-	@SaCheckPermission(TbGoodsUnits.PERMISSION_CODE_ADD)
-	public AjaxJson add(TbGoodsUnits t){
-		tbGoodsUnitsService.add(t);
-		t = tbGoodsUnitsService.getById(SP.publicMapper.getPrimarykey());
-		return AjaxJson.getSuccessData(t);
-	}
-
-	/** 删 */  
-	@RequestMapping("delete")
-	@SaCheckPermission(TbGoodsUnits.PERMISSION_CODE_DEL)
-	public AjaxJson delete(Long id){
-		 tbGoodsUnitsService.delete(id);
-		return AjaxJson.getSuccess();
-	}
-	
-	/** 删 - 根据id列表 */  
-	@RequestMapping("deleteByIds")
-	@SaCheckPermission(TbGoodsUnits.PERMISSION_CODE_DEL)
-	public AjaxJson deleteByIds(){
-		List<Long> ids = SoMap.getRequestSoMap().getListByComma("ids", long.class); 
-		int line = SP.publicMapper.deleteByIds(TbGoodsUnits.TABLE_NAME, ids);
-		return AjaxJson.getByLine(line);
-	}
-	
-	/** 改 */  
-	@RequestMapping("update")
-	@SaCheckPermission(TbGoodsUnits.PERMISSION_CODE_EDIT)
-	public AjaxJson update(TbGoodsUnits t){
-		tbGoodsUnitsService.update(t);
-		return AjaxJson.getSuccess();
-	}
-
-	/** 查 - 根据id */  
-	@RequestMapping("getById")
-		@SaCheckPermission(TbGoodsUnits.PERMISSION_CODE)
-	public AjaxJson getById(Long id){
-		TbGoodsUnits t = tbGoodsUnitsService.getById(id);
-		return AjaxJson.getSuccessData(t);
-	}
-
-	/** 查集合 - 根据条件(参数为空时代表忽略指定条件) */  
-	@RequestMapping("getList")
-		@SaCheckPermission(TbGoodsUnits.PERMISSION_CODE)
-	public AjaxJson getList() { 
-		SoMap so = SoMap.getRequestSoMap();
-		List<TbGoodsUnits> list = tbGoodsUnitsService.getList(so.startPage());
-		return AjaxJson.getPageData(so.getDataCount(), list);
-	}
-
-
-	/**
-	 * 数据导入接口
-	 * @param file
-	 * @return
-	 */
-	@RequestMapping("goodsUnitsImport")
-	@ResponseBody
-	public AjaxJson dataImport(@RequestParam("file") MultipartFile file){
-		try {
-			String importData = tbGoodsUnitsService.importData(file);
-			AjaxJson.getSuccess(importData);
-		} catch (IOException e) {
-			throw new RuntimeException(e);
-		}
-		return AjaxJson.getError();
-	}
-
-	/**
-	 * 导出
-	 * @param keyword
-	 * @return
-	 */
-	@RequestMapping("goodsUnitsOutport")
-	@ResponseBody
-	public AjaxJson dataOutport(@RequestParam(value = "keyword",required = false) String keyword,@RequestParam(value = "filepath",required = false)String filepath){
-		try {
-			String importData = tbGoodsUnitsService.outportExcel(keyword,filepath);
-			AjaxJson.getSuccess(importData);
-		} catch (IOException e) {
-			throw new RuntimeException(e);
-		}
-		return AjaxJson.getError();
-	}
-
-
-
-
-
-
+    /**
+     * 底层 Service 对象
+     */
+    @Autowired
+    TbGoodsUnitsService tbGoodsUnitsService;
+
+    /**
+     * 增
+     */
+    @RequestMapping("add")
+    @SaCheckPermission(TbGoodsUnits.PERMISSION_CODE_ADD)
+    public AjaxJson add(TbGoodsUnits t) {
+        tbGoodsUnitsService.add(t);
+        t = tbGoodsUnitsService.getById(SP.publicMapper.getPrimarykey());
+        return AjaxJson.getSuccessData(t);
+    }
+
+    /**
+     * 删
+     */
+    @RequestMapping("delete")
+    @SaCheckPermission(TbGoodsUnits.PERMISSION_CODE_DEL)
+    public AjaxJson delete(Long id) {
+        tbGoodsUnitsService.delete(id);
+        return AjaxJson.getSuccess();
+    }
+
+    /**
+     * 删 - 根据id列表
+     */
+    @RequestMapping("deleteByIds")
+    @SaCheckPermission(TbGoodsUnits.PERMISSION_CODE_DEL)
+    public AjaxJson deleteByIds() {
+        List<Long> ids = SoMap.getRequestSoMap().getListByComma("ids", long.class);
+        int line = SP.publicMapper.deleteByIds(TbGoodsUnits.TABLE_NAME, ids);
+        return AjaxJson.getByLine(line);
+    }
+
+    /**
+     * 改
+     */
+    @RequestMapping("update")
+    @SaCheckPermission(TbGoodsUnits.PERMISSION_CODE_EDIT)
+    public AjaxJson update(TbGoodsUnits t) {
+        tbGoodsUnitsService.update(t);
+        return AjaxJson.getSuccess();
+    }
+
+    /**
+     * 查 - 根据id
+     */
+    @RequestMapping("getById")
+    @SaCheckPermission(TbGoodsUnits.PERMISSION_CODE)
+    public AjaxJson getById(Long id) {
+        TbGoodsUnits t = tbGoodsUnitsService.getById(id);
+        return AjaxJson.getSuccessData(t);
+    }
+
+    /**
+     * 查集合 - 根据条件(参数为空时代表忽略指定条件)
+     */
+    @RequestMapping("getList")
+    @SaCheckPermission(TbGoodsUnits.PERMISSION_CODE)
+    public AjaxJson getList() {
+        SoMap so = SoMap.getRequestSoMap();
+        List<TbGoodsUnits> list = tbGoodsUnitsService.getList(so.startPage());
+        return AjaxJson.getPageData(so.getDataCount(), list);
+    }
+
+
+    /**
+     * 数据导入接口
+     *
+     * @param file
+     * @return
+     */
+    @RequestMapping("goodsUnitsImport")
+    @ResponseBody
+    public AjaxJson dataImport(@RequestParam("file") MultipartFile file) {
+        try {
+            String importData = tbGoodsUnitsService.importData(file);
+            AjaxJson.getSuccess(importData);
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+        return AjaxJson.getError();
+    }
+
+    /**
+     * 导出
+     *
+     * @param keyword
+     * @return
+     */
+    @RequestMapping("goodsUnitsOutport")
+    @ResponseBody
+    public AjaxJson dataOutport(@RequestParam(value = "keyword", required = false) String keyword, @RequestParam(value = "filepath", required = false) String filepath) {
+        try {
+            String importData = tbGoodsUnitsService.outportExcel(keyword, filepath);
+            AjaxJson.getSuccess(importData);
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+        return AjaxJson.getError();
+    }
 
 
 }

+ 1 - 1
sp-service/level-one-server/src/main/java/com/pj/tb_goods_units/TbGoodsUnitsMapper.xml

@@ -31,7 +31,7 @@
 			<when test='sortType == 1'> id desc </when>
 			<when test='sortType == 2'> units_no desc </when>
 			<when test='sortType == 3'> units desc </when>
-			<otherwise> id desc </otherwise>
+			<otherwise> units_no asc </otherwise>
 		</choose>
 	</select>
 	

+ 137 - 113
sp-service/level-one-server/src/main/java/com/pj/tb_goods_units/TbGoodsUnitsService.java

@@ -7,6 +7,7 @@ import java.time.format.DateTimeFormatter;
 import java.util.List;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.pj.tb_goods_type.TbGoodsType;
 import com.pj.utils.so.SoMap;
 import org.apache.commons.lang3.StringUtils;
@@ -24,121 +25,144 @@ import javax.swing.filechooser.FileSystemView;
 
 /**
  * Service: tb_goods_units -- 商品单位
- * @author qzy 
+ *
+ * @author qzy
  */
 @Service
 @Transactional(rollbackFor = Exception.class)
-public class TbGoodsUnitsService extends ServiceImpl<TbGoodsUnitsMapper, TbGoodsUnits> implements IService<TbGoodsUnits>{
-
-	/** 底层 Mapper 对象 */
-	@Autowired
-	TbGoodsUnitsMapper tbGoodsUnitsMapper;
-
-	@Autowired
-	private MethodGoodsUnitsService methodGoodsUnitsService;
-
-	/** 增 */
-	void add(TbGoodsUnits t){
-		save(t);
-	}
-
-	/** 删 */
-	void delete(Long id){
-		removeById(id);
-	}
-
-	/** 改 */
-	void update(TbGoodsUnits t){
-		updateById(t);
-
-	}
-
-	/** 查 */
-	TbGoodsUnits getById(Long id){
-		return super.getById(id);
-	}
-
-	/** 查集合 - 根据条件(参数为空时代表忽略指定条件) */  
-	List<TbGoodsUnits> getList(SoMap so) { 
-		return tbGoodsUnitsMapper.getList(so);	
-	}
-
-	/**
-	 * 导入
-	 * @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 = methodGoodsUnitsService.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<TbGoodsUnits> selectedList = tbGoodsUnitsMapper.selectList(new LambdaQueryWrapper<TbGoodsUnits>().eq(StringUtils.isNoneBlank(keyword), TbGoodsUnits::getUnits, 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("管理商品的单位");
-
-		//定义计数器
-		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).getUnitsNo() + "").equals("null")? "": selectedList.get(i).getUnitsNo() + "");
-			sheetRow.createCell(2).setCellValue((selectedList.get(i).getUnits() + "").equals("null")? "": selectedList.get(i).getUnits() + "");
-
-			count += 1;
-					}
-		//建立输出流,输出文件
-		FileOutputStream fos = new FileOutputStream(filepath);
-
-		workbook.write(fos);
-		fos.flush();
-		//关闭输出流
-		fos.close();
-		workbook.close();
-		System.out.println("\n数据导出完成!共导出 " + count + " 条数据。");
-		return "数据导出完成!共导出 " + count + " 条数据。";
-	}
-
-
+public class TbGoodsUnitsService extends ServiceImpl<TbGoodsUnitsMapper, TbGoodsUnits> implements IService<TbGoodsUnits> {
+
+    /**
+     * 底层 Mapper 对象
+     */
+    @Autowired
+    TbGoodsUnitsMapper tbGoodsUnitsMapper;
+
+    @Autowired
+    private MethodGoodsUnitsService methodGoodsUnitsService;
+
+    /**
+     * 增
+     */
+    void add(TbGoodsUnits t) {
+        save(t);
+    }
+
+    /**
+     * 删
+     */
+    void delete(Long id) {
+        removeById(id);
+    }
+
+    /**
+     * 改
+     */
+    void update(TbGoodsUnits t) {
+        updateById(t);
+
+    }
+
+    /**
+     * 查
+     */
+    TbGoodsUnits getById(Long id) {
+        return super.getById(id);
+    }
+
+    /**
+     * 查集合 - 根据条件(参数为空时代表忽略指定条件)
+     */
+    List<TbGoodsUnits> getList(SoMap so) {
+        return tbGoodsUnitsMapper.getList(so);
+    }
+
+    /**
+     * 导入
+     *
+     * @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 = methodGoodsUnitsService.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<TbGoodsUnits> selectedList = tbGoodsUnitsMapper.selectList(new LambdaQueryWrapper<TbGoodsUnits>().eq(StringUtils.isNoneBlank(keyword), TbGoodsUnits::getUnits, 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("管理商品的单位");
+
+        //定义计数器
+        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).getUnitsNo() + "").equals("null") ? "" : selectedList.get(i).getUnitsNo() + "");
+            sheetRow.createCell(2).setCellValue((selectedList.get(i).getUnits() + "").equals("null") ? "" : selectedList.get(i).getUnits() + "");
+
+            count += 1;
+        }
+        //建立输出流,输出文件
+        FileOutputStream fos = new FileOutputStream(filepath);
+
+        workbook.write(fos);
+        fos.flush();
+        //关闭输出流
+        fos.close();
+        workbook.close();
+        System.out.println("\n数据导出完成!共导出 " + count + " 条数据。");
+        return "数据导出完成!共导出 " + count + " 条数据。";
+    }
+
+    /**
+     * 根据编号查询
+     * @param code
+     * @return
+     */
+    public TbGoodsUnits findByCode(String code) {
+        List<TbGoodsUnits> list = tbGoodsUnitsMapper.selectList(new LambdaQueryWrapper<TbGoodsUnits>().eq(TbGoodsUnits::getUnitsNo, code));
+        return list.isEmpty() ? null : list.get(0);
+    }
 
 }

+ 1 - 1
sp-service/level-one-server/src/main/java/com/pj/tb_group/TbGroupController.java

@@ -205,7 +205,7 @@ public class TbGroupController {
 	/*------            正常业务👆👆    rpc远程调用👇👇                         -----------*/
 
 	/** 用户在APP注册时选择身份则创建一个对应身份的实体 */
-	@RequestMapping("rpc/groupDto")
+	@PostMapping("rpc/groupDto")
 	public boolean groupDto(@RequestBody HtGroupDto groupDto){
 		return tbGroupService.groupDto(groupDto);
 	}

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

@@ -12,6 +12,7 @@ import java.util.stream.Collectors;
 
 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.DclBorderList;
 import com.pj.api.dto.GroupDto;
@@ -25,6 +26,7 @@ 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 lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.hssf.usermodel.HSSFRow;
 import org.apache.poi.hssf.usermodel.HSSFSheet;
@@ -43,10 +45,12 @@ import javax.swing.filechooser.FileSystemView;
 
 /**
  * Service: tb_group -- 互助组
+ *
  * @author qzy
  */
 @Service
 @Transactional(rollbackFor = Exception.class)
+@Slf4j
 public class TbGroupService extends ServiceImpl<TbGroupMapper, TbGroup> implements IService<TbGroup> {
 
     /**
@@ -56,8 +60,8 @@ public class TbGroupService extends ServiceImpl<TbGroupMapper, TbGroup> implemen
     TbGroupMapper tbGroupMapper;
     @Autowired
     TbPeopleService tbPeopleService;
-	@Autowired
-	TbPeopleMapper tbPeopleMapper;
+    @Autowired
+    TbPeopleMapper tbPeopleMapper;
 
     @Autowired
     private MethodGroupService methodGroupService;
@@ -143,279 +147,290 @@ public class TbGroupService extends ServiceImpl<TbGroupMapper, TbGroup> implemen
         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 = tbPeopleMapper.selectById(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;
-
-	}
-
-	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;
-	}
-
-	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);
-	}
-
-	/**
-	 * 导入
-	 *
-	 * @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 = methodGroupService.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<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("当天该组剩余额度");
-
-		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("删除状态");
-
-		//定义计数器
-		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() + "");
-
-			//公共字段
-			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 i = tbPeopleMapper.updateById(tbPeople);
+            line = i + 1;
+        }
+        return line;
+
+    }
+
+    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;
+    }
+
+    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);
+    }
+
+    /**
+     * 导入
+     *
+     * @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 = methodGroupService.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<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("当天该组剩余额度");
+
+        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("删除状态");
+
+        //定义计数器
+        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() + "");
+
+            //公共字段
+            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 boolean groupDto(HtGroupDto groupDto) {
+        log.info("还是处理互助组信息:{}",JSONUtil.toJsonStr(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 tbGroup = this.findByAreaCodeAndSeqCode(tbTradeArea.getId(), groupDto.getPlatSeqNo());
+        if (tbGroup == null) {
+            tbGroup = new TbGroup();
+            BeanUtils.copyProperties(groupDto, tbGroup);
             //新增
             tbGroup.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode());
-            tbGroup.setCreateTime(new Date()).setTradeAreaId(tbTradeArea.getId()).setTradeAreaName(tbTradeArea.getName());
-         this.save(tbGroup);
+            tbGroup.setCreateTime(new Date())
+                    .setTradeAreaId(tbTradeArea.getId())
+                    .setTradeAreaName(tbTradeArea.getName());
+            this.save(tbGroup);
         }
-
         // 边民信息表体信息
         List<BorderDTO> borderDTOList = JSONUtil.toList(groupDto.getBorderList(), BorderDTO.class);
         //互助组边民代表(组长)表体信息
-		List<DclBorderList> dclBorderList = JSONUtil.toList(groupDto.getDclBorderList(), DclBorderList.class);
-
-        borderDTOList.forEach(borderDTO -> {
-			TbPeople tbPeople = tbPeopleService.findByIdCarNo(borderDTO.getIdCardNo());
-            if (tbPeople==null){
-                tbPeople=new TbPeople();
+        List<DclBorderList> dclBorderList = JSONUtil.toList(groupDto.getDclBorderList(), DclBorderList.class);
+        for (BorderDTO borderDTO : borderDTOList) {
+            TbPeople tbPeople = tbPeopleService.findByIdCarNo(borderDTO.getIdCardNo());
+            if (tbPeople == null) {
+                tbPeople = new TbPeople();
             }
-
             //判断当前边民是否是组长
-			List<DclBorderList> dclBorderList1 = dclBorderList.stream().filter(dclBorder -> dclBorder.getIdCardNo().equals(borderDTO.getIdCardNo())).collect(Collectors.toList());
-			if(dclBorderList1.size() > 0) {
-				tbPeople.setRole(2);//组长
-			} else {
-				tbPeople.setRole(1);//普通边民
-			}
+            List<DclBorderList> dclBorderList1 = dclBorderList.stream().filter(dclBorder -> dclBorder.getIdCardNo().equals(borderDTO.getIdCardNo())).collect(Collectors.toList());
+            if (dclBorderList1.size() > 0) {
+                tbPeople.setRole(2);//组长
+            } else {
+                tbPeople.setRole(1);//普通边民
+            }
 
             tbPeople.setGroupName(tbGroup.getOrgName()).setGroupId(tbGroup.getId()).setTradeAreaId(tbTradeArea.getId())
                     .setTradeAreaName(tbTradeArea.getName()).setUpdateTime(new Date());
             tbPeopleService.saveOrUpdate(tbPeople);
             //todo 继续同步边民信息
-        });
+        }
         //修改
-        BeanUtils.copyProperties(tbGroupList.get(0), tbGroup);
-        int i = tbGroupMapper.updateById(tbGroup);
-        return i == 1;
+        BeanUtils.copyProperties(groupDto, tbGroup);
+        tbGroup.setUpdateTime(new Date());
+        this.saveOrUpdate(tbGroup);
+        return true;
     }
 
-	/** 远程调用方法 获取边民组的基本信息*/
-	GroupDto getRpcById(String id) {
-		TbGroup byId = super.getById(id);
-		GroupDto groupDto = new GroupDto();
-		BeanUtils.copyProperties(byId,groupDto);
-		return groupDto;
-	}
+    public TbGroup findByAreaCodeAndSeqCode(Long tradeId, String platSeqNo) {
+        QueryWrapper<TbGroup> ew = new QueryWrapper<>();
+        ew.lambda().eq(TbGroup::getPlatSeqNo, platSeqNo).eq(TbGroup::getTradeAreaId, tradeId);
+        List<TbGroup> list = list(ew);
+        return list.isEmpty() ? null : list.get(0);
+    }
+
+    /**
+     * 远程调用方法 获取边民组的基本信息
+     */
+    GroupDto getRpcById(String id) {
+        TbGroup byId = super.getById(id);
+        GroupDto groupDto = new GroupDto();
+        BeanUtils.copyProperties(byId, groupDto);
+        return groupDto;
+    }
 
 }
 

+ 5 - 5
sp-service/level-one-server/src/main/java/com/pj/tb_order/TbOrderAppController.java

@@ -71,7 +71,7 @@ public class TbOrderAppController {
 	@RequestMapping("getResaleOrders")
 	public AjaxJson getResaleOrders() {
 		List<TbOrder> resaleOrders = tbOrderService.getResaleOrders();
-		return AjaxJson.getPageData(Long.valueOf(resaleOrders.size()), resaleOrders);
+		return AjaxJson.getPageData(resaleOrders.size(), resaleOrders);
 	}
 
 	/**
@@ -118,7 +118,7 @@ public class TbOrderAppController {
 	public AjaxJson getPeopleState() {
 		SoMap so = SoMap.getRequestSoMap();
 		List<PeopleConfirmVo> list = tbOrderService.getPeopleState(so);
-		return AjaxJson.getPageData(Long.valueOf(list.size()), list);
+		return AjaxJson.getPageData(so.getDataCount(), list);
 	}
 
 
@@ -168,20 +168,20 @@ public class TbOrderAppController {
 	}
 
 	/** 远程调用  修改订单的叫车状态 */
-	@RequestMapping("rpc/updateOrderCallCarStatus")
+	@PostMapping("rpc/updateOrderCallCarStatus")
 	public boolean updateOrderCallCarStatus(@RequestBody OrderDto orderDto){
 		boolean b = tbOrderService.updateOrderCallCarStatus(orderDto);
 		return b;
 	}
 
 	/** 改 转售状态:根据订单Id把订单改为已转售 */
-	@RequestMapping("rpc/updateResaleStatus")
+	@PostMapping("rpc/updateResaleStatus")
 	public boolean updateResaleStatus(@RequestParam("id")Long orderId) {
 		return tbOrderService.updateResaleStatus(orderId);
 	}
 
 	/** 远程调用 根据订单Id修改状态:在二级市场被下单[0=未被下单,1=已被下单] */
-	@RequestMapping("rpc/updateBeingOrder")
+	@PostMapping("rpc/updateBeingOrder")
 	public boolean updateBeingOrder(@RequestParam("id")Long levelOneOrderId) {
 		return tbOrderService.updateBeingOrder(levelOneOrderId);
 	}

+ 2 - 2
sp-service/level-one-server/src/main/java/com/pj/tb_people/TbPeopleController.java

@@ -113,7 +113,7 @@ public class TbPeopleController {
     @SaCheckPermission(TbPeople.PERMISSION_CODE)
     public AjaxJson getLeftPeople() {
         List<TbPeople> list = tbPeopleService.getLeftPeople();
-        return AjaxJson.getPageData(Long.valueOf(list.size()), list);
+        return AjaxJson.getPageData(list.size(), list);
     }
 
     /**
@@ -262,7 +262,7 @@ public class TbPeopleController {
     /**
      * 注册身份时对应的表添加数据
      */
-    @RequestMapping("rpc/peopleDto")
+    @PostMapping("rpc/peopleDto")
     public boolean peopleDto(@RequestBody HtPeopleDto peopleDto) throws Exception {
         boolean dto = tbPeopleService.peopleDto(peopleDto);
         return dto;

+ 1 - 1
sp-service/level-one-server/src/main/java/com/pj/tb_port_news/TbPortNews.java

@@ -94,7 +94,7 @@ public class TbPortNews extends Model<TbPortNews> implements Serializable {
 	/**
 	 * 状态(0=禁用,1=启用)
 	 */
-	private Integer status;
+	private Integer status=1;
 
 	/**
 	 * 创建者id

+ 4 - 22
sp-service/level-one-server/src/main/java/com/pj/tb_port_news/TbPortNewsService.java

@@ -96,9 +96,6 @@ public class TbPortNewsService extends ServiceImpl<TbPortNewsMapper, TbPortNews>
             throw new RuntimeException("口岸咨询不存在");
         }
         // 口岸咨询被禁用抛异常
-        if (tbPortNews.getStatus() == DeleteStatus.DELETE_STATUS_OFF.getCode()) {
-            throw new RuntimeException("当前口岸咨询已被禁用,不允许发布!");
-        }
         tbPortNews.setIsRelease(isRelease).setReleaseTime(new Date());
         tbPortNews.setUpdateBy(userInfo.getLoginId()).setUpdateName(userInfo.getLoginName()).setUpdateTime(new Date());
 
@@ -114,29 +111,14 @@ public class TbPortNewsService extends ServiceImpl<TbPortNewsMapper, TbPortNews>
      */
     public AjaxJson getNewestList(Long limit) {
         QueryWrapper<TbPortNews> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("status", 1).eq("is_release", ReleaseStatus.RELEASE_STATUS_PUBLISH.getCode()).orderByDesc("release_time").last("LIMIT " + limit);
+        queryWrapper
+                .eq("is_release", ReleaseStatus.RELEASE_STATUS_PUBLISH.getCode())
+                .orderByDesc("release_time")
+                .last("LIMIT " + limit);
         return AjaxJson.getSuccessData(list(queryWrapper));
     }
 
     /**
-     * APP端获取口岸资讯列表
-     *
-     * @author loovi
-     * @date
-     */
-    public AjaxJson getPortNewsList() {
-        // 构造条件查询资讯列表
-        QueryWrapper<TbPortNews> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("status", DeleteStatus.DELETE_STATUS_ON.getCode());
-        // 执行查询
-        List<TbPortNews> list = tbPortNewsMapper.selectList(queryWrapper);
-        // 将结果列表拷贝至VO列表
-        List<TbPortNewsVo> resList = CglibUtil.copyList(list, TbPortNewsVo::new);
-        // 返回获取的最新口岸资讯
-        return AjaxJson.getSuccess("口岸资讯列表", resList);
-    }
-
-    /**
      * APP端获取口岸资讯详情
      *
      * @author loovi

+ 1 - 1
sp-service/level-one-server/src/main/java/com/pj/tb_shop/TbShopAppController.java

@@ -39,7 +39,7 @@ public class TbShopAppController {
 	@RequestMapping("getAppList")
 	public AjaxJson getAppList() {
 		List<ShopVo> list = tbShopService.getAppList();
-		return AjaxJson.getPageData(Long.valueOf(list.size()), list);
+		return AjaxJson.getPageData(list.size(), list);
 	}
 
 

+ 2 - 3
sp-service/level-one-server/src/main/java/com/pj/tb_shop/TbShopController.java

@@ -131,10 +131,9 @@ public class TbShopController {
 
 	/*------            正常业务👆👆    rpc远程调用👇👇                         -----------*/
 
-	@RequestMapping("rpc/shopDto")
+	@PostMapping("rpc/shopDto")
 	public boolean shopDto(@RequestBody HtShopDTO shopDto) throws Exception {
-		boolean b = tbShopService.shopDto(shopDto);
-		return b;
+		return tbShopService.shopDto(shopDto);
 	}
 
 

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

@@ -75,7 +75,7 @@ public class TbTradeAreaController {
 
 	/** 查集合 - 根据条件(参数为空时代表忽略指定条件) */  
 	@RequestMapping("getList")
-		@SaCheckPermission(TbTradeArea.PERMISSION_CODE)
+	@SaCheckPermission(TbTradeArea.PERMISSION_CODE)
 	public AjaxJson getList() { 
 		SoMap so = SoMap.getRequestSoMap();
 		so.set("deleteStatus", 1);

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

@@ -262,7 +262,11 @@ public class TbTradeAreaService extends ServiceImpl<TbTradeAreaMapper, TbTradeAr
         TbTradeArea tbTradeArea = this.findByCode(tradeCode);
         if (tbTradeArea == null) {
             tbTradeArea = new TbTradeArea();
-            tbTradeArea.setCode(tradeCode).setName(fieldName).setCreateTime(new Date()).setCreateBy("async");
+            tbTradeArea.setCode(tradeCode)
+                    .setName(fieldName)
+                    .setCreateTime(new Date())
+                    .setDeleteStatus(1)
+                    .setCreateBy("async");
             this.save(tbTradeArea);
         } else {
             if (!StrUtil.isEmpty(fieldName)){

+ 6 - 7
sp-service/sp-admin/src/main/java/com/pj/project/app_user/AppUserController.java

@@ -94,7 +94,7 @@ public class AppUserController {
 
 
 	/** 启/停边民的app账号登陆限制 */
-	@RequestMapping("rpc/isLock")
+	@PostMapping("rpc/isLock")
 	public int isLock(@RequestParam("id") String id,
 						   @RequestParam("type") Integer type,
 						   @RequestParam("status") Integer status) {
@@ -109,7 +109,7 @@ public class AppUserController {
 		return appUser;
 	}
 	/** 商户认证 */
-	@RequestMapping("rpc/audit")
+	@PostMapping("rpc/audit")
 	public boolean audit(@RequestBody EnterpriseAuditDto dto){
 		AppUser user=new AppUser();
 		BeanUtils.copyProperties(dto, user);
@@ -120,7 +120,7 @@ public class AppUserController {
 	/**
 	 * 收购商认证
 	 */
-	@RequestMapping("rpc/saveAppUserInfo")
+	@PostMapping("rpc/saveAppUserInfo")
 	public Boolean saveAppUserInfo(@RequestBody AppUserDto appUser) {
 		boolean info = appUserService.saveAppUserInfo(appUser);
 		return info;
@@ -130,17 +130,16 @@ public class AppUserController {
 	/**
 	 * 同步航通边民信息时,自动给边民注册app账号
 	 */
-	@RequestMapping("rpc/generatePeopleAccount")
+	@PostMapping("rpc/generatePeopleAccount")
 	public boolean generatePeopleAccount(@RequestBody HtPeopleDto peopleDto) throws Exception {
-		boolean info = appUserService.generatePeopleAccount(peopleDto);
-		return info;
+		return appUserService.generatePeopleAccount(peopleDto);
 	}
 
 
 	/**
 	 * 同步航通边民信息时,自动给外籍商户注册app账号
 	 */
-	@RequestMapping("rpc/generateEnterpriseAccount")
+	@PostMapping("rpc/generateEnterpriseAccount")
 	public int generateEnterpriseAccount(@RequestBody EnterpriseDto enterpriseDto) throws Exception {
 		int account = appUserService.generateEnterpriseAccount(enterpriseDto);
 		return account;

+ 7 - 4
sp-service/sp-admin/src/main/java/com/pj/project/app_user/AppUserService.java

@@ -41,6 +41,7 @@ import com.pj.utils.sg.AjaxError;
 import com.pj.utils.sg.AjaxJson;
 import com.pj.utils.sg.WebNbUtil;
 import com.pj.utils.so.SoMap;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -60,6 +61,7 @@ import javax.annotation.Resource;
  */
 @Service
 @Transactional(rollbackFor = Exception.class)
+@Slf4j
 public class AppUserService extends ServiceImpl<AppUserMapper, AppUser> implements IService<AppUser> {
 
     /**
@@ -572,13 +574,13 @@ public class AppUserService extends ServiceImpl<AppUserMapper, AppUser> implemen
      */
     public boolean generatePeopleAccount(HtPeopleDto peopleDto) throws Exception {
         //检查是否重复注册
-        List<AppUser> appUsers = appUserMapper.selectList(new LambdaQueryWrapper<AppUser>().eq(AppUser::getPhone, peopleDto.getBorderTel()));
-        if (appUsers.size() != 0) {
+        AppUser appUser=this.findByPhone(peopleDto.getBorderTel());
+        if (appUser!=null) {
             log.error("\n该用户已注册! phone = " + peopleDto.getBorderTel() + "\n");
             return true;
         }
         //创建保存对象
-        AppUser appUser = new AppUser();
+         appUser = new AppUser();
         //设置基本属性
         appUser.setAuth(1 + ""); // 默认已认证
         appUser.setUserType(1); // 用户类型 1
@@ -591,7 +593,8 @@ public class AppUserService extends ServiceImpl<AppUserMapper, AppUser> implemen
         appUser.setFkId(peopleDto.getId()); // 外键
         appUser.setCreateUnit("航通");
         //随机生成6位数密码
-        String password = RandomUtil.randomNumbers(8);
+        String password = RandomUtil.randomNumbers(6);
+        log.info("生成账号:{},{}",peopleDto.getBorderTel(),password);
 //        String password=appUser.getPhone();
         //密码加密
         String encodePassword = passwordEncoder.encode(password + "");

+ 2 - 2
sp-service/sp-admin/src/main/java/com/pj/project4sp/admin4login/SpAccAdminService.java

@@ -76,14 +76,14 @@ public class SpAccAdminService {
 
         // 3、开始验证
         if (admin == null) {
-            return AjaxJson.getError("无此账号");
+            return AjaxJson.getError("账号或密码错误");
         }
         if (NbUtil.isNull(admin.getPassword2())) {
             return AjaxJson.getError("此账号尚未设置密码,无法登陆");
         }
         String md5Password = SystemObject.getPasswordMd5(admin.getId(), password);
         if (!admin.getPassword2().equals(md5Password)) {
-            return AjaxJson.getError("密码错误");
+            return AjaxJson.getError("账号或密码错误");
         }
 
         // 4、是否禁用

+ 1 - 1
sp-service/transport-server/src/main/java/com/pj/project/tb_logistics/TbLogisticsAppController.java

@@ -64,7 +64,7 @@ public class TbLogisticsAppController {
 	public AjaxJson selectByDriverId() {
 		SoMap so = SoMap.getRequestSoMap();
 		List<TbLogistics> list = tbLogisticsService.selectByDriverId(so.startPage());
-		return AjaxJson.getPageData(Long.valueOf(list.size()), list);
+		return AjaxJson.getPageData(list.size(), list);
 	}
 
 }