Showing
4 changed files
with
183 additions
and
24 deletions
| 1 | +package com.erry.iclear.dateInterface.dto; | ||
| 2 | + | ||
| 3 | +import com.erry.iclear.dateInterface.entity.HsCodeAndDescription; | ||
| 4 | +import com.erry.iclear.dateInterface.entity.SysUser; | ||
| 5 | +import lombok.Data; | ||
| 6 | + | ||
| 7 | +import java.util.Date; | ||
| 8 | + | ||
| 9 | +@Data | ||
| 10 | +public class HsCodeAndDescriptionDto { | ||
| 11 | + | ||
| 12 | + private Long id; | ||
| 13 | + | ||
| 14 | + private String a; | ||
| 15 | + | ||
| 16 | + private String b; | ||
| 17 | + | ||
| 18 | + /*** | ||
| 19 | + * 类型 | ||
| 20 | + * 1表示hsCode清单 | ||
| 21 | + | ||
| 22 | + * 2表示品名品名清单 | ||
| 23 | + */ | ||
| 24 | + private int type; | ||
| 25 | + | ||
| 26 | + //用户 | ||
| 27 | + private SysUser sysUser; | ||
| 28 | + | ||
| 29 | + private Date createTime; | ||
| 30 | + | ||
| 31 | + private String errorMsg; | ||
| 32 | + | ||
| 33 | + private String rowNum; | ||
| 34 | + | ||
| 35 | + public HsCodeAndDescriptionDto() { | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + public HsCodeAndDescriptionDto(HsCodeAndDescription hsCodeAndDescription) { | ||
| 39 | + this.setId(hsCodeAndDescription.getId()); | ||
| 40 | + this.setA(hsCodeAndDescription.getA()); | ||
| 41 | + this.setB(hsCodeAndDescription.getB()); | ||
| 42 | + this.setType(hsCodeAndDescription.getType()); | ||
| 43 | + this.setSysUser(hsCodeAndDescription.getSysUser()); | ||
| 44 | + this.setCreateTime(hsCodeAndDescription.getCreateTime()); | ||
| 45 | + } | ||
| 46 | +} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +package com.erry.iclear.dateInterface.entity; | ||
| 2 | + | ||
| 3 | +import com.fasterxml.jackson.annotation.JsonIgnore; | ||
| 4 | +import lombok.Data; | ||
| 5 | + | ||
| 6 | +import javax.persistence.*; | ||
| 7 | +import java.util.Date; | ||
| 8 | + | ||
| 9 | +@Entity | ||
| 10 | +@Table(name = "T_AU_HSCODE_DESCRIPTION") | ||
| 11 | +@Data | ||
| 12 | +public class HsCodeAndDescription { | ||
| 13 | + | ||
| 14 | + private static final long serialVersionUID = 1L; | ||
| 15 | + | ||
| 16 | + @Id | ||
| 17 | + @GeneratedValue | ||
| 18 | + @Column(name = "ID") | ||
| 19 | + private Long id; | ||
| 20 | + | ||
| 21 | + @Column(name = "A") | ||
| 22 | + private String a; | ||
| 23 | + | ||
| 24 | + @Column(name = "B") | ||
| 25 | + private String b; | ||
| 26 | + | ||
| 27 | + /*** | ||
| 28 | + * 类型 | ||
| 29 | + * 1表示hsCode清单 | ||
| 30 | + | ||
| 31 | + * 2表示品名品名清单 | ||
| 32 | + */ | ||
| 33 | + @Column(name = "TYPE") | ||
| 34 | + private int type; | ||
| 35 | + | ||
| 36 | + //用户 | ||
| 37 | + @JsonIgnore | ||
| 38 | + @ManyToOne(targetEntity = SysUser.class) | ||
| 39 | + @JoinColumn(name = "USER_ID") | ||
| 40 | + private SysUser sysUser; | ||
| 41 | + | ||
| 42 | + //创建时间 | ||
| 43 | + @Column(name = "CREATETIME") | ||
| 44 | + private Date createTime; | ||
| 45 | + | ||
| 46 | +} |
src/main/java/com/erry/iclear/dateInterface/repository/HsCodeAndDescriptionRepository.java
0 → 100644
| 1 | +package com.erry.iclear.dateInterface.repository; | ||
| 2 | + | ||
| 3 | +import com.erry.iclear.dateInterface.entity.HsCodeAndDescription; | ||
| 4 | +import org.springframework.data.jpa.repository.JpaRepository; | ||
| 5 | +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | ||
| 6 | +import org.springframework.data.jpa.repository.Query; | ||
| 7 | +import org.springframework.stereotype.Repository; | ||
| 8 | + | ||
| 9 | +import java.util.List; | ||
| 10 | +@Repository | ||
| 11 | +public interface HsCodeAndDescriptionRepository extends JpaSpecificationExecutor<HsCodeAndDescription>, JpaRepository<HsCodeAndDescription, Long> { | ||
| 12 | + @Query(nativeQuery = true,value = "select * from T_AU_HSCODE_DESCRIPTION where TYPE = ?1 ") | ||
| 13 | + public List<HsCodeAndDescription> selectAndType(int type); | ||
| 14 | +} |
| 1 | package com.erry.iclear.dateInterface.service; | 1 | package com.erry.iclear.dateInterface.service; |
| 2 | 2 | ||
| 3 | -import com.erry.iclear.dateInterface.enums.ErrorCodeEnum; | ||
| 4 | import com.erry.iclear.dateInterface.api.request.HsCodeParam; | 3 | import com.erry.iclear.dateInterface.api.request.HsCodeParam; |
| 5 | import com.erry.iclear.dateInterface.api.response.ResultHsCode; | 4 | import com.erry.iclear.dateInterface.api.response.ResultHsCode; |
| 6 | import com.erry.iclear.dateInterface.common.Constant; | 5 | import com.erry.iclear.dateInterface.common.Constant; |
| 6 | +import com.erry.iclear.dateInterface.dto.HsCodeAndDescriptionDto; | ||
| 7 | import com.erry.iclear.dateInterface.entity.HsCode; | 7 | import com.erry.iclear.dateInterface.entity.HsCode; |
| 8 | +import com.erry.iclear.dateInterface.entity.HsCodeAndDescription; | ||
| 9 | +import com.erry.iclear.dateInterface.enums.ErrorCodeEnum; | ||
| 8 | import com.erry.iclear.dateInterface.repository.DictionaryEntriesRepository; | 10 | import com.erry.iclear.dateInterface.repository.DictionaryEntriesRepository; |
| 11 | +import com.erry.iclear.dateInterface.repository.HsCodeAndDescriptionRepository; | ||
| 9 | import com.erry.iclear.dateInterface.repository.HsCodeRepository; | 12 | import com.erry.iclear.dateInterface.repository.HsCodeRepository; |
| 10 | import com.erry.iclear.dateInterface.util.StringUtil; | 13 | import com.erry.iclear.dateInterface.util.StringUtil; |
| 11 | import lombok.extern.slf4j.Slf4j; | 14 | import lombok.extern.slf4j.Slf4j; |
| 12 | import org.springframework.beans.factory.annotation.Autowired; | 15 | import org.springframework.beans.factory.annotation.Autowired; |
| 13 | import org.springframework.stereotype.Service; | 16 | import org.springframework.stereotype.Service; |
| 14 | 17 | ||
| 15 | -import java.util.*; | 18 | +import java.math.BigDecimal; |
| 19 | +import java.util.Arrays; | ||
| 20 | +import java.util.HashMap; | ||
| 21 | +import java.util.List; | ||
| 22 | +import java.util.Map; | ||
| 16 | 23 | ||
| 17 | /** | 24 | /** |
| 18 | * hscode service | 25 | * hscode service |
| ... | @@ -27,6 +34,8 @@ public class HsCodeService { | ... | @@ -27,6 +34,8 @@ public class HsCodeService { |
| 27 | HsCodeRepository hsCodeRepository; | 34 | HsCodeRepository hsCodeRepository; |
| 28 | @Autowired | 35 | @Autowired |
| 29 | DictionaryEntriesRepository dicEntriesRepository; | 36 | DictionaryEntriesRepository dicEntriesRepository; |
| 37 | + @Autowired | ||
| 38 | + HsCodeAndDescriptionRepository hsCodeAndDescriptionRepository; | ||
| 30 | 39 | ||
| 31 | /** | 40 | /** |
| 32 | * 根据hscode编码查询对应的hscode | 41 | * 根据hscode编码查询对应的hscode |
| ... | @@ -168,29 +177,73 @@ public class HsCodeService { | ... | @@ -168,29 +177,73 @@ public class HsCodeService { |
| 168 | * 2023年2月24日17:29:49 | 177 | * 2023年2月24日17:29:49 |
| 169 | */ | 178 | */ |
| 170 | public void setHscodeSupervise(List<HsCode> hsCodeList){ | 179 | public void setHscodeSupervise(List<HsCode> hsCodeList){ |
| 171 | - List<Long> hsCodeIds = new ArrayList<>(); | 180 | + for (HsCode hsCode : hsCodeList) { |
| 172 | - Map<String,Object> hscodeMap = this.getHscodeSupervise(); | 181 | + Map<String,Object> hscodeMap = new HashMap<>(); |
| 173 | - StringBuffer shsql = new StringBuffer("'"); | 182 | + hscodeMap.put("success",false); |
| 174 | - if (hscodeMap !=null && hscodeMap.size()>0){ | 183 | + Map hsCodeAndDescription1 = new HashMap(); |
| 175 | - for (Map.Entry hscodeEntry :hscodeMap.entrySet()){ | 184 | + List<HsCodeAndDescription> hsCodeAndDescriptionList = hsCodeAndDescriptionRepository.selectAndType(1); |
| 176 | - HsCode hsCode = (HsCode) hscodeEntry.getValue(); | 185 | + if (hsCodeAndDescriptionList.size() > 0) { |
| 177 | - hsCodeIds.add(hsCode.getId()); | 186 | + for (HsCodeAndDescription hsCodeAndDescription : hsCodeAndDescriptionList) { |
| 178 | - } | 187 | + HsCodeAndDescriptionDto hsCodeAndDescriptionDto = new HsCodeAndDescriptionDto(hsCodeAndDescription); |
| 188 | + hsCodeAndDescription1.put(hsCodeAndDescriptionDto.getB(), hsCodeAndDescriptionDto); | ||
| 189 | + } | ||
| 190 | + } | ||
| 191 | + Boolean isTrue = false; | ||
| 192 | + if (hsCode !=null){ | ||
| 193 | + if(hsCodeAndDescription1.size()>0){ | ||
| 194 | + String fieldValue =getSubHscode(hsCode.getSkuCode()); | ||
| 195 | + if (hsCodeAndDescription1.size()>0 && !StringUtil.isEmptyWithTrim(fieldValue)){ | ||
| 196 | + //hsCodeAndDescription1.get(fieldValue); | ||
| 197 | + if (hsCodeAndDescription1.get(fieldValue) != null){ | ||
| 198 | + isTrue = true; | ||
| 199 | + } | ||
| 200 | + } | ||
| 201 | + } | ||
| 202 | + List<String> dictionaryEntriesList = dicEntriesRepository.findDicEntByCodeList(Constant.supervise_condition,1); | ||
| 203 | + if (dictionaryEntriesList != null && dictionaryEntriesList.size() >0){ | ||
| 204 | + for (String str : dictionaryEntriesList){ | ||
| 205 | + if (!StringUtil.isEmptyWithTrim(hsCode.getMonitorCondition()) || hsCode.getOutRate() != null){ | ||
| 206 | + if (hsCode.getMonitorCondition().indexOf(str) > -1 || hsCode.getOutRate().compareTo(BigDecimal.valueOf(0)) > 0){ | ||
| 207 | + isTrue = true; | ||
| 208 | + } | ||
| 209 | + } | ||
| 210 | + } | ||
| 211 | + } | ||
| 212 | + if (isTrue){ | ||
| 213 | + hsCode.setRestrictedC(1); | ||
| 214 | + }else { | ||
| 215 | + hsCode.setRestrictedC(0); | ||
| 216 | + } | ||
| 217 | + if (hsCode.getId()==null){ | ||
| 218 | + hsCode.setRestrictedC(null); | ||
| 219 | + } | ||
| 220 | + } | ||
| 179 | } | 221 | } |
| 180 | - hsCodeList.forEach(hsCode->{ | 222 | + |
| 181 | - //判断该hscode是否只能申报D类 | 223 | + |
| 182 | - if(hsCodeIds.contains(hsCode.getId())){ | 224 | +// List<Long> hsCodeIds = new ArrayList<>(); |
| 183 | - //d类 | 225 | +// Map<String,Object> hscodeMap = this.getHscodeSupervise(); |
| 184 | - hsCode.setRestrictedC(1); | 226 | +// StringBuffer shsql = new StringBuffer("'"); |
| 185 | - }else{ | 227 | +// if (hscodeMap !=null && hscodeMap.size()>0){ |
| 186 | - //C类 | 228 | +// for (Map.Entry hscodeEntry :hscodeMap.entrySet()){ |
| 187 | - hsCode.setRestrictedC(0); | 229 | +// HsCode hsCode = (HsCode) hscodeEntry.getValue(); |
| 188 | - } | 230 | +// hsCodeIds.add(hsCode.getId()); |
| 189 | - //如果ID为空,则设置为空 | 231 | +// } |
| 190 | - if(hsCode.getId() == null){ | 232 | +// } |
| 191 | - hsCode.setRestrictedC(null); | 233 | +// hsCodeList.forEach(hsCode->{ |
| 192 | - } | 234 | +// //判断该hscode是否只能申报D类 |
| 193 | - }); | 235 | +// if(hsCodeIds.contains(hsCode.getId())){ |
| 236 | +// //d类 | ||
| 237 | +// hsCode.setRestrictedC(1); | ||
| 238 | +// }else{ | ||
| 239 | +// //C类 | ||
| 240 | +// hsCode.setRestrictedC(0); | ||
| 241 | +// } | ||
| 242 | +// //如果ID为空,则设置为空 | ||
| 243 | +// if(hsCode.getId() == null){ | ||
| 244 | +// hsCode.setRestrictedC(null); | ||
| 245 | +// } | ||
| 246 | +// }); | ||
| 194 | } | 247 | } |
| 195 | 248 | ||
| 196 | /** | 249 | /** | ... | ... |
-
Please register or login to post a comment