diff --git a/order-management-base-service/src/main/java/com/dxhy/order/baseservice/module/commodity/model/CommodityCodeEntity.java b/order-management-base-service/src/main/java/com/dxhy/order/baseservice/module/commodity/model/CommodityCodeEntity.java index e2765b2e..b9bf244b 100644 --- a/order-management-base-service/src/main/java/com/dxhy/order/baseservice/module/commodity/model/CommodityCodeEntity.java +++ b/order-management-base-service/src/main/java/com/dxhy/order/baseservice/module/commodity/model/CommodityCodeEntity.java @@ -189,6 +189,16 @@ public class CommodityCodeEntity implements Serializable { */ private String jdc; + /** + * mdm物料分类编码 + */ + private String wlflbm; + + /** + * mdm物料分类名称 + */ + private String wlflmc; + private String UUID; private Boolean success; diff --git a/order-management-base-service/src/main/resources/mybatis/mapper/CommodityMapper.xml b/order-management-base-service/src/main/resources/mybatis/mapper/CommodityMapper.xml index 0f203011..8e7cef07 100644 --- a/order-management-base-service/src/main/resources/mybatis/mapper/CommodityMapper.xml +++ b/order-management-base-service/src/main/resources/mybatis/mapper/CommodityMapper.xml @@ -38,6 +38,8 @@ + + @@ -45,7 +47,7 @@ tax_rate, specification_model, metering_unit, unit_price, tax_logo, hide_the_logo, enjoy_preferential_policies, tax_class_code, tax_classification_name, preferential_policies_type,zzstsgl, user_id, create_time, modify_time, modify_user_id, group_id,enterprise_name,data_source, - matching_state,data_state,tax_class_abbreviation,description,collect_ident,cpy,bmb_bbh,jdc + matching_state,data_state,tax_class_abbreviation,description,collect_ident,cpy,bmb_bbh,jdc,wlflbm,wlflmc @@ -87,6 +89,8 @@ cc.jdc, cc.bmb_bbh, gc.group_name + cc.wlflbm, + cc.wlflmc, FROM commodity_code cc LEFT JOIN group_commodity gc ON gc.id = cc.group_id @@ -107,6 +111,7 @@ #{item} + and cc.xhf_nsrsbh != '-1' AND cc.id = #{map.id,jdbcType=VARCHAR} @@ -311,6 +316,12 @@ jdc = #{commodityCode.jdc,jdbcType=VARCHAR}, + + wlflbm = #{commodityCode.wlflbm,jdbcType=VARCHAR}, + + + wlflmc = #{commodityCode.wlflmc,jdbcType=VARCHAR}, + @@ -439,6 +450,12 @@ jdc, + + wlflbm, + + + wlflmc, + @@ -545,6 +562,12 @@ #{jdc,jdbcType=VARCHAR}, + + #{wlflbm,jdbcType=VARCHAR}, + + + #{wlflmc,jdbcType=VARCHAR}, + @@ -651,6 +674,12 @@ jdc, + + wlflbm, + + + wlflmc, + @@ -757,6 +786,12 @@ #{jdc,jdbcType=VARCHAR}, + + #{wlflbm,jdbcType=VARCHAR}, + + + #{wlflmc,jdbcType=VARCHAR}, + ON DUPLICATE KEY UPDATE @@ -858,6 +893,12 @@ jdc = VALUES(jdc), + + wlflbm = VALUES(wlflbm), + + + wlflmc = VALUES(wlflmc), + @@ -975,6 +1016,7 @@ #{item} + and cc.xhf_nsrsbh != '-1' limit 1000 @@ -989,6 +1031,7 @@ WHERE t.collect_ident is null AND t.matching_state = '0' AND t.data_state = '0' + and t.xhf_nsrsbh != '-1' AND ( t.data_source = '1' OR t.data_source = '2' @@ -1043,6 +1086,7 @@ #{item} + and xhf_nsrsbh != '-1' @@ -1092,6 +1136,7 @@ #{item} + and cc.xhf_nsrsbh != '-1' @@ -1143,6 +1188,7 @@ AND cc.jdc = 'N' + and cc.xhf_nsrsbh != '-1' @@ -1198,6 +1244,7 @@ AND cc.jdc = 'N' + and cc.xhf_nsrsbh != '-1' diff --git a/order-management-base-service/src/main/resources/mybatis/mapper/GroupCommodityMapper.xml b/order-management-base-service/src/main/resources/mybatis/mapper/GroupCommodityCodeMapper.xml similarity index 100% rename from order-management-base-service/src/main/resources/mybatis/mapper/GroupCommodityMapper.xml rename to order-management-base-service/src/main/resources/mybatis/mapper/GroupCommodityCodeMapper.xml diff --git a/order-management-common/pom.xml b/order-management-common/pom.xml index 5ef958fb..36af9bc2 100644 --- a/order-management-common/pom.xml +++ b/order-management-common/pom.xml @@ -95,5 +95,14 @@ - + + + nexus-myself + http://172.31.32.53:8081/repository/sndt-local + + + nexus-myself + http://172.31.32.53:8081/repository/sndt-local + + diff --git a/order-management-consumer/pom.xml b/order-management-consumer/pom.xml index 726a18a3..2d3e186a 100644 --- a/order-management-consumer/pom.xml +++ b/order-management-consumer/pom.xml @@ -504,6 +504,11 @@ compile + + org.springframework.boot + spring-boot-starter-mail + + order-api diff --git a/order-management-consumer/src/main/java/com/dxhy/order/consumer/dao/GroupCommodityCodeMapper.java b/order-management-consumer/src/main/java/com/dxhy/order/consumer/dao/GroupCommodityCodeMapper.java new file mode 100644 index 00000000..d8dc9eb2 --- /dev/null +++ b/order-management-consumer/src/main/java/com/dxhy/order/consumer/dao/GroupCommodityCodeMapper.java @@ -0,0 +1,35 @@ +package com.dxhy.order.consumer.dao; + +import com.dxhy.order.baseservice.module.commodity.model.CommodityCodeEntity; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @Description 集团物料库 集团物料库和 + * @Author 巩权林 + * @Date 2023/3/9 10:36 + **/ +public interface GroupCommodityCodeMapper { + + /** + * 查询集团物料库 + * + * @param commodityCodeEntity + * @return + */ + List queryGroupCommodityCodeList(CommodityCodeEntity commodityCodeEntity); + + + /** + * 根据物料编码和销方税号查询物料信息 + * + * @param zxbm + * @param xhfNsrsbh + * @return + */ + CommodityCodeEntity queryCommodityCodeByZxbmAndXhfNsrsbh(@Param("zxbm") String zxbm, @Param("xhfNsrsbh") String xhfNsrsbh); + + + int insertCommodityCode(CommodityCodeEntity entity); +} diff --git a/order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/commodity/controller/GroupCommodityCodeController.java b/order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/commodity/controller/GroupCommodityCodeController.java new file mode 100644 index 00000000..3d2d4017 --- /dev/null +++ b/order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/commodity/controller/GroupCommodityCodeController.java @@ -0,0 +1,51 @@ +package com.dxhy.order.consumer.modules.commodity.controller; + +import cn.hutool.json.JSONObject; +import com.dxhy.order.consumer.modules.commodity.domain.dto.QueryGroupCommodityDTO; +import com.dxhy.order.consumer.modules.commodity.domain.dto.QuoteGroupCommodityDTO; +import com.dxhy.order.consumer.modules.commodity.service.IGroupCommodityCodeService; +import com.dxhy.order.model.PageUtils; +import com.dxhy.order.model.R; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + +/** + * @Description 集团物料库 + * @Author 巩权林 + * @Date 2023/3/9 08:19 + **/ +@RequestMapping(value = "/groupCommodity") +@RestController +@Slf4j +public class GroupCommodityCodeController { + + private final static String LOGGER_MSG = "(集团物料库)"; + + @Autowired + private IGroupCommodityCodeService groupCommodityCodeService; + + @GetMapping("/list") + public R list(QueryGroupCommodityDTO queryGroupCommodityDTO) { + try { + PageUtils pageUtil = groupCommodityCodeService.queryGroupCommodityCodeList(queryGroupCommodityDTO); + return R.ok().put("page", pageUtil); + } catch (NumberFormatException e) { + log.error("{},分页参数类型转换异常:{}", LOGGER_MSG, e.getMessage()); + return R.error("商品信息列表查询异常"); + } + } + + /** + * 物料引用 + * + * @return + */ + @PostMapping("/quote") + public R quote(@RequestBody @Validated QuoteGroupCommodityDTO dto) { + return groupCommodityCodeService.quoteGroupCommodityCode(dto); + } +} diff --git a/order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/commodity/domain/dto/PageBaseDTO.java b/order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/commodity/domain/dto/PageBaseDTO.java new file mode 100644 index 00000000..a6b10058 --- /dev/null +++ b/order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/commodity/domain/dto/PageBaseDTO.java @@ -0,0 +1,30 @@ +package com.dxhy.order.consumer.modules.commodity.domain.dto; + +import lombok.Data; + +/** + * @Description 带分页的基础dto + * @Author 巩权林 + * @Date 2023/3/9 10:09 + **/ +public class PageBaseDTO { + + private Integer currPage; + private Integer pageSize; + + public Integer getCurrPage() { + return currPage == null ? 0 : currPage; + } + + public void setCurrPage(Integer currPage) { + this.currPage = currPage; + } + + public Integer getPageSize() { + return pageSize == null ? 0 : pageSize; + } + + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; + } +} diff --git a/order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/commodity/domain/dto/QueryGroupCommodityDTO.java b/order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/commodity/domain/dto/QueryGroupCommodityDTO.java new file mode 100644 index 00000000..3db07c0f --- /dev/null +++ b/order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/commodity/domain/dto/QueryGroupCommodityDTO.java @@ -0,0 +1,32 @@ +package com.dxhy.order.consumer.modules.commodity.domain.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotBlank; + +/** + * @Description 集团物料编码查询 + * @Author 巩权林 + * @Date 2023/3/9 08:22 + **/ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class QueryGroupCommodityDTO extends PageBaseDTO { + + // 物料分类编码 + private String wlflbm; + + // 物料分类名称 + private String wlflmc; + + // 物料自行编码 + private String zxbm; + + // 物料名称 + private String xmmc; +} diff --git a/order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/commodity/domain/dto/QuoteGroupCommodityDTO.java b/order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/commodity/domain/dto/QuoteGroupCommodityDTO.java new file mode 100644 index 00000000..2ae712b2 --- /dev/null +++ b/order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/commodity/domain/dto/QuoteGroupCommodityDTO.java @@ -0,0 +1,23 @@ +package com.dxhy.order.consumer.modules.commodity.domain.dto; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +/** + * @Description 引用物料 + * @Author 巩权林 + * @Date 2023/3/9 11:01 + **/ +@Data +public class QuoteGroupCommodityDTO { + + /** + * 自行编码 + */ + @NotBlank(message = "物料编码不能为空!") + private String zxbm; + + @NotBlank(message = "接收引用物料的销方纳税人识别号不能为空!") + private String xhfNsrsbh; +} diff --git a/order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/commodity/service/IGroupCommodityCodeService.java b/order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/commodity/service/IGroupCommodityCodeService.java new file mode 100644 index 00000000..881d1f71 --- /dev/null +++ b/order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/commodity/service/IGroupCommodityCodeService.java @@ -0,0 +1,20 @@ +package com.dxhy.order.consumer.modules.commodity.service; + +import com.dxhy.order.consumer.modules.commodity.domain.dto.QueryGroupCommodityDTO; +import com.dxhy.order.consumer.modules.commodity.domain.dto.QuoteGroupCommodityDTO; +import com.dxhy.order.model.PageUtils; +import com.dxhy.order.model.R; + +import java.util.List; + +/** + * @Description 集团物料库 + * @Author 巩权林 + * @Date 2023/3/9 10:06 + **/ +public interface IGroupCommodityCodeService { + + PageUtils queryGroupCommodityCodeList(QueryGroupCommodityDTO queryGroupCommodityDTO); + + R quoteGroupCommodityCode(QuoteGroupCommodityDTO quoteGroupCommodityDTO); +} diff --git a/order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/commodity/service/impl/GroupCommodityCodeServiceImpl.java b/order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/commodity/service/impl/GroupCommodityCodeServiceImpl.java new file mode 100644 index 00000000..2ed9fa03 --- /dev/null +++ b/order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/commodity/service/impl/GroupCommodityCodeServiceImpl.java @@ -0,0 +1,116 @@ +package com.dxhy.order.consumer.modules.commodity.service.impl; + +import com.dxhy.order.baseservice.module.base.service.BaseService; +import com.dxhy.order.baseservice.module.commodity.model.CommodityCodeEntity; +import com.dxhy.order.constant.ConfigureConstant; +import com.dxhy.order.consumer.dao.GroupCommodityCodeMapper; +import com.dxhy.order.consumer.modules.commodity.domain.dto.QueryGroupCommodityDTO; +import com.dxhy.order.consumer.modules.commodity.domain.dto.QuoteGroupCommodityDTO; +import com.dxhy.order.consumer.modules.commodity.service.IGroupCommodityCodeService; +import com.dxhy.order.model.PageUtils; +import com.dxhy.order.model.R; +import com.dxhy.order.utils.CommonUtils; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.beanutils.BeanUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.lang.reflect.InvocationTargetException; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @Description + * @Author 巩权林 + * @Date 2023/3/9 10:06 + **/ +@Service +@Slf4j +public class GroupCommodityCodeServiceImpl implements IGroupCommodityCodeService { + + private final static String LOGGER_MSG = "(集团物料库)"; + + @Autowired + private GroupCommodityCodeMapper groupCommodityMapper; + + @Resource + private BaseService baseService; + + /** + * 查询集团物料库 + * + * @param queryGroupCommodityDTO + * @param shList + * @return + */ + @Override + public PageUtils queryGroupCommodityCodeList(QueryGroupCommodityDTO queryGroupCommodityDTO) { + int pageSize = queryGroupCommodityDTO.getPageSize(); + int currPage = queryGroupCommodityDTO.getCurrPage(); + PageHelper.startPage(currPage, pageSize); + CommodityCodeEntity query = new CommodityCodeEntity(); + query.setWlflbm(queryGroupCommodityDTO.getWlflbm()); + query.setWlflmc(queryGroupCommodityDTO.getWlflmc()); + query.setZxbm(queryGroupCommodityDTO.getZxbm()); + query.setXmmc(queryGroupCommodityDTO.getXmmc()); + List result = groupCommodityMapper.queryGroupCommodityCodeList(query); + result = result.stream().map(i -> { + if (StringUtils.isNotEmpty(i.getSl())) { + i.setSl(CommonUtils.formatSl(i.getSl())); + } + return i; + }).collect(Collectors.toList()); + PageInfo pageInfo = new PageInfo<>(result); + return new PageUtils(pageInfo.getList(), (int) pageInfo.getTotal(), pageInfo.getPageSize(), pageInfo.getPageNum()); + } + + /** + * 引用物料 + * + * @param quoteGroupCommodityDTO + * @return + */ + @Override + public R quoteGroupCommodityCode(QuoteGroupCommodityDTO quoteGroupCommodityDTO) { + // 判断销方税号是否合法,因为某些情况下可能会传递list过来 + if (StringUtils.isBlank(quoteGroupCommodityDTO.getXhfNsrsbh())) { + return R.error(ConfigureConstant.STRING_0000, "销方税号不能为空"); + } + + if (quoteGroupCommodityDTO.getXhfNsrsbh().contains(ConfigureConstant.STRING_CHARSET_1)) { + return R.error(ConfigureConstant.STRING_0000, "销方税号非法"); + } + + CommodityCodeEntity commodityCodeEntity = groupCommodityMapper.queryCommodityCodeByZxbmAndXhfNsrsbh(quoteGroupCommodityDTO.getZxbm(), quoteGroupCommodityDTO.getXhfNsrsbh()); + // 根据文档4.2.1.2 (6) 若物料编码重复时,引用后不对子公司物料进行更新 + if (commodityCodeEntity != null) { + return R.ok(); + } + + commodityCodeEntity = groupCommodityMapper.queryCommodityCodeByZxbmAndXhfNsrsbh(quoteGroupCommodityDTO.getZxbm(), "-1"); + if (commodityCodeEntity == null) { + return R.error("引用失败,集团物料不存在"); + } + + CommodityCodeEntity newCommodityCodeEntity = new CommodityCodeEntity(); + try { + BeanUtils.copyProperties(newCommodityCodeEntity, commodityCodeEntity); + } catch (IllegalAccessException e) { + log.error("{}引用物料异常", LOGGER_MSG, e); + } catch (InvocationTargetException e) { + log.error("{}引用物料异常", LOGGER_MSG, e); + } + + newCommodityCodeEntity.setId(baseService.getGenerateShotKey()); + newCommodityCodeEntity.setXhfNsrsbh(quoteGroupCommodityDTO.getXhfNsrsbh()); + if (groupCommodityMapper.insertCommodityCode(newCommodityCodeEntity) > 0) { + return R.ok(); + } else { + return R.error("引用失败"); + } + } +} diff --git a/order-management-consumer/src/main/java/com/dxhy/order/consumer/openapi/protocol/v6/sdenergy/MdmSyncGroupTaxCodeReqBO.java b/order-management-consumer/src/main/java/com/dxhy/order/consumer/openapi/protocol/v6/sdenergy/MdmSyncGroupTaxCodeReqBO.java index 07552f35..57515382 100644 --- a/order-management-consumer/src/main/java/com/dxhy/order/consumer/openapi/protocol/v6/sdenergy/MdmSyncGroupTaxCodeReqBO.java +++ b/order-management-consumer/src/main/java/com/dxhy/order/consumer/openapi/protocol/v6/sdenergy/MdmSyncGroupTaxCodeReqBO.java @@ -16,6 +16,12 @@ public class MdmSyncGroupTaxCodeReqBO { private String DESCSHORT; private String UUID; + // 物料分类编码 + private String CATEGORYNAME; + + // 物料分类名称 + private String CATEGORYCODE; + public void setCODE(String CODE) { this.CODE = CODE; } @@ -56,4 +62,19 @@ public class MdmSyncGroupTaxCodeReqBO { return UUID; } + public String getCATEGORYNAME() { + return CATEGORYNAME; + } + + public void setCATEGORYNAME(String CATEGORYNAME) { + this.CATEGORYNAME = CATEGORYNAME; + } + + public String getCATEGORYCODE() { + return CATEGORYCODE; + } + + public void setCATEGORYCODE(String CATEGORYCODE) { + this.CATEGORYCODE = CATEGORYCODE; + } } \ No newline at end of file diff --git a/order-management-consumer/src/main/java/com/dxhy/order/consumer/openapi/service/impl/SDEnregyServiceImpl.java b/order-management-consumer/src/main/java/com/dxhy/order/consumer/openapi/service/impl/SDEnregyServiceImpl.java index 4274b994..8cdf99fc 100644 --- a/order-management-consumer/src/main/java/com/dxhy/order/consumer/openapi/service/impl/SDEnregyServiceImpl.java +++ b/order-management-consumer/src/main/java/com/dxhy/order/consumer/openapi/service/impl/SDEnregyServiceImpl.java @@ -1,6 +1,7 @@ package com.dxhy.order.consumer.openapi.service.impl; import com.alibaba.fastjson.JSONObject; +import com.dxhy.order.baseservice.module.base.service.BaseService; import com.dxhy.order.baseservice.module.buyer.dao.BuyerMapper; import com.dxhy.order.baseservice.module.buyer.model.BuyerEntity; import com.dxhy.order.baseservice.module.commodity.dao.CommodityMapper; @@ -19,6 +20,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; +import javax.annotation.Resource; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -43,6 +45,9 @@ public class SDEnregyServiceImpl extends SDEnregyServiceAbstract { @Autowired private UserInfoService userInfoService; + @Resource + private BaseService baseService; + @Override public AjaxResult syncBuyerMessage(List mdmGmfxxtbReqBOS, String requestBody) { // 存表 @@ -156,6 +161,9 @@ public class SDEnregyServiceImpl extends SDEnregyServiceAbstract { commodityCodeEntity.setCreateTime(new Date()); commodityCodeEntity.setBz(reqBO.getDESCSHORT()); commodityCodeEntity.setUUID(reqBO.getUUID()); + commodityCodeEntity.setWlflbm(reqBO.getCATEGORYCODE()); + commodityCodeEntity.setWlflmc(reqBO.getCATEGORYNAME()); + commodityCodeEntity.setCommodityId(baseService.getGenerateShotKey()); commodityCodeEntity.setXhfNsrsbh("-1"); if (commodityMapper.insertCommodityOnDuplicateKey(commodityCodeEntity) > 0) { commodityCodeEntity.setSuccess(true); diff --git a/order-management-consumer/src/main/resources/bootstrap-std.yaml b/order-management-consumer/src/main/resources/bootstrap-std.yaml index 58f980cd..08db4069 100644 --- a/order-management-consumer/src/main/resources/bootstrap-std.yaml +++ b/order-management-consumer/src/main/resources/bootstrap-std.yaml @@ -4,13 +4,14 @@ spring: nacos: config: # Nacos config 地址 - server-addr: nacos-1.itax.local:33000 +# server-addr: nacos-1.itax.local:33000 + server-addr: 172.31.36.147:33000 # Nacos config 命名空间,对应配置中的名称(sims_order_namespace) namespace: a049b41c-b0a8-4a66-91b1-f3f3cab0e524 # Nacos config 分组 group: sims-order-config # Nacos config 登录用户名 - username: admin + username: nacos # Nacos config 登录密码 password: Invoice.nacos.!1 # Nacos config 配置文件前缀 diff --git a/order-management-consumer/src/main/resources/bootstrap.yaml b/order-management-consumer/src/main/resources/bootstrap.yaml index 3ccead84..563d27e2 100644 --- a/order-management-consumer/src/main/resources/bootstrap.yaml +++ b/order-management-consumer/src/main/resources/bootstrap.yaml @@ -7,6 +7,8 @@ spring: profiles: # Spring 配置文件读取 active: @deployType@ +# active: dev +# active: std #active: test jackson: # jackson 日期格式化 diff --git a/order-management-consumer/src/main/resources/mybatis/mapper/GroupCommodityCodeMapper.xml b/order-management-consumer/src/main/resources/mybatis/mapper/GroupCommodityCodeMapper.xml new file mode 100644 index 00000000..fecca133 --- /dev/null +++ b/order-management-consumer/src/main/resources/mybatis/mapper/GroupCommodityCodeMapper.xml @@ -0,0 +1,1395 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id + , commodity_id, sort_id, xhf_nsrsbh, merchandise_name,encoding, tax_items, brief_code, + tax_rate, specification_model, metering_unit, unit_price, tax_logo, hide_the_logo, + enjoy_preferential_policies, tax_class_code, tax_classification_name, preferential_policies_type,zzstsgl, + user_id, create_time, modify_time, modify_user_id, group_id,enterprise_name,data_source, + matching_state,data_state,tax_class_abbreviation,description,collect_ident,cpy,bmb_bbh,jdc,wlflbm,wlflmc + + + + SELECT cc.id, + cc.commodity_id, + cc.sort_id, + cc.xhf_nsrsbh, + cc.merchandise_name, + cc.tax_items, + cc.brief_code, + cc.tax_rate, + cc.specification_model, + cc.metering_unit, + cc.unit_price, + cc.tax_logo, + cc.hide_the_logo, + cc.enjoy_preferential_policies, + cc.tax_class_code, + cc.tax_classification_name, + cc.preferential_policies_type, + cc.zzstsgl, + cc.user_id, + cc.create_time, + cc.modify_time, + cc.modify_user_id, + cc.encoding, + cc.group_id, + cc.enterprise_name, + cc.data_source, + cc.matching_state, + cc.data_state, + cc.tax_class_abbreviation, + cc.description, + cc.cpy, + cc.jdc, + cc.bmb_bbh, + gc.group_name, + cc.wlflbm, + cc.wlflmc + FROM commodity_code cc + LEFT JOIN group_commodity gc + ON gc.id = cc.group_id + + + + + + + + + + + + insert into commodity_code + + + id, + + + commodity_id, + + + sort_id, + + + xhf_nsrsbh, + + + merchandise_name, + + + encoding, + + + tax_items, + + + brief_code, + + + tax_rate, + + + specification_model, + + + metering_unit, + + + unit_price, + + + tax_logo, + + + hide_the_logo, + + + enjoy_preferential_policies, + + + tax_class_code, + + + tax_classification_name, + + + preferential_policies_type, + + + zzstsgl, + + + user_id, + + create_time, + modify_time, + + modify_user_id, + + + group_id, + + + description, + + + enterprise_name, + + + data_source, + + + matching_state, + + + data_state, + + + tax_class_abbreviation, + + + collect_ident, + + + cpy, + + + bmb_bbh, + + + jdc, + + + wlflbm, + + + wlflmc, + + + + + #{id,jdbcType=VARCHAR}, + + + #{commodityId,jdbcType=VARCHAR}, + + + #{sortId,jdbcType=BIGINT}, + + + #{xhfNsrsbh,jdbcType=VARCHAR}, + + + #{xmmc,jdbcType=VARCHAR}, + + + #{zxbm,jdbcType=VARCHAR}, + + + #{spsm,jdbcType=VARCHAR}, + + + #{spjm,jdbcType=VARCHAR}, + + + #{sl,jdbcType=VARCHAR}, + + + #{ggxh,jdbcType=VARCHAR}, + + + #{xmdw,jdbcType=VARCHAR}, + + + #{xmdj,jdbcType=VARCHAR}, + + + #{hsbz,jdbcType=VARCHAR}, + + + #{ycbz,jdbcType=VARCHAR}, + + + #{yhzcbs,jdbcType=VARCHAR}, + + + #{spbm,jdbcType=VARCHAR}, + + + #{ssflMc,jdbcType=VARCHAR}, + + + #{lslbs,jdbcType=VARCHAR}, + + + #{zzstsgl,jdbcType=VARCHAR}, + + + #{userId,jdbcType=VARCHAR}, + + + now(), + now(), + + + SYSDATE, + SYSDATE, + + + #{modifyUserId,jdbcType=CHAR}, + + + #{groupId,jdbcType=VARCHAR}, + + + #{bz,jdbcType=VARCHAR}, + + + #{xhfMc,jdbcType=VARCHAR}, + + + #{dataSource,jdbcType=VARCHAR}, + + + #{matchingState,jdbcType=VARCHAR}, + + + #{dataState,jdbcType=VARCHAR}, + + + #{spjc,jdbcType=VARCHAR}, + + + #{collectIdent,jdbcType=VARCHAR}, + + + #{cpy,jdbcType=VARCHAR}, + + + #{bmbBbh,jdbcType=VARCHAR}, + + + #{jdc,jdbcType=VARCHAR}, + + + #{wlflbm,jdbcType=VARCHAR}, + + + #{wlflmc,jdbcType=VARCHAR}, + + + + + + + + + update commodity_code + + + commodity_id = #{commodityCode.commodityId,jdbcType=VARCHAR}, + + + sort_id = #{commodityCode.sortId,jdbcType=BIGINT}, + + + xhf_nsrsbh = #{commodityCode.xhfNsrsbh,jdbcType=VARCHAR}, + + + merchandise_name = #{commodityCode.xmmc,jdbcType=VARCHAR}, + + + encoding = #{commodityCode.zxbm,jdbcType=VARCHAR}, + + + tax_items = #{commodityCode.spsm,jdbcType=VARCHAR}, + + + brief_code = #{commodityCode.spjm,jdbcType=VARCHAR}, + + + tax_rate = #{commodityCode.sl,jdbcType=VARCHAR}, + + + specification_model = #{commodityCode.ggxh,jdbcType=VARCHAR}, + + + metering_unit = #{commodityCode.xmdw,jdbcType=VARCHAR}, + + + unit_price = #{commodityCode.xmdj,jdbcType=VARCHAR}, + + + tax_logo = #{commodityCode.hsbz,jdbcType=VARCHAR}, + + + hide_the_logo = #{commodityCode.ycbz,jdbcType=VARCHAR}, + + + enjoy_preferential_policies = #{commodityCode.yhzcbs,jdbcType=VARCHAR}, + + + tax_class_code = #{commodityCode.spbm,jdbcType=VARCHAR}, + + + tax_classification_name = #{commodityCode.ssflMc,jdbcType=VARCHAR}, + + + preferential_policies_type = #{commodityCode.lslbs,jdbcType=VARCHAR}, + + + zzstsgl = #{commodityCode.zzstsgl,jdbcType=VARCHAR}, + + + user_id = #{commodityCode.userId,jdbcType=VARCHAR}, + + + create_time = #{commodityCode.createTime,jdbcType=TIMESTAMP}, + + + modify_time = now(), + + + modify_time = SYSDATE, + + + modify_user_id = #{commodityCode.modifyUserId,jdbcType=CHAR}, + + + group_id = #{commodityCode.groupId,jdbcType=VARCHAR}, + + + description = #{commodityCode.bz,jdbcType=VARCHAR}, + + + enterprise_name = #{commodityCode.xhfMc,jdbcType=VARCHAR}, + + + data_source = #{commodityCode.dataSource,jdbcType=VARCHAR}, + + + matching_state = #{commodityCode.matchingState,jdbcType=VARCHAR}, + + + data_state = #{commodityCode.dataState,jdbcType=VARCHAR}, + + + tax_class_abbreviation = #{commodityCode.spjc,jdbcType=VARCHAR}, + + + collect_ident = #{commodityCode.collectIdent,jdbcType=VARCHAR}, + + + cpy = #{commodityCode.cpy,jdbcType=VARCHAR}, + + + bmb_bbh = #{commodityCode.bmbBbh,jdbcType=VARCHAR}, + + + jdc = #{commodityCode.jdc,jdbcType=VARCHAR}, + + + wlflbm = #{commodityCode.wlflbm,jdbcType=VARCHAR}, + + + wlflmc = #{commodityCode.wlflmc,jdbcType=VARCHAR}, + + + + + AND id = #{commodityCode.id,jdbcType=VARCHAR} + + + + and xhf_nsrsbh = '' + + + and xhf_nsrsbh = + + #{item} + + + + and xhf_nsrsbh in + + #{item} + + + + + + + + + insert into commodity_code + + + id, + + + commodity_id, + + + sort_id, + + + xhf_nsrsbh, + + + merchandise_name, + + + encoding, + + + tax_items, + + + brief_code, + + + tax_rate, + + + specification_model, + + + metering_unit, + + + unit_price, + + + tax_logo, + + + hide_the_logo, + + + enjoy_preferential_policies, + + + tax_class_code, + + + tax_classification_name, + + + preferential_policies_type, + + + zzstsgl, + + + user_id, + + create_time, + modify_time, + + modify_user_id, + + + group_id, + + + description, + + + enterprise_name, + + + data_source, + + + matching_state, + + + data_state, + + + tax_class_abbreviation, + + + collect_ident, + + + cpy, + + + bmb_bbh, + + + jdc, + + + wlflbm, + + + wlflmc, + + + + + #{id,jdbcType=VARCHAR}, + + + #{commodityId,jdbcType=VARCHAR}, + + + #{sortId,jdbcType=BIGINT}, + + + #{xhfNsrsbh,jdbcType=VARCHAR}, + + + #{xmmc,jdbcType=VARCHAR}, + + + #{zxbm,jdbcType=VARCHAR}, + + + #{spsm,jdbcType=VARCHAR}, + + + #{spjm,jdbcType=VARCHAR}, + + + #{sl,jdbcType=VARCHAR}, + + + #{ggxh,jdbcType=VARCHAR}, + + + #{xmdw,jdbcType=VARCHAR}, + + + #{xmdj,jdbcType=VARCHAR}, + + + #{hsbz,jdbcType=VARCHAR}, + + + #{ycbz,jdbcType=VARCHAR}, + + + #{yhzcbs,jdbcType=VARCHAR}, + + + #{spbm,jdbcType=VARCHAR}, + + + #{ssflMc,jdbcType=VARCHAR}, + + + #{lslbs,jdbcType=VARCHAR}, + + + #{zzstsgl,jdbcType=VARCHAR}, + + + #{userId,jdbcType=VARCHAR}, + + + now(), + now(), + + + SYSDATE, + SYSDATE, + + + #{modifyUserId,jdbcType=CHAR}, + + + #{groupId,jdbcType=VARCHAR}, + + + #{bz,jdbcType=VARCHAR}, + + + #{xhfMc,jdbcType=VARCHAR}, + + + #{dataSource,jdbcType=VARCHAR}, + + + #{matchingState,jdbcType=VARCHAR}, + + + #{dataState,jdbcType=VARCHAR}, + + + #{spjc,jdbcType=VARCHAR}, + + + #{collectIdent,jdbcType=VARCHAR}, + + + #{cpy,jdbcType=VARCHAR}, + + + #{bmbBbh,jdbcType=VARCHAR}, + + + #{jdc,jdbcType=VARCHAR}, + + + #{wlflbm,jdbcType=VARCHAR}, + + + #{wlflmc,jdbcType=VARCHAR}, + + + + + + + + insert into commodity_code + + + id, + + + commodity_id, + + + sort_id, + + + xhf_nsrsbh, + + + merchandise_name, + + + encoding, + + + tax_items, + + + brief_code, + + + tax_rate, + + + specification_model, + + + metering_unit, + + + unit_price, + + + tax_logo, + + + hide_the_logo, + + + enjoy_preferential_policies, + + + tax_class_code, + + + tax_classification_name, + + + preferential_policies_type, + + + zzstsgl, + + + user_id, + + create_time, + modify_time, + + modify_user_id, + + + group_id, + + + description, + + + enterprise_name, + + + data_source, + + + matching_state, + + + data_state, + + + tax_class_abbreviation, + + + collect_ident, + + + cpy, + + + bmb_bbh, + + + jdc, + + + wlflbm, + + + wlflmc, + + + + + #{id,jdbcType=VARCHAR}, + + + #{commodityId,jdbcType=VARCHAR}, + + + #{sortId,jdbcType=BIGINT}, + + + #{xhfNsrsbh,jdbcType=VARCHAR}, + + + #{xmmc,jdbcType=VARCHAR}, + + + #{zxbm,jdbcType=VARCHAR}, + + + #{spsm,jdbcType=VARCHAR}, + + + #{spjm,jdbcType=VARCHAR}, + + + #{sl,jdbcType=VARCHAR}, + + + #{ggxh,jdbcType=VARCHAR}, + + + #{xmdw,jdbcType=VARCHAR}, + + + #{xmdj,jdbcType=VARCHAR}, + + + #{hsbz,jdbcType=VARCHAR}, + + + #{ycbz,jdbcType=VARCHAR}, + + + #{yhzcbs,jdbcType=VARCHAR}, + + + #{spbm,jdbcType=VARCHAR}, + + + #{ssflMc,jdbcType=VARCHAR}, + + + #{lslbs,jdbcType=VARCHAR}, + + + #{zzstsgl,jdbcType=VARCHAR}, + + + #{userId,jdbcType=VARCHAR}, + + + now(), + now(), + + + SYSDATE, + SYSDATE, + + + #{modifyUserId,jdbcType=CHAR}, + + + #{groupId,jdbcType=VARCHAR}, + + + #{bz,jdbcType=VARCHAR}, + + + #{xhfMc,jdbcType=VARCHAR}, + + + #{dataSource,jdbcType=VARCHAR}, + + + #{matchingState,jdbcType=VARCHAR}, + + + #{dataState,jdbcType=VARCHAR}, + + + #{spjc,jdbcType=VARCHAR}, + + + #{collectIdent,jdbcType=VARCHAR}, + + + #{cpy,jdbcType=VARCHAR}, + + + #{bmbBbh,jdbcType=VARCHAR}, + + + #{jdc,jdbcType=VARCHAR}, + + + #{wlflbm,jdbcType=VARCHAR}, + + + #{wlflmc,jdbcType=VARCHAR}, + + + ON DUPLICATE KEY UPDATE + + + id = VALUES(id), + + + commodity_id = VALUES(commodity_id), + + + sort_id = VALUES(sort_id), + + + xhf_nsrsbh = VALUES(xhf_nsrsbh), + + + merchandise_name = VALUES(merchandise_name), + + + encoding = VALUES(encoding), + + + tax_items = VALUES(tax_items), + + + brief_code = VALUES(brief_code), + + + tax_rate = VALUES(tax_rate), + + + specification_model = VALUES(specification_model), + + + metering_unit = VALUES(metering_unit), + + + unit_price = VALUES(unit_price), + + + tax_logo = VALUES(tax_logo), + + + hide_the_logo = VALUES(hide_the_logo), + + + enjoy_preferential_policies = VALUES(enjoy_preferential_policies), + + + tax_class_code = VALUES(tax_class_code), + + + tax_classification_name = VALUES(tax_classification_name), + + + preferential_policies_type = VALUES(preferential_policies_type), + + + zzstsgl = VALUES(zzstsgl), + + + user_id = VALUES(user_id), + + create_time = VALUES(create_time), + modify_time = VALUES(modify_time), + + modify_user_id = VALUES(modify_user_id), + + + group_id = VALUES(group_id), + + + description = VALUES(description), + + + enterprise_name = VALUES(enterprise_name), + + + data_source = VALUES(data_source), + + + matching_state = VALUES(matching_state), + + + data_state = VALUES(data_state), + + + tax_class_abbreviation = VALUES(tax_class_abbreviation), + + + collect_ident = VALUES(collect_ident), + + + cpy = VALUES(cpy), + + + bmb_bbh = VALUES(bmb_bbh), + + + jdc = VALUES(jdc), + + + wlflbm = VALUES(wlflbm), + + + wlflmc = VALUES(wlflmc), + + + + + + UPDATE commodity_code + SET + group_id = '' + WHERE group_id = #{id,jdbcType=VARCHAR} + + and xhf_nsrsbh = '' + + + and xhf_nsrsbh = + + #{item} + + + + and xhf_nsrsbh in + + #{item} + + + + + + DELETE + FROM + commodity_code + WHERE id = #{id,jdbcType=VARCHAR} + + and xhf_nsrsbh = '' + + + and xhf_nsrsbh = + + #{item} + + + + and xhf_nsrsbh in + + #{item} + + + + + + + + + + + + + + + + + diff --git a/order-management-consumer/src/test/java/Pop3Test.java b/order-management-consumer/src/test/java/Pop3Test.java new file mode 100644 index 00000000..b3d75908 --- /dev/null +++ b/order-management-consumer/src/test/java/Pop3Test.java @@ -0,0 +1,199 @@ +import com.sun.mail.pop3.POP3Folder; +import com.sun.mail.pop3.POP3Store; +import com.sun.mail.util.MailSSLSocketFactory; +import org.junit.Test; + +import javax.mail.*; +import javax.mail.internet.InternetAddress; +import javax.mail.internet.MimeMessage; +import javax.mail.internet.MimeMultipart; +import javax.mail.internet.MimeUtility; +import javax.mail.search.FlagTerm; +import java.io.*; +import java.security.GeneralSecurityException; +import java.text.SimpleDateFormat; +import java.util.Properties; + +public class Pop3Test { + + @Test + public void main() throws Exception { + + POP3Store pop3Store = null; + try { + Session session = setCollectProperties(); + pop3Store = (POP3Store)session.getStore("pop3"); + pop3Store.connect("pop.qq.com", 995, "1021674882@qq.com", "szcrvcsoakumbcid"); + POP3Folder pop3Folder = (POP3Folder) pop3Store.getFolder("INBOX"); + pop3Folder.open(Folder.READ_WRITE); //打开收件箱 + FetchProfile fetchProfile = new FetchProfile(); + fetchProfile.add(FetchProfile.Item.ENVELOPE); + FlagTerm flagTerm = new FlagTerm(new Flags(Flags.Flag.SEEN),false); + Message[] messages = pop3Folder.search(flagTerm); + pop3Folder.fetch(messages,fetchProfile); + int length = messages.length; + System.out.println("收件箱的邮件数:" + length); + Folder folder = pop3Folder.getStore().getDefaultFolder(); + Folder[] folders = folder.list(); + + for (int i = 0; i < folders.length; i++) { + System.out.println("名称:"+folders[i].getName()); + } + + for (int i = 0; i < length; i++) { + MimeMessage msg = (MimeMessage) messages[i]; + String from = MimeUtility.decodeText(messages[i].getFrom()[0].toString()); + InternetAddress ia = new InternetAddress(from); + System.out.println("发件人:" + ia.getPersonal() + '(' + ia.getAddress() + ')'); + System.out.println("主题:" + messages[i].getSubject()); + System.out.println("邮件发送时间:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(messages[i].getSentDate())); + boolean isContainerAttachment = isContainAttachment(msg); + System.out.println("是否包含附件:" + isContainerAttachment); + if (isContainerAttachment) { + //设置需要保存的目录并保存附件 +// saveAttachment(msg, "F:\\test\\"+msg.getSubject() + "_"+i+"_"); //保存附件 + } + messages[i].setFlag(Flags.Flag.SEEN, true); + } + + } catch (Exception e) { + e.printStackTrace(); + } finally { + if(pop3Store != null){ + pop3Store.close(); + } + } + } + + /** + * 设置连接邮箱属性 + * @return + * @throws GeneralSecurityException + */ + private static Session setCollectProperties() throws GeneralSecurityException { + Properties props = new Properties(); + props.setProperty("mail.popStore.protocol", "pop3"); // 使用pop3协议 + props.setProperty("mail.pop3.port", "995"); // 端口 + + MailSSLSocketFactory sf = new MailSSLSocketFactory(); + sf.setTrustAllHosts(true); + props.put("mail.pop3.ssl.enable",true); + props.put("mail.pop3.ssl.socketFactory",sf); + props.setProperty("mail.pop3.host", "pop.qq.com"); + + + return Session.getInstance(props); + } + + /** + * 判断邮件中是否包含附件 + * @param + * @return 邮件中存在附件返回true,不存在返回false + * @throws MessagingException + * @throws Exception + */ + public static boolean isContainAttachment(Part part) throws Exception { + boolean flag = false; + if (part.isMimeType("multipart/*")) { + MimeMultipart multipart = (MimeMultipart) part.getContent(); + int partCount = multipart.getCount(); + for (int i = 0; i < partCount; i++) { + BodyPart bodyPart = multipart.getBodyPart(i); + String disp = bodyPart.getDisposition(); + if (disp != null && (disp.equalsIgnoreCase(Part.ATTACHMENT) || disp.equalsIgnoreCase(Part.INLINE))) { + flag = true; + } else if (bodyPart.isMimeType("multipart/*")) { + flag = isContainAttachment(bodyPart); + } else { + String contentType = bodyPart.getContentType(); + if (contentType.indexOf("application") != -1) { + flag = true; + } + + if (contentType.indexOf("name") != -1) { + flag = true; + } + } + + if (flag) break; + } + } else if (part.isMimeType("message/rfc822")) { + flag = isContainAttachment((Part)part.getContent()); + } + return flag; + } + + /** + * 保存附件 + * @param part 邮件中多个组合体中的其中一个组合体 + * @param destDir 附件保存目录 + * @throws UnsupportedEncodingException + * @throws MessagingException + * @throws FileNotFoundException + * @throws IOException + */ + public static void saveAttachment(Part part, String destDir) throws Exception{ + if (part.isMimeType("multipart/*")) { + Multipart multipart = (Multipart) part.getContent(); //复杂体邮件 + //复杂体邮件包含多个邮件体 + int partCount = multipart.getCount(); + for (int i = 0; i < partCount; i++) { + //获得复杂体邮件中其中一个邮件体 + BodyPart bodyPart = multipart.getBodyPart(i); + //某一个邮件体也有可能是由多个邮件体组成的复杂体 + String disp = bodyPart.getDisposition(); + if (disp != null && (disp.equalsIgnoreCase(Part.ATTACHMENT) || disp.equalsIgnoreCase(Part.INLINE))) { + InputStream is = bodyPart.getInputStream(); + saveFile(is, destDir, decodeText(bodyPart.getFileName())); + } else if (bodyPart.isMimeType("multipart/*")) { + saveAttachment(bodyPart,destDir); + } else { + String contentType = bodyPart.getContentType(); + if (contentType.indexOf("name") != -1 || contentType.indexOf("application") != -1) { + saveFile(bodyPart.getInputStream(), destDir, decodeText(bodyPart.getFileName())); + } + } + } + } else if (part.isMimeType("message/rfc822")) { + saveAttachment((Part) part.getContent(),destDir); + } + } + + /** + * 读取输入流中的数据保存至指定目录 + * @param is 输入流 + * @param fileName 文件名 + * @param destDir 文件存储目录 + * @throws Exception + */ + private static void saveFile(InputStream is, String destDir, String fileName) + throws Exception { + //如果文件名称包含关键字则进行保存 + BufferedInputStream bis = new BufferedInputStream(is); + BufferedOutputStream bos = new BufferedOutputStream( + new FileOutputStream(new File(destDir + fileName))); + int len = -1; + while ((len = bis.read()) != -1) { + bos.write(len); + bos.flush(); + } + bos.close(); + bis.close(); + } + + /** + * 文本解码 + * @param encodeText 解码MimeUtility.encodeText(String text)方法编码后的文本 + * @return 解码后的文本 + * @throws UnsupportedEncodingException + */ + public static String decodeText(String encodeText) throws UnsupportedEncodingException { + if (encodeText == null || "".equals(encodeText)) { + return ""; + } else { + return MimeUtility.decodeText(encodeText); + } + } +} + + diff --git a/pom.xml b/pom.xml index 3bb201c1..61a61c1c 100644 --- a/pom.xml +++ b/pom.xml @@ -148,15 +148,22 @@ 6.1.6.Final - http://10.1.20.6:8081/nexus/content/groups/public - http://10.1.20.6:8081/nexus/content/groups/public + + - http://10.1.20.6:8081/nexus/content/repositories/releases + + + + + + http://172.31.32.53:8081/repository/maven-public + http://172.31.32.53:8081/repository/maven-public + + http://172.31.32.53:8081/repository/maven-public - http://10.1.20.6:8081/nexus/content/repositories/snapshots + http://172.31.32.53:8081/repository/maven-public - @@ -568,9 +575,9 @@ - - true - + + + @@ -663,14 +670,17 @@ dxhy Dxhy@123 - http://10.1.20.6:8081/nexus/content/groups/public - http://10.1.20.6:8081/nexus/content/groups/public + + - http://10.1.20.6:8081/nexus/content/repositories/releases - - http://10.1.20.6:8081/nexus/content/repositories/snapshots - + + + + + + true +