mirror of https://github.com/jeecgboot/jeecg-boot
commit
6baf1d4d9b
|
@ -128,5 +128,7 @@ public class LoginUser {
|
|||
private String clientId;
|
||||
/**Mabang username*/
|
||||
private String mabangUsername;
|
||||
/**User code*/
|
||||
private String code;
|
||||
|
||||
}
|
||||
|
|
|
@ -531,7 +531,7 @@ public class SkuController {
|
|||
sku.setLabelData(map.get("labelData"));
|
||||
return sku;
|
||||
}
|
||||
@PostMapping("syncSkus")
|
||||
@PostMapping("/syncSkus")
|
||||
public Result<?> syncSkus(@RequestBody List<String> erpCodes) {
|
||||
Map<Sku, String> newSkusNeedTreatmentMap;
|
||||
|
||||
|
@ -607,4 +607,11 @@ public class SkuController {
|
|||
page.setTotal(total);
|
||||
return Result.OK(page);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/latestSkuCounter")
|
||||
public Result<?> latestSkuCounter(@RequestParam(name= "userCode") String userCode,
|
||||
@RequestParam(name= "clientCode") String clientCode,
|
||||
@RequestParam(name= "date") String date) {
|
||||
return Result.OK(skuService.latestSkuCounter(userCode, clientCode, date));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import com.google.common.cache.CacheBuilder;
|
|||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.catalina.User;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.jeecg.modules.business.controller.UserException;
|
||||
import org.jeecg.modules.business.domain.codeGeneration.CompleteInvoiceCodeRule;
|
||||
|
@ -17,9 +16,7 @@ import org.jeecg.modules.business.service.*;
|
|||
import org.jeecg.modules.business.vo.*;
|
||||
import org.jeecg.modules.business.vo.clientPlatformOrder.section.OrdersStatisticData;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.simpleframework.xml.core.Complete;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.dao.IncorrectResultSizeDataAccessException;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
@ -61,6 +58,7 @@ public class ShippingInvoiceFactory {
|
|||
private final Environment env;
|
||||
|
||||
private final SimpleDateFormat SUBJECT_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
|
||||
private final SimpleDateFormat CREATE_TIME_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
private final List<String> EU_COUNTRY_LIST = Arrays.asList("Austria", "Belgium", "Bulgaria", "Croatia", "Cyprus",
|
||||
"Czech", "Denmark", "Estonia", "Finland", "France", "Germany", "Greece", "Hungary", "Ireland", "Italy",
|
||||
|
@ -1341,7 +1339,7 @@ public class ShippingInvoiceFactory {
|
|||
Client client = clientMapper.getClientFromPurchase(purchaseId);
|
||||
List<PurchaseInvoiceEntry> purchaseOrderSkuList = purchaseOrderContentMapper.selectInvoiceDataByID(purchaseId);
|
||||
List<PromotionDetail> promotionDetails = skuPromotionHistoryMapper.selectPromotionByPurchase(purchaseId);
|
||||
BigDecimal eurToUsd = exchangeRatesMapper.getExchangeRateFromDate("EUR", "USD", order.getCreateTime().toString());
|
||||
BigDecimal eurToUsd = exchangeRatesMapper.getExchangeRateFromDate("EUR", "USD", CREATE_TIME_FORMAT.format(order.getCreateTime()));
|
||||
return new PurchaseInvoice(client, invoiceCode, "Purchase Invoice", purchaseOrderSkuList, promotionDetails, eurToUsd);
|
||||
}
|
||||
public CompleteInvoice buildExistingCompleteInvoice(String invoiceCode, String clientId, String start, String end, String filetype, String shippingMethod) throws UserException {
|
||||
|
|
|
@ -84,4 +84,6 @@ public interface SkuMapper extends BaseMapper<Sku> {
|
|||
List<String> fetchUnpairedSkus(@Param("shopId") String shopId, @Param("offset") Integer offset, @Param("size") Integer pageSize, @Param("column") String column, @Param("order") String order);
|
||||
|
||||
int countUnpairedSkus(@Param("shopId") String shopId);
|
||||
|
||||
List<String> latestSkuCounter(@Param("userCode") String userCode, @Param("clientCode") String clientCode, @Param("date") String date);
|
||||
}
|
||||
|
|
|
@ -816,4 +816,9 @@
|
|||
AND poc.erp_status <> 5
|
||||
AND s.id = #{shopId};
|
||||
</select>
|
||||
<select id="latestSkuCounter" resultType="java.lang.String">
|
||||
SELECT erp_code
|
||||
FROM sku s
|
||||
WHERE erp_code LIKE CONCAT(#{date}, #{userCode}, '%%%-', #{clientCode});
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
@ -128,4 +128,6 @@ public interface ISkuService extends IService<Sku> {
|
|||
List<String> fetchUnpairedSkus(String shopId, int offset, Integer pageSize, String column, String order);
|
||||
|
||||
int countUnpairedSkus(String shopId);
|
||||
|
||||
int latestSkuCounter(String userCode, String clientCode, String date);
|
||||
}
|
||||
|
|
|
@ -510,11 +510,19 @@ public class SkuListMabangServiceImpl extends ServiceImpl<SkuListMabangMapper, S
|
|||
@Override
|
||||
public Map<Sku, String> skuSyncUpsert(List<String> erpCodes) {
|
||||
Map<Sku, String> newSkusNeedTreatmentMap = new HashMap<>();
|
||||
SkuListRequestBody body = new SkuListRequestBody();
|
||||
body.setStockSkuList(String.join(",", erpCodes));
|
||||
SkuListRawStream rawStream = new SkuListRawStream(body);
|
||||
SkuListStream stream = new SkuListStream(rawStream);
|
||||
List<SkuData> skusFromMabang = stream.all();
|
||||
List<SkuData> skusFromMabang = new ArrayList<>();
|
||||
List<List<String>> skusPartition = Lists.partition(erpCodes, 50);
|
||||
for(List<String> skuPartition : skusPartition) {
|
||||
SkuListRequestBody body = new SkuListRequestBody();
|
||||
body.setStockSkuList(String.join(",", skuPartition));
|
||||
SkuListRawStream rawStream = new SkuListRawStream(body);
|
||||
SkuListStream stream = new SkuListStream(rawStream);
|
||||
List<SkuData> partialSkusFromMabang = stream.all();
|
||||
if(!partialSkusFromMabang.isEmpty()) {
|
||||
skusFromMabang.addAll(partialSkusFromMabang);
|
||||
}
|
||||
}
|
||||
|
||||
if (!skusFromMabang.isEmpty()) {
|
||||
// we save the skuDatas in DB
|
||||
// and store skus that need manual treatment
|
||||
|
|
|
@ -626,4 +626,14 @@ public class SkuServiceImpl extends ServiceImpl<SkuMapper, Sku> implements ISkuS
|
|||
public int countUnpairedSkus(String shopId) {
|
||||
return skuMapper.countUnpairedSkus(shopId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int latestSkuCounter(String userCode, String clientCode, String date) {
|
||||
List<String> skus = skuMapper.latestSkuCounter(userCode, clientCode, date);
|
||||
List<Integer> counters = skus.stream().map(sku -> {
|
||||
String counter = sku.split("-")[0].substring(8 + userCode.length());
|
||||
return Integer.parseInt(counter);
|
||||
}).collect(Collectors.toList());
|
||||
return counters.stream().max(Integer::compareTo).orElse(0) + 1;
|
||||
}
|
||||
}
|
|
@ -1830,4 +1830,11 @@ public class SysUserController {
|
|||
return Result.error("Mabang username not found");
|
||||
return Result.ok(sysUser.getMabangUsername());
|
||||
}
|
||||
@GetMapping(value = "/userCode")
|
||||
public Result<?> getUserCode() {
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
if(sysUser.getCode() == null || sysUser.getCode().isEmpty())
|
||||
return Result.error(404,"User code not found");
|
||||
return Result.ok(sysUser.getCode());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -190,6 +190,8 @@ public class SysUser implements Serializable {
|
|||
private String clientId;
|
||||
/**Mabang username*/
|
||||
private String mabangUsername;
|
||||
/** User code is used to identify who created a sku*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 登录首页地址
|
||||
|
|
Loading…
Reference in New Issue