Commit 8dab0a00 by 肖洋洋

外部接口对接代码2

parent c99ed9f9
Showing with 2024 additions and 1065 deletions
......@@ -3,7 +3,9 @@ package orthopedics;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;
import orthopedics.util.IdWorker;
@SpringBootApplication
//@EnableScheduling
......@@ -13,5 +15,8 @@ public class Application {
SpringApplication.run(Application.class, args);
}
@Bean
public IdWorker idWorker(){
return new IdWorker();
}
}
package orthopedics.client;
import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import orthopedics.controller.v1.TransactionController;
import orthopedics.dao.*;
import orthopedics.model.*;
import orthopedics.service.PropertiesServer;
import orthopedics.util.IdWorker;
import orthopedics.util.UuidUtil;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@RestController
@RequestMapping("/Sync")
public class Sync {
private final static Logger logger = LoggerFactory.getLogger(Sync.class);
@Autowired
private TempItemFomPmpMapper tempItemFomPmpMapper;
@Autowired
private InvItemMapper invItemMapper;
@Autowired
private PropertiesServer propertiesServer;
@Autowired
private SysUserDepartMapper sysUserDepartMapper;
@Autowired
private InvItemSkuMapper invItemSkuMapper;
@Autowired
private InvItemAttributeMapper invItemAttributeMapper;
@Autowired
private IdWorker idWorker;
@GetMapping("/item")
public void sync1(){
int j=210295;
while (true){
try {
List<TempItemFomPmp> limit = tempItemFomPmpMapper.findLimit(j);
if(limit.size()<=0){
logger.info("所有数据同步完成!!!");
return;
}
List<InvItem> invItems=new ArrayList<>();
List<InvItemAttribute> invItemAttributes=new ArrayList<>();
List<InvItemSku> invItemSkus=new ArrayList<>();
for (TempItemFomPmp tempItemFomPmp:limit) {
String plucode = invItemMapper.getPlucode(tempItemFomPmp.getPlucode());
if(plucode!=null){
continue;
}
InvItem invItem=new InvItem();
InvItemAttribute invItemAttribute=new InvItemAttribute();
InvItemSku invItemSku=new InvItemSku();
//商品表
invItem.setId(UuidUtil.get32UUIDString());
invItem.setOrgId("2c9007626dde3f4f016deda2151f1a42");
invItem.setStatus("SALE");
invItem.setProType(tempItemFomPmp.getClscode());
invItem.setItemCode(idWorker.nextId()+"");
invItem.setItemName(tempItemFomPmp.getTitle());
invItem.setItemDesc(tempItemFomPmp.getJp());
invItem.setPystype(tempItemFomPmp.getPystype()+"");
invItem.setIsbn(tempItemFomPmp.getIsbn());
invItem.setPlucode(tempItemFomPmp.getPlucode());
invItem.setScancode(tempItemFomPmp.getScancode());
invItem.setExtcode("0");
invItem.setPurchasePrice(tempItemFomPmp.getPrice()+"");
invItem.setGeneralName(tempItemFomPmp.getClscode());
invItem.setManufacturerId(tempItemFomPmp.getPublisher());
invItem.setSpecification(tempItemFomPmp.getPubdate());
invItem.setPrimaryUnit("BEN");
if(tempItemFomPmp.getPystype()==0||tempItemFomPmp.getPystype()==4){
invItem.setAttribute1("Book");
invItem.setIsBorrow("Y");
}else{
invItem.setAttribute1("Goods");
invItem.setIsBorrow("N");
}
invItem.setAttribute2("A");
invItem.setTax(tempItemFomPmp.getInctax()+"");
invItem.setDefaultVendorId("000000006c60dba1016c60f839270004");
invItem.setCreateBy("PMP同步");
invItem.setCreateTime(LocalDateTime.now());
//查询当前用户部门
//SysUserDepart sysUserDepart = sysUserDepartMapper.selectByUserId("b7b819e3a7fb25699ff5e10332f089f7");
//图书信息
invItemAttribute.setId(UuidUtil.get32UUIDString());
invItemAttribute.setCreateBy("PMP同步");
invItemAttribute.setCreateTime(LocalDateTime.now());
// if(sysUserDepart!=null){
// invItemAttribute.setSysOrgCode(sysUserDepart.getDepId());
// }
invItemAttribute.setItemId(invItem.getId());
invItemAttribute.setItemCode(invItem.getItemCode());
invItemAttribute.setAuthor(tempItemFomPmp.getAuthor());
invItemAttribute.setReader(tempItemFomPmp.getReader());
//商品SKU映射
invItemSku.setId(UuidUtil.get32UUIDString());
// if(sysUserDepart!=null){
// invItemSku.setSysOrgCode(sysUserDepart.getDepId());
// }
invItemSku.setOrgId("2c9007626dde3f4f016deda2151f1a42");
invItemSku.setExternal("PMP");
invItemSku.setItemSku(tempItemFomPmp.getPlucode());
invItemSku.setItemName(invItem.getItemName());
invItemSku.setItemCode(invItem.getItemCode());
invItemSku.setItemDesc(invItem.getItemDesc());
invItemSku.setStatus("A");
invItemSku.setCreateBy("PMP同步");
invItemSku.setCreateTime(LocalDateTime.now());
invItems.add(invItem);
invItemAttributes.add(invItemAttribute);
invItemSkus.add(invItemSku);
}
if(invItems.size()<=0){
continue;
}
invItemMapper.insertBatch(invItems);
invItemSkuMapper.insertBatch(invItemSkus);
invItemAttributeMapper.insertBatch(invItemAttributes);
j=j+4999;
logger.info("前"+j+"条同步完成");
}catch (Exception e){
logger.error("同步失败的下标段"+j+"-"+(j+4999));
logger.error(e.getMessage());
j=j+4999;
}
}
}
@Autowired
private TempItemSkuFomPmpMapper tempItemSkuFomPmpMapper;
@Autowired
private TransactionController transactionController;
@GetMapping("/sku")
public void addInvItemSku(){
List<TempItemSkuFomPmp> select = tempItemSkuFomPmpMapper.select();
int i=0;
for (TempItemSkuFomPmp tempItemSkuFomPmp:select) {
JSONObject jsonObject=new JSONObject();
JSONObject data=new JSONObject();
data.put("inv_code","WH2");
data.put("subinv_code","KQ22");
data.put("locator_code","HJ"+tempItemSkuFomPmp.getRack());
String itemcode = invItemMapper.getPlucode(tempItemSkuFomPmp.getPlucode());
if(itemcode==null){
continue;
}
data.put("item_code",itemcode);
data.put("tx_type_code","PMP_SYN");
data.put("tx_date",new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
data.put("tx_quantity",tempItemSkuFomPmp.getQty());
data.put("tx_price",tempItemSkuFomPmp.getPrice());
jsonObject.put("data",data);
String s = transactionController.invItemInOut("201910271129039497a78b526d9a246eca0abb1025986f25cG7BHIxhVaDO6MYm", jsonObject);
i++;
logger.info("同步到"+i+"条"+",一共"+select.size()+"条");
}
}
}
......@@ -10,8 +10,10 @@ import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import orthopedics.dao.InvItemBalanceSummaryVMapper;
import orthopedics.dao.InvLocatorMapper;
import orthopedics.dao.SalOrderHeaderMapper;
import orthopedics.model.InvItemBalanceSummaryV;
import orthopedics.model.InvLocator;
import orthopedics.model.SalOrderHeader;
import orthopedics.util.*;
......@@ -24,6 +26,9 @@ public class SyncItemSku {
@Autowired
private InvItemBalanceSummaryVMapper invItemBalanceSummaryVMapper;
@Autowired
private InvLocatorMapper invLocatorMapper;
/**
* 将商品库存同步到PMP
*/
......@@ -41,7 +46,8 @@ public class SyncItemSku {
JSONObject jsonObject=new JSONObject();
if(invItemBalanceSummaryV.getLocator_id()!=null && invItemBalanceSummaryV.getBalance()!=null){
jsonObject.put("wh",invItemBalanceSummaryV.getInv_id());
jsonObject.put("rack",invItemBalanceSummaryV.getLocator_id());
InvLocator byId = invLocatorMapper.findById(invItemBalanceSummaryV.getLocator_id());
jsonObject.put("rack",byId.getLocatorName());
jsonObject.put("plucode",invItemBalanceSummaryV.getPlucode());
jsonObject.put("qty",invItemBalanceSummaryV.getBalance());
plulist.add(jsonObject);
......
......@@ -60,10 +60,24 @@ public class SyncSalFromPos {
ps.setString(1,invItem.getItemCode());
rs = ps.executeQuery();
while (rs.next()){
String operator = rs.getString(2);//收银员账号
Timestamp timestamp = rs.getTimestamp(3);//订单时间
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// String dateStr = sdf.format(date);
String paymentMethod = rs.getString(8);//支付方式
long vouchnum = rs.getLong(4);//小票单号
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String dateStr = sdf.format(timestamp);
//查询支付方式
PreparedStatement ps1=ct.prepareStatement("SELECT * FROM shoptxns WHERE Convert(varchar,txntime,120) like ''+?+'%' and vouchnum=? and operator=? and salestype=8");
ps1.setString(1,dateStr);
ps1.setLong(2,vouchnum);
ps1.setString(3,operator);
String paymentMethod =null;//支付方式
ResultSet rs1 = ps1.executeQuery();
while (rs1.next()){
paymentMethod = rs1.getString(8);
}
rs1.close();
ps1.close();
int quantity = rs.getInt(13);//数量
int attribute1 = rs.getInt(14);//单价
int attribute3 = rs.getInt(15);//折扣
......
......@@ -9,10 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import orthopedics.dao.InvItemMapper;
import orthopedics.dao.InvLocatorMapper;
import orthopedics.dao.InvSubinventoryMapper;
import orthopedics.dao.SalOrderLineVMapper;
import orthopedics.dao.*;
import orthopedics.model.*;
import orthopedics.util.Aes;
import orthopedics.util.HttpUtilPMP;
......@@ -37,6 +34,9 @@ public class SyncSalOrderHeader {
@Autowired
private InvLocatorMapper invLocatorMapper;
@Autowired
private SalOrderLineDetailVMapper salOrderLineDetailVMapper;
/**
* 将销售订单同步到PMP
*/
......@@ -57,26 +57,17 @@ public class SyncSalOrderHeader {
jsonObject.put("seq",salOrderLineV.getLineNumber());
jsonObject.put("plucode",salOrderLineV.getPlucode());
// jsonObject.put("fwh",salOrderLineV);
InvItem invItem = invItemMapper.selectInvItemById(salOrderLineV.getItemId());
if(invItem==null){
logger.error("销售订单商品id【"+salOrderLineV.getItemId()+"】查询不到商品信息");
return;
}
if(StringUtil.isEmpty(invItem.getInvId())){
logger.error("销售订单商品id【"+salOrderLineV.getItemId()+"】查询商品信息库存id为空");
return;
}
List<InvSubinventory> invSubinventories = invSubinventoryMapper.selectByInvIdAndSubinvName(invItem.getInvId());
if(invSubinventories==null||invSubinventories.size()<=0){
logger.error("商品code:"+invItem.getItemCode()+"库存id查询不到库区");
return;
SalOrderLineDetailV byOrderNumber = salOrderLineDetailVMapper.findByOrderNumber(salOrderLineV.getOrderNumber());
if(byOrderNumber==null){
logger.error(salOrderLineV.getOrderNumber()+"查询不到销售订单执行报表");
continue;
}
List<InvLocator> byInvIdAndSubinvId = invLocatorMapper.findByInvIdAndSubinvId(invItem.getInvId(), invSubinventories.get(0).getId());
if(invSubinventories==null||invSubinventories.size()<=0){
logger.error("商品code:"+invItem.getItemCode()+"库存id和存储库区id查询不到货架");
return;
InvLocator byId = invLocatorMapper.findById(byOrderNumber.getLocatorId());
if(byId==null){
logger.error(salOrderLineV.getOrderNumber()+"查询不到货架号");
continue;
}
jsonObject.put("frack",byInvIdAndSubinvId.get(0).getLocatorCode());
jsonObject.put("frack",byId.getLocatorName());
jsonObject.put("qty",salOrderLineV.getQuantity());
jsonObject.put("disc",salOrderLineV.getAttribute3());
jsonObject.put("apvby",salOrderLineV.getOrderDate());
......
......@@ -170,6 +170,28 @@ public class InvCountHeaderController {
return new Result(true,StatusCode.OK,"盘点单查询成功",invCountHeaderPage);
}
@GetMapping("/findByHeaderStatus")
public Result findByHeaderStatus(@RequestParam(value = "access_token",required = true)String token){
SysAccessToken sysAccessToken = userServer.checkToken(token);
List<InvCountHeaderPage> ichp=new ArrayList<>();
List<InvCountHeader> invCountHeaders = invCountHeaderMapper.fingByHeaderStatus("new");
if(invCountHeaders==null ||invCountHeaders.size()<=0){
return new Result(false, StatusCode.ERROR,"没有状态为【新增】数据");
}
for (InvCountHeader invCountHeader:invCountHeaders) {
InvCountHeaderPage invCountHeaderPage=new InvCountHeaderPage();
BeanUtils.copyProperties(invCountHeader,invCountHeaderPage);
List<InvCountLine> invCountLines = invCountLineMapper.selectByInvCountHeaderId(invCountHeader.getId());
if(invCountLines==null || invCountLines.size()<=0){
continue;
}
invCountHeaderPage.setInvCountLineList(invCountLines);
ichp.add(invCountHeaderPage);
}
return new Result(true,StatusCode.OK,"盘点单查询成功",ichp);
}
@GetMapping("/findByCountNumberToSku")
public Result findByCountNumberToSku(@RequestParam(value = "access_token",required = true)String token,@RequestParam(value = "countNumber",required = true) String countNumber){
SysAccessToken sysAccessToken = userServer.checkToken(token);
......
......@@ -40,10 +40,10 @@ public class InvCountPrintController {
private InvItemBalanceSummaryVMapper invItemBalanceSummaryVMapper;
@GetMapping("/findByPrintNumber")
public Result findByPrintNumber(@RequestParam(value = "access_token",required = true)String token, @RequestParam(value = "printNumber",required = true) String printNumber){
public Result findByPrintNumber(@RequestParam(value = "access_token",required = true)String token, @RequestParam(value = "printInvId",required = true) String printInvId){
SysAccessToken sysAccessToken = userServer.checkToken(token);
List<InvCountPrintPage> ichp=new ArrayList<>();
if(StringUtil.isEmpty(printNumber)){
if(StringUtil.isEmpty(printInvId)){
List<SysOrgAccess> sysOrgAccesses = userServer.selectSysOrgAccessByUserId(sysAccessToken.getUserId());
if(sysOrgAccesses==null || sysOrgAccesses.size()<=0){
return new Result(false, StatusCode.ERROR,"当前用户不属于任何组织");
......@@ -63,23 +63,32 @@ public class InvCountPrintController {
}
return new Result(true,StatusCode.OK,"盘点计划查询成功",ichp);
}
List<InvCountPrint> invCountPrints = invCountPrintMapper.findByPrintInvId(printInvId);
if(invCountPrints==null || invCountPrints.size()<=0){
return new Result(false, StatusCode.ERROR,"库存id查询不到数据");
}
for (InvCountPrint invCountPrint:invCountPrints) {
InvCountPrintPage invCountPrintPage=new InvCountPrintPage();
InvCountPrint byPrintNumber = invCountPrintMapper.findByPrintNumber(printNumber);
if(byPrintNumber==null){
return new Result(false, StatusCode.ERROR,"判断顺序号查询不到数据");
BeanUtils.copyProperties(invCountPrint,invCountPrintPage);
List<InvCountPrintLine> invCountPrintLines = invCountPrintLineMapper.findByPrintId(invCountPrint.getId());
if(invCountPrintLines==null || invCountPrintLines.size()<=0){
continue;
}
List<InvCountPrintLine> byPrintId = invCountPrintLineMapper.findByPrintId(byPrintNumber.getId());
BeanUtils.copyProperties(byPrintNumber,invCountPrintPage);
invCountPrintPage.setInvCountPrintLines(byPrintId);
return new Result(true,StatusCode.OK,"盘点计划查询成功",invCountPrintPage);
invCountPrintPage.setInvCountPrintLines(invCountPrintLines);
ichp.add(invCountPrintPage);
}
return new Result(true,StatusCode.OK,"盘点计划查询成功",ichp);
}
@GetMapping("/findByPrintNumberToSku")
public Result findByPrintNumberToSku(@RequestParam(value = "access_token",required = true)String token, @RequestParam(value = "printNumber",required = true) String printNumber){
public Result findByPrintNumberToSku(@RequestParam(value = "access_token",required = true)String token, @RequestParam(value = "printNumber",required = true) String printNumber,@RequestParam(value = "invId",required = true) String invId){
SysAccessToken sysAccessToken = userServer.checkToken(token);
if(StringUtil.isEmpty(printNumber)){
return new Result(false, StatusCode.ERROR,"顺序号为空");
}
if(StringUtil.isEmpty(invId)){
return new Result(false, StatusCode.ERROR,"库存为空");
}
InvCountPrint byPrintNumber = invCountPrintMapper.findByPrintNumber(printNumber);
if(byPrintNumber==null){
return new Result(false, StatusCode.ERROR,"判断顺序号查询不到数据");
......@@ -88,8 +97,8 @@ public class InvCountPrintController {
if(byPrintId==null || byPrintId.size()<=0){
return new Result(false, StatusCode.ERROR,"顺序号为【"+printNumber+"】没有子表数据");
}
String sql = "";
String sqld="'";
String sql = " inv_id="+sqld+invId+sqld;
for (InvCountPrintLine invCountPrintLine:byPrintId) {
SysDictItem sysDictItem = sysDictItemMapper.findByItemValue(invCountPrintLine.getCompare());
if(sysDictItem==null){
......
......@@ -227,12 +227,13 @@ public class SalOrderHeaderController {
if(warehouseCode==null||warehouseCode.equals("")){
return new Result(false, StatusCode.ERROR,"缺少库存code信息");
}
//装重复商品id
List skulist=new ArrayList<>();
if(type.equals("1")){
//入库
List<SalOrderHeader> salOrderHeaders = salOrderHeaderMapper.selectSalOrderByattribute1(orderId);
if(salOrderHeaders==null||salOrderHeaders.size()<=0){
return new Result(false, StatusCode.ERROR,"查询不到借阅信息");
return new Result(false, StatusCode.ERROR,"销售订单未同步");
}
salOrderHeaderMapper.updateStatus(salOrderHeaders.get(0).getId(),"refund");
for (JSONObject jsonObject:items) {
......@@ -249,6 +250,7 @@ public class SalOrderHeaderController {
if(StringUtil.isEmpty(skuid)){
return new Result(false, StatusCode.ERROR,"缺少商品skuid");
}
int quantity=0;
for (JSONObject jsonObject1:items) {
JSONObject sku1 = (JSONObject) jsonObject1.get("sku");
......@@ -329,10 +331,14 @@ public class SalOrderHeaderController {
if(StringUtil.isEmpty(skuid)){
return new Result(false, StatusCode.ERROR,"缺少商品skuid");
}
if(skulist.contains(skuid)){
continue;
}
skulist.add(skuid);
int quantity=0;
for (JSONObject jsonObject1:items) {
JSONObject sku1 = (JSONObject) jsonObject1.get("sku");
String id = (String) sku.get("_id");
String id = (String) sku1.get("_id");
if(id.equals(skuid)){
quantity=quantity+1;
}
......@@ -468,12 +474,13 @@ public class SalOrderHeaderController {
if(warehouseCode==null||warehouseCode.equals("")){
return new Result(false, StatusCode.ERROR,"缺少库存code信息");
}
//装重复商品id
List skulist=new ArrayList<>();
if(status.equals("Return")){
//入库
List<SalOrderHeader> salOrderHeaders = salOrderHeaderMapper.selectSalOrderByattribute1(borrowId);
if(salOrderHeaders==null||salOrderHeaders.size()<=0){
return new Result(false, StatusCode.ERROR,"查询不到借阅信息");
return new Result(false, StatusCode.ERROR,"借阅信息未同步");
}
salOrderHeaderMapper.updateStatus(salOrderHeaders.get(0).getId(),"return");
for (JSONObject jsonObject:items) {
......@@ -570,10 +577,14 @@ public class SalOrderHeaderController {
if(StringUtil.isEmpty(skuid)){
return new Result(false, StatusCode.ERROR,"缺少商品skuid");
}
if(skulist.contains(skuid)){
continue;
}
skulist.add(skuid);
int quantity=0;
for (JSONObject jsonObject1:items) {
JSONObject sku1 = (JSONObject) jsonObject1.get("sku");
String id = (String) sku.get("_id");
String id = (String) sku1.get("_id");
if(id.equals(skuid)){
quantity=quantity+1;
}
......@@ -729,4 +740,5 @@ public class SalOrderHeaderController {
data.put("data",jsonObject);
return new Result(true, StatusCode.ERROR,"数据封装完毕",data);
}
}
......@@ -51,7 +51,7 @@ public class TakeStockController {
*/
@PostMapping("/invInventory/search")
public Result invInventorySearch(@RequestParam("access_token")String token, @RequestBody JSONObject requestJson) throws Exception {
public Result invInventorySearch(@RequestParam("access_token")String token, @RequestBody JSONObject requestJson) {
SysAccessToken sysAccessToken = userServer.checkToken(token);
if(requestJson==null||requestJson.size()<=0){
List<InvInventory> select = invInventoryMapper.select();
......@@ -77,7 +77,7 @@ public class TakeStockController {
*/
@PostMapping("/invSubinventory/search")
public Result invSubinventorySearch(@RequestParam("access_token")String token, @RequestBody JSONObject requestJson) throws Exception {
public Result invSubinventorySearch(@RequestParam("access_token")String token, @RequestBody JSONObject requestJson) {
SysAccessToken sysAccessToken = userServer.checkToken(token);
if(requestJson==null||requestJson.size()<=0){
List<InvSubinventory> select = invSubinventoryMapper.select();
......@@ -104,7 +104,7 @@ public class TakeStockController {
*/
@PostMapping("/invLocator/search")
public Result invLocatorSearch(@RequestParam("access_token")String token, @RequestBody JSONObject requestJson) throws Exception {
public Result invLocatorSearch(@RequestParam("access_token")String token, @RequestBody JSONObject requestJson) {
SysAccessToken sysAccessToken = userServer.checkToken(token);
if(requestJson==null||requestJson.size()<=0){
List<InvLocator> select = invLocatorMapper.select();
......@@ -129,7 +129,7 @@ public class TakeStockController {
* @throws Exception
*/
@PostMapping("/sku/search")
public Result skuSearch(@RequestParam("access_token")String token, @RequestBody JSONObject requestJson) throws Exception {
public Result skuSearch(@RequestParam("access_token")String token, @RequestBody JSONObject requestJson) {
SysAccessToken sysAccessToken = userServer.checkToken(token);
if(requestJson==null||requestJson.size()<=0){
List<InvItemBalanceSummaryV> select = invItemBalanceSummaryVMapper.select();
......@@ -173,7 +173,7 @@ public class TakeStockController {
* @throws Exception
*/
@GetMapping("/sku/findLikeSku")
public Result findLikeSku(@RequestParam("access_token")String token, @RequestParam String request) throws Exception {
public Result findLikeSku(@RequestParam("access_token")String token, @RequestParam String request){
SysAccessToken sysAccessToken = userServer.checkToken(token);
if(StringUtil.isEmpty(request)){
return new Result(false,StatusCode.ERROR,"参数为空");
......@@ -183,6 +183,27 @@ public class TakeStockController {
}
/**
* 根据库存查询库存现有量
* @param token
* @param invId
* @return
* @throws Exception
*/
@GetMapping("/sku/findInvId")
public Result findInvId(@RequestParam("access_token")String token, @RequestParam String invId,@RequestParam String request) {
SysAccessToken sysAccessToken = userServer.checkToken(token);
if(StringUtil.isEmpty(invId)){
return new Result(false,StatusCode.ERROR,"参数为空");
}
if(StringUtil.isEmpty(request)){
return new Result(false,StatusCode.ERROR,"参数为空");
}
List<InvItemBalanceSummaryV> byLikeAll = invItemBalanceSummaryVMapper.findByInvIdAndLikeAll(invId,request);
return new Result(true,StatusCode.OK,"库存现有量查询成功",byLikeAll);
}
@Autowired
private RedisTemplate redisTemplate;
......
......@@ -2015,11 +2015,7 @@ public class PurchaseController {
//status和headerId为筛选条件
private List<RcvReceiptLineV> getUniqueRcvReceiptLine(String userName, String userId, String status, String headerId) {
List<RcvReceiptLineV> rcvReceiptLineVList = new ArrayList<>();
rcvReceiptLineVList.addAll(purchaseServer.selectRcvReceiptLineVByUserNameAndStatusAndHeaderId(userName, status, headerId));
List<String> invList = getValidInvIdByUserId(userId);
if (invList.size() > 0) {
rcvReceiptLineVList.addAll(purchaseServer.selectRcvReceiptLineVByInvIdAndStatusAndHeaderId(invList,status, headerId));
}
rcvReceiptLineVList.addAll(purchaseServer.selectRcvReceiptLineVByInvIdAndStatusAndHeaderIdG(status, headerId));
//去重
return rcvReceiptLineVList.stream().collect(
Collectors.collectingAndThen(Collectors.toCollection(
......
......@@ -19,23 +19,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import orthopedics.controller.error.ErrorEnum;
import orthopedics.controller.operation.SaleOrderProcessEnum;
import orthopedics.model.HrOrganization;
import orthopedics.model.InvItem;
import orthopedics.model.InvUnit;
import orthopedics.model.SalCustomer;
import orthopedics.model.SalOrderHeader;
import orthopedics.model.SalOrderHeaderV;
import orthopedics.model.SalOrderLine;
import orthopedics.model.SalOrderLineV;
import orthopedics.model.SalOrderType;
import orthopedics.model.SysAccessToken;
import orthopedics.model.SysOrgAccess;
import orthopedics.model.SysValueSetV;
import orthopedics.model.SalCustomerSite;
import orthopedics.model.SalParameter;
import orthopedics.model.SalSellerV;
import orthopedics.model.SysDocumentProcessLog;
import orthopedics.model.WshShipmentHeader;
import orthopedics.dao.WshParameterMapper;
import orthopedics.model.*;
import orthopedics.service.InventoryServer;
import orthopedics.service.OrganzitionServer;
import orthopedics.service.ProcessLogServer;
......@@ -406,7 +391,8 @@ public class SaleController {
return responseResult.toJSONString();
}
@Autowired
private WshParameterMapper wshParameterMapper;
public String saleOrderHeaderCreateG(JSONObject requestJson) {
logger.info(String.format("----销售订单信息创建接口----- requestJson %s", requestJson.toJSONString()));
......@@ -511,7 +497,7 @@ public class SaleController {
if (saleOrderLineArray != null) {
//line_number 不能重复
List<String> lineNumberList = new ArrayList<>();
//List<String> lineNumberList = new ArrayList<>();
for (int i = 0; i < saleOrderLineArray.size(); i++) {
JSONObject line = saleOrderLineArray.getJSONObject(i);
......@@ -523,14 +509,14 @@ public class SaleController {
});
Double taxRate = line.getDouble("tax_rate");
String lineNumber = line.getString("line_number");
if (lineNumberList.contains(lineNumber)) {
logger.info(String.format("line_number%s重复了", lineNumber));
return "line_number不能为"+lineNumber;
}
else {
lineNumberList.add(lineNumber);
}
// String lineNumber = line.getString("line_number");
// if (lineNumberList.contains(lineNumber) ) {
// logger.info(String.format("line_number%s重复了", lineNumber));
// return "line_number不能为"+lineNumber;
// }
// else {
// lineNumberList.add(lineNumber);
// }
String salePrice = StringUtil.valueOf(line.get("sale_price"));
if (!StringUtil.isPrice(salePrice)) {
logger.info(String.format("sale_price非价格形式", salePrice));
......@@ -556,15 +542,16 @@ public class SaleController {
if (StringUtil.notEmpty(unitCode)) {
checkUnitCode(unitCode);
}
SalParameter salParameter = saleServer.selectParameterByOrgId(orgId);
if (salParameter == null) {
logger.info(String.format("orgCode%s找不到相应的parameter", data.getString("org_code")));
return "org_code不能为"+data.getString("org_code");
}
//SalParameter salParameter = saleServer.selectParameterByOrgId(orgId);
// List<WshParameter> wshParameters = wshParameterMapper.selectWshParamByOrg(orgId);
// if (wshParameters == null || wshParameters.size()<=0) {
// logger.info(String.format("orgCode%s找不到相应的parameter", data.getString("org_code")));
// return "org_code不能为"+data.getString("org_code");
// }
String itemCode = line.getString("item_code");
InvItem invItem = inventoryServer.selectInvItemByItemCodeWithInvIdG(itemCode);
if (invItem == null) {
logger.info(String.format("itemCode:%s和inv_id:%s找不到相应的inv_item", itemCode, salParameter.getSaleMasterInvId()));
logger.info(String.format("itemCode:%s找不到相应的inv_item", itemCode));
return "itemCode不能为"+itemCode;
}
String lineId = line.getString("lineId");
......@@ -598,7 +585,7 @@ public class SaleController {
salOrderLine.setItemCode(itemCode);
salOrderLine.setSalOrderHeaderId(headId);
salOrderLine.setOrderHeaderId(headId);
salOrderLine.setLineNumber(StringUtil.notEmpty(lineNumber) ? lineNumber : String.valueOf(i+1));
salOrderLine.setLineNumber(String.valueOf(i+1));
salOrderLine.setItemId(invItem.getId());
String itemName = line.getString("item_name");
salOrderLine.setItemName(StringUtil.notEmpty(itemName) ? itemName : invItem.getItemName());
......
......@@ -79,8 +79,13 @@ int updateInvCountHeaderStatus(@Param("status") String status, @Param("id") Stri
@ResultMap("invcountheader")
public List<InvCountHeader> fingBySysOrgCode(@Param("sysOrgCode") String sysOrgCode);
//根据sysOrgCode查询
//根据countNumber查询
@Select("select * from inv_count_header where count_number = #{countNumber}")
@ResultMap("invcountheader")
public InvCountHeader fingByCountNumber(@Param("countNumber") String countNumber);
//根据header_status查询
@Select("select * from inv_count_header where header_status = #{status}")
@ResultMap("invcountheader")
public List<InvCountHeader> fingByHeaderStatus(@Param("status") String status);
}
\ No newline at end of file
......@@ -68,8 +68,13 @@ Integer insert(InvCountPrint InvCountPrint);
@ResultMap("invcountprint")
List<InvCountPrint> findByOrgId(@Param("orgId")String orgId);
//通过组织id查询
//通过顺序号查询
@Select("SELECT * FROM inv_count_print WHERE print_number = #{printNumber} ")
@ResultMap("invcountprint")
InvCountPrint findByPrintNumber(@Param("printNumber")String printNumber);
//通过库存id查询
@Select("SELECT * FROM inv_count_print WHERE print_inv_id = #{printInvId} ")
@ResultMap("invcountprint")
List<InvCountPrint> findByPrintInvId(@Param("printInvId")String printInvId);
}
\ No newline at end of file
......@@ -126,6 +126,8 @@ public interface InvItemBalanceSummaryVMapper{
@ResultMap("invitembalancesummaryv")
List<InvItemBalanceSummaryV> findByInvIdAndSubinvIdAndLocatorIdAndItemId(@Param("inv_id") String inv_id,@Param("subinv_id") String subinv_id,@Param("locator_id") String locator_id,@Param("item_id") String item_id);
@Select("SELECT * FROM inv_item_balance_summary_v WHERE inv_id=#{invId} AND (inv_code LIKE '%${request}%' OR inv_name LIKE '%${request}%' OR subinv_code LIKE '%${request}%' OR subinv_name LIKE '%${request}%' OR locator_code LIKE '%${request}%' OR locator_name LIKE '%${request}%' OR plucode LIKE '%${request}%' OR scancode LIKE '%${request}%' OR rfid LIKE '%${request}%' OR item_code LIKE '%${request}%' OR item_name LIKE '%${request}%')")
@ResultMap("invitembalancesummaryv")
List<InvItemBalanceSummaryV> findByInvIdAndLikeAll(@Param("invId") String invId,@Param("request") String request);
}
\ No newline at end of file
......@@ -61,6 +61,7 @@ public interface InvItemMapper{
@Result(property = "rfid", column = "rfid"),
@Result(property = "language", column = "language"),
@Result(property = "marketingStatus", column = "marketing_status"),
@Result(property = "maxInvQty", column = "max_inv_qty"),
})
public List<InvItem> select();
......@@ -78,16 +79,16 @@ public interface InvItemMapper{
InvItem selectByItemId(@Param("itemId") String itemId);
@Insert("<script>" +
"INSERT INTO inv_item(id,attribute_category,attribute1,attribute2,attribute3,attribute4,attribute5,attribute6,attribute7,attribute8,attribute9,attribute10,inv_id,item_code,item_name,item_desc,pystype,media,isbn,plucode,scancode,extcode,purchase_price,general_name,cip,manufacturer_id,specification,image_url,pack_qty,pack_unit,tax,isset,status,default_vendor_id,primary_unit,lot_control,serial_control,min_inv_qty,org_id,create_by,create_time,update_by,update_time,pro_type,is_borrow,rfid,language,marketing_status) VALUES" +
"INSERT INTO inv_item(id,attribute_category,attribute1,attribute2,attribute3,attribute4,attribute5,attribute6,attribute7,attribute8,attribute9,attribute10,inv_id,item_code,item_name,item_desc,pystype,media,isbn,plucode,scancode,extcode,purchase_price,general_name,cip,manufacturer_id,specification,image_url,pack_qty,pack_unit,tax,isset,status,default_vendor_id,primary_unit,lot_control,serial_control,min_inv_qty,org_id,create_by,create_time,update_by,update_time,pro_type,is_borrow,rfid,language,marketing_status,max_inv_qty) VALUES" +
"<foreach collection='invitems' item='item' index='index' separator=','>" +
"(#{item.id},#{item.attributeCategory},#{item.attribute1},#{item.attribute2},#{item.attribute3},#{item.attribute4},#{item.attribute5},#{item.attribute6},#{item.attribute7},#{item.attribute8},#{item.attribute9},#{item.attribute10},#{item.invId},#{item.itemCode},#{item.itemName},#{item.itemDesc},#{item.pystype},#{item.media},#{item.isbn},#{item.plucode},#{item.scancode},#{item.extcode},#{item.purchasePrice},#{item.generalName},#{item.cip},#{item.manufacturerId},#{item.specification},#{item.imageUrl},#{item.packQty},#{item.packUnit},#{item.tax},#{item.isset},#{item.status},#{item.defaultVendorId},#{item.primaryUnit},#{item.lotControl},#{item.serialControl},#{item.minInvQty},#{item.orgId},#{item.createBy},#{item.createTime},#{item.updateBy},#{item.updateTime},#{item.proType},#{item.isBorrow},#{item.rfid},#{item.language},#{item.marketingStatus})" +
"(#{item.id},#{item.attributeCategory},#{item.attribute1},#{item.attribute2},#{item.attribute3},#{item.attribute4},#{item.attribute5},#{item.attribute6},#{item.attribute7},#{item.attribute8},#{item.attribute9},#{item.attribute10},#{item.invId},#{item.itemCode},#{item.itemName},#{item.itemDesc},#{item.pystype},#{item.media},#{item.isbn},#{item.plucode},#{item.scancode},#{item.extcode},#{item.purchasePrice},#{item.generalName},#{item.cip},#{item.manufacturerId},#{item.specification},#{item.imageUrl},#{item.packQty},#{item.packUnit},#{item.tax},#{item.isset},#{item.status},#{item.defaultVendorId},#{item.primaryUnit},#{item.lotControl},#{item.serialControl},#{item.minInvQty},#{item.orgId},#{item.createBy},#{item.createTime},#{item.updateBy},#{item.updateTime},#{item.proType},#{item.isBorrow},#{item.rfid},#{item.language},#{item.marketingStatus},#{item.maxInvQty})" +
"</foreach>" +
"</script>")
Integer insertBatch(@Param("invitems")List<InvItem> InvItemList);
@Insert(
"INSERT INTO inv_item(id,attribute_category,attribute1,attribute2,attribute3,attribute4,attribute5,attribute6,attribute7,attribute8,attribute9,attribute10,inv_id,item_code,item_name,item_desc,pystype,media,isbn,plucode,scancode,extcode,purchase_price,general_name,cip,manufacturer_id,specification,image_url,pack_qty,pack_unit,tax,isset,status,default_vendor_id,primary_unit,lot_control,serial_control,min_inv_qty,org_id,create_by,create_time,update_by,update_time,pro_type,is_borrow,rfid,language,marketing_status) VALUES" +
"(#{id},#{attributeCategory},#{attribute1},#{attribute2},#{attribute3},#{attribute4},#{attribute5},#{attribute6},#{attribute7},#{attribute8},#{attribute9},#{attribute10},#{invId},#{itemCode},#{itemName},#{itemDesc},#{pystype},#{media},#{isbn},#{plucode},#{scancode},#{extcode},#{purchasePrice},#{generalName},#{cip},#{manufacturerId},#{specification},#{imageUrl},#{packQty},#{packUnit},#{tax},#{isset},#{status},#{defaultVendorId},#{primaryUnit},#{lotControl},#{serialControl},#{minInvQty},#{orgId},#{createBy},#{createTime},#{updateBy},#{updateTime},#{proType},#{isBorrow},#{rfid},#{language},#{marketingStatus})"
"INSERT INTO inv_item(id,attribute_category,attribute1,attribute2,attribute3,attribute4,attribute5,attribute6,attribute7,attribute8,attribute9,attribute10,inv_id,item_code,item_name,item_desc,pystype,media,isbn,plucode,scancode,extcode,purchase_price,general_name,cip,manufacturer_id,specification,image_url,pack_qty,pack_unit,tax,isset,status,default_vendor_id,primary_unit,lot_control,serial_control,min_inv_qty,org_id,create_by,create_time,update_by,update_time,pro_type,is_borrow,rfid,language,marketing_status,max_inv_qty) VALUES" +
"(#{id},#{attributeCategory},#{attribute1},#{attribute2},#{attribute3},#{attribute4},#{attribute5},#{attribute6},#{attribute7},#{attribute8},#{attribute9},#{attribute10},#{invId},#{itemCode},#{itemName},#{itemDesc},#{pystype},#{media},#{isbn},#{plucode},#{scancode},#{extcode},#{purchasePrice},#{generalName},#{cip},#{manufacturerId},#{specification},#{imageUrl},#{packQty},#{packUnit},#{tax},#{isset},#{status},#{defaultVendorId},#{primaryUnit},#{lotControl},#{serialControl},#{minInvQty},#{orgId},#{createBy},#{createTime},#{updateBy},#{updateTime},#{proType},#{isBorrow},#{rfid},#{language},#{marketingStatus},#{maxInvQty})"
)
Integer insert(InvItem InvItem);
......@@ -139,4 +140,7 @@ public interface InvItemMapper{
@Select("SELECT * FROM inv_item WHERE plucode = #{plucode}")
@ResultMap("invitem")
InvItem findByPlucode(@Param("plucode") String plucode);
@Select("SELECT item_code FROM inv_item WHERE plucode = #{plucode}")
String getPlucode(@Param("plucode") String plucode);
}
\ No newline at end of file
......@@ -75,4 +75,8 @@ public interface InvLocatorMapper{
@ResultMap("invlocator")
InvLocator findById(@Param("id")String id);
@Select("select * from inv_locator where locator_code = #{locatorCode}")
@ResultMap("invlocator")
InvLocator findLocatorByCode(@Param("locatorCode")String locatorCode);
}
\ No newline at end of file
......@@ -104,6 +104,19 @@ public List<RcvReceiptLineV> select();
public List<RcvReceiptLineV> selectByInvIdAndStatusAndHeaderId
(@Param("invIds")List<String> invIds, @Param("rcvReceiptLineStatus")String rcvReceiptLineStatus,@Param("headerId")String headerId);
@Select("<script>"
+ "SELECT * FROM rcv_receipt_line_v WHERE 1=1 "
+ "<if test = 'rcvReceiptLineStatus != null and rcvReceiptLineStatus != \"\"'>"
+ " AND line_status = #{rcvReceiptLineStatus}"
+ "</if>"
+ "<if test = 'headerId != null and headerId != \"\"'>"
+ " AND rcv_receipt_header_id = #{headerId}"
+ "</if>"
+ "</script>")
@ResultMap("rcvreceiptlinev")
public List<RcvReceiptLineV> selectByInvIdAndStatusAndHeaderIdG
(@Param("rcvReceiptLineStatus")String rcvReceiptLineStatus,@Param("headerId")String headerId);
@Select("<script>" +
"SELECT * FROM rcv_receipt_line_v rl " +
"LEFT JOIN sys_value_set_v vs " +
......
package orthopedics.dao;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Insert;
import orthopedics.model.SalOrderLineDetailV;
/**
* @author author
*/
public interface SalOrderLineDetailVMapper{
@Select("SELECT * FROM sal_order_line_detail_v")
@Results(id = "salorderlinedetailv", value ={
@Result(property = "orderTypeId", column = "order_type_id"),
@Result(property = "orderDate", column = "order_date"),
@Result(property = "orderNumber", column = "order_number"),
@Result(property = "customerId", column = "customer_id"),
@Result(property = "sellerId", column = "seller_id"),
@Result(property = "salStatus", column = "sal_status"),
@Result(property = "orgId", column = "org_id"),
@Result(property = "itemName", column = "item_name"),
@Result(property = "itemDesc", column = "item_desc"),
@Result(property = "quantity", column = "quantity"),
@Result(property = "unitCode", column = "unit_code"),
@Result(property = "salePrice", column = "sale_price"),
@Result(property = "taxRate", column = "tax_rate"),
@Result(property = "attribute1", column = "attribute1"),
@Result(property = "attribute2", column = "attribute2"),
@Result(property = "attribute3", column = "attribute3"),
@Result(property = "requiredDate", column = "required_date"),
@Result(property = "sumPrice", column = "sum_price"),
@Result(property = "shipmentType", column = "shipment_type"),
@Result(property = "shipmentNumber", column = "shipment_number"),
@Result(property = "shipmentDate", column = "shipment_date"),
@Result(property = "invId", column = "inv_id"),
@Result(property = "subinvId", column = "subinv_id"),
@Result(property = "locatorId", column = "locator_id"),
@Result(property = "shipmentQuantity", column = "shipment_quantity"),
})
public List<SalOrderLineDetailV> select();
@Insert("<script>" +
"INSERT INTO sal_order_line_detail_v(order_type_id,order_date,order_number,customer_id,seller_id,sal_status,org_id,item_name,item_desc,quantity,unit_code,sale_price,tax_rate,attribute1,attribute2,attribute3,required_date,sum_price,shipment_type,shipment_number,shipment_date,inv_id,subinv_id,locator_id,shipment_quantity) VALUES" +
"<foreach collection='salorderlinedetailvs' item='item' index='index' separator=','>" +
"(#{item.orderTypeId},#{item.orderDate},#{item.orderNumber},#{item.customerId},#{item.sellerId},#{item.salStatus},#{item.orgId},#{item.itemName},#{item.itemDesc},#{item.quantity},#{item.unitCode},#{item.salePrice},#{item.taxRate},#{item.attribute1},#{item.attribute2},#{item.attribute3},#{item.requiredDate},#{item.sumPrice},#{item.shipmentType},#{item.shipmentNumber},#{item.shipmentDate},#{item.invId},#{item.subinvId},#{item.locatorId},#{item.shipmentQuantity})" +
"</foreach>" +
"</script>")
Integer insertBatch(@Param("salorderlinedetailvs") List<SalOrderLineDetailV> SalOrderLineDetailVList);
@Insert(
"INSERT INTO sal_order_line_detail_v(order_type_id,order_date,order_number,customer_id,seller_id,sal_status,org_id,item_name,item_desc,quantity,unit_code,sale_price,tax_rate,attribute1,attribute2,attribute3,required_date,sum_price,shipment_type,shipment_number,shipment_date,inv_id,subinv_id,locator_id,shipment_quantity) VALUES" +
"(#{orderTypeId},#{orderDate},#{orderNumber},#{customerId},#{sellerId},#{salStatus},#{orgId},#{itemName},#{itemDesc},#{quantity},#{unitCode},#{salePrice},#{taxRate},#{attribute1},#{attribute2},#{attribute3},#{requiredDate},#{sumPrice},#{shipmentType},#{shipmentNumber},#{shipmentDate},#{invId},#{subinvId},#{locatorId},#{shipmentQuantity})"
)
Integer insert(SalOrderLineDetailV SalOrderLineDetailV);
@Select("SELECT * FROM sal_order_line_detail_v WHERE order_number = #{orderNumber}")
@ResultMap("salorderlinedetailv")
SalOrderLineDetailV findByOrderNumber(@Param("orderNumber") String orderNumber);
}
\ No newline at end of file
......@@ -66,7 +66,10 @@ Integer insert(TempItemFomPmp TempItemFomPmp);
@Select("select count(temp_item_fom_pmp.`id`) from temp_item_fom_pmp")
Integer findCount();
@Select("SELECT * FROM temp_item_fom_pmp LIMIT ${sta},10000")
@Select("SELECT * FROM temp_item_fom_pmp LIMIT ${sta},5000")
@ResultMap("tempitemfompmp")
public List<TempItemFomPmp> findLimit(@Param("sta") int sta);
@Select("SELECT plucode FROM temp_item_fom_pmp LIMIT ${sta},${end}")
public List<String> findLimitByStaEnd(@Param("sta") int sta,@Param("end") int end);
}
\ No newline at end of file
......@@ -5,16 +5,13 @@ import java.util.HashMap;
import java.util.Map;
import java.util.List;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
/**
*
* @author ice
* @author author
*/
public class InvItem implements Serializable {
private static final long serialVersionUID = 1566298641844L;
private static final long serialVersionUID = 1572260837783L;
/**
......@@ -33,43 +30,43 @@ public class InvItem implements Serializable {
private String attributeCategory;
/**
* 备用字段1
* isNullAble:1
* 商品类型
* isNullAble:0
*/
@JSONField(name = "attribute1")
private String attribute1;
/**
* 备用字段2
* isNullAble:1
* 采购类型
* isNullAble:0
*/
@JSONField(name = "attribute2")
private String attribute2;
/**
* 备用子段3
* 寄售
* isNullAble:1
*/
@JSONField(name = "attribute3")
private String attribute3;
/**
* 备用字段4
* 扣点%
* isNullAble:1
*/
@JSONField(name = "attribute4")
private String attribute4;
/**
* 备用字段5
* 库存信息同步到pmp
* isNullAble:1
*/
@JSONField(name = "attribute5")
private String attribute5;
/**
* 备用字段6
* isNullAble:1
* 商品信息同步到是否pos
* isNullAble:1,defaultVal:0
*/
@JSONField(name = "attribute6")
private String attribute6;
......@@ -111,14 +108,14 @@ public class InvItem implements Serializable {
/**
* 商品代码
* isNullAble:0
* isNullAble:1
*/
@JSONField(name = "item_code")
private String itemCode;
/**
* 商品名称
* isNullAble:1
* isNullAble:0
*/
@JSONField(name = "item_name")
private String itemName;
......@@ -153,28 +150,28 @@ public class InvItem implements Serializable {
/**
* 货号
* isNullAble:0
* isNullAble:1
*/
@JSONField(name = "plucode")
private String plucode;
/**
* 扫描码
* isNullAble:0
* isNullAble:1
*/
@JSONField(name = "scancode")
private String scancode;
/**
* 延长码
* isNullAble:1,defaultVal:3
* isNullAble:1,defaultVal:0
*/
@JSONField(name = "extcode")
private String extcode;
/**
* 价格
* isNullAble:1
* isNullAble:0
*/
@JSONField(name = "purchase_price")
private String purchasePrice;
......@@ -188,7 +185,7 @@ public class InvItem implements Serializable {
/**
* CIP分类
* isNullAble:0
* isNullAble:1
*/
@JSONField(name = "cip")
private String cip;
......@@ -205,8 +202,6 @@ public class InvItem implements Serializable {
* isNullAble:1
*/
@JSONField(name = "specification")
@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private java.time.LocalDateTime specification;
/**
......@@ -260,21 +255,21 @@ public class InvItem implements Serializable {
/**
* 单位
* isNullAble:1
* isNullAble:0
*/
@JSONField(name = "primary_unit")
private String primaryUnit;
/**
* 批次控制
* isNullAble:1
* isNullAble:1,defaultVal:N
*/
@JSONField(name = "lot_control")
private String lotControl;
/**
* 序列控制
* isNullAble:1
* isNullAble:1,defaultVal:N
*/
@JSONField(name = "serial_control")
private String serialControl;
......@@ -305,8 +300,6 @@ public class InvItem implements Serializable {
* isNullAble:1
*/
@JSONField(name = "create_time")
@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private java.time.LocalDateTime createTime;
/**
......@@ -321,20 +314,18 @@ public class InvItem implements Serializable {
* isNullAble:1
*/
@JSONField(name = "update_time")
@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private java.time.LocalDateTime updateTime;
/**
* 商品类型
* isNullAble:0
* 商品分类
* isNullAble:1
*/
@JSONField(name = "pro_type")
private String proType;
/**
* 可借阅
* isNullAble:1
* isNullAble:0
*/
@JSONField(name = "is_borrow")
private String isBorrow;
......@@ -360,6 +351,13 @@ public class InvItem implements Serializable {
@JSONField(name = "marketing_status")
private String marketingStatus;
/**
* 库存上限
* isNullAble:1
*/
@JSONField(name = "max_inv_qty")
private String maxInvQty;
public void setId(String id){this.id = id;}
......@@ -552,6 +550,10 @@ public class InvItem implements Serializable {
public void setMarketingStatus(String marketingStatus){this.marketingStatus = marketingStatus;}
public String getMarketingStatus(){return this.marketingStatus;}
public void setMaxInvQty(String maxInvQty){this.maxInvQty = maxInvQty;}
public String getMaxInvQty(){return this.maxInvQty;}
@Override
public String toString() {
return "InvItem{" +
......@@ -603,6 +605,7 @@ public class InvItem implements Serializable {
"rfid='" + rfid + '\'' +
"language='" + language + '\'' +
"marketingStatus='" + marketingStatus + '\'' +
"maxInvQty='" + maxInvQty + '\'' +
'}';
}
......
package orthopedics.model;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
import com.alibaba.fastjson.annotation.JSONField;
/**
*
* @author author
*/
public class SalOrderLineDetailV implements Serializable {
private static final long serialVersionUID = 1572232529131L;
/**
*
* isNullAble:1
*/
@JSONField(name = "order_type_id")
private String orderTypeId;
/**
* 订单日期
* isNullAble:1
*/
@JSONField(name = "order_date")
private java.time.LocalDateTime orderDate;
/**
* 订单编号
* isNullAble:0
*/
@JSONField(name = "order_number")
private String orderNumber;
/**
*
* isNullAble:1
*/
@JSONField(name = "customer_id")
private String customerId;
/**
*
* isNullAble:1
*/
@JSONField(name = "seller_id")
private String sellerId;
/**
* 订单状态
* isNullAble:1,defaultVal:new
*/
@JSONField(name = "sal_status")
private String salStatus;
/**
*
* isNullAble:1
*/
@JSONField(name = "org_id")
private String orgId;
/**
* 商品名称
* isNullAble:1
*/
@JSONField(name = "item_name")
private String itemName;
/**
* 商品简称
* isNullAble:1
*/
@JSONField(name = "item_desc")
private String itemDesc;
/**
* 数量
* isNullAble:1
*/
@JSONField(name = "quantity")
private Integer quantity;
/**
*
* isNullAble:1
*/
@JSONField(name = "unit_code")
private String unitCode;
/**
* 价格
* isNullAble:1
*/
@JSONField(name = "sale_price")
private Double salePrice;
/**
* 税率
* isNullAble:1
*/
@JSONField(name = "tax_rate")
private String taxRate;
/**
* 码洋
* isNullAble:1
*/
@JSONField(name = "attribute1")
private Double attribute1;
/**
* 金额
* isNullAble:1
*/
@JSONField(name = "attribute2")
private Double attribute2;
/**
* 折扣%
* isNullAble:1
*/
@JSONField(name = "attribute3")
private String attribute3;
/**
* 需求日期
* isNullAble:1
*/
@JSONField(name = "required_date")
private java.time.LocalDateTime requiredDate;
/**
*
* isNullAble:1
*/
@JSONField(name = "sum_price")
private String sumPrice;
/**
* 发运类型
* isNullAble:1
*/
@JSONField(name = "shipment_type")
private String shipmentType;
/**
* 发运单号
* isNullAble:1
*/
@JSONField(name = "shipment_number")
private String shipmentNumber;
/**
* 发运日期
* isNullAble:1
*/
@JSONField(name = "shipment_date")
private java.time.LocalDateTime shipmentDate;
/**
*
* isNullAble:1
*/
@JSONField(name = "inv_id")
private String invId;
/**
*
* isNullAble:1
*/
@JSONField(name = "subinv_id")
private String subinvId;
/**
*
* isNullAble:1
*/
@JSONField(name = "locator_id")
private String locatorId;
/**
* 数量
* isNullAble:1
*/
@JSONField(name = "shipment_quantity")
private Integer shipmentQuantity;
public void setOrderTypeId(String orderTypeId){this.orderTypeId = orderTypeId;}
public String getOrderTypeId(){return this.orderTypeId;}
public void setOrderDate(java.time.LocalDateTime orderDate){this.orderDate = orderDate;}
public java.time.LocalDateTime getOrderDate(){return this.orderDate;}
public void setOrderNumber(String orderNumber){this.orderNumber = orderNumber;}
public String getOrderNumber(){return this.orderNumber;}
public void setCustomerId(String customerId){this.customerId = customerId;}
public String getCustomerId(){return this.customerId;}
public void setSellerId(String sellerId){this.sellerId = sellerId;}
public String getSellerId(){return this.sellerId;}
public void setSalStatus(String salStatus){this.salStatus = salStatus;}
public String getSalStatus(){return this.salStatus;}
public void setOrgId(String orgId){this.orgId = orgId;}
public String getOrgId(){return this.orgId;}
public void setItemName(String itemName){this.itemName = itemName;}
public String getItemName(){return this.itemName;}
public void setItemDesc(String itemDesc){this.itemDesc = itemDesc;}
public String getItemDesc(){return this.itemDesc;}
public void setQuantity(Integer quantity){this.quantity = quantity;}
public Integer getQuantity(){return this.quantity;}
public void setUnitCode(String unitCode){this.unitCode = unitCode;}
public String getUnitCode(){return this.unitCode;}
public void setSalePrice(Double salePrice){this.salePrice = salePrice;}
public Double getSalePrice(){return this.salePrice;}
public void setTaxRate(String taxRate){this.taxRate = taxRate;}
public String getTaxRate(){return this.taxRate;}
public void setAttribute1(Double attribute1){this.attribute1 = attribute1;}
public Double getAttribute1(){return this.attribute1;}
public void setAttribute2(Double attribute2){this.attribute2 = attribute2;}
public Double getAttribute2(){return this.attribute2;}
public void setAttribute3(String attribute3){this.attribute3 = attribute3;}
public String getAttribute3(){return this.attribute3;}
public void setRequiredDate(java.time.LocalDateTime requiredDate){this.requiredDate = requiredDate;}
public java.time.LocalDateTime getRequiredDate(){return this.requiredDate;}
public void setSumPrice(String sumPrice){this.sumPrice = sumPrice;}
public String getSumPrice(){return this.sumPrice;}
public void setShipmentType(String shipmentType){this.shipmentType = shipmentType;}
public String getShipmentType(){return this.shipmentType;}
public void setShipmentNumber(String shipmentNumber){this.shipmentNumber = shipmentNumber;}
public String getShipmentNumber(){return this.shipmentNumber;}
public void setShipmentDate(java.time.LocalDateTime shipmentDate){this.shipmentDate = shipmentDate;}
public java.time.LocalDateTime getShipmentDate(){return this.shipmentDate;}
public void setInvId(String invId){this.invId = invId;}
public String getInvId(){return this.invId;}
public void setSubinvId(String subinvId){this.subinvId = subinvId;}
public String getSubinvId(){return this.subinvId;}
public void setLocatorId(String locatorId){this.locatorId = locatorId;}
public String getLocatorId(){return this.locatorId;}
public void setShipmentQuantity(Integer shipmentQuantity){this.shipmentQuantity = shipmentQuantity;}
public Integer getShipmentQuantity(){return this.shipmentQuantity;}
@Override
public String toString() {
return "SalOrderLineDetailV{" +
"orderTypeId='" + orderTypeId + '\'' +
"orderDate='" + orderDate + '\'' +
"orderNumber='" + orderNumber + '\'' +
"customerId='" + customerId + '\'' +
"sellerId='" + sellerId + '\'' +
"salStatus='" + salStatus + '\'' +
"orgId='" + orgId + '\'' +
"itemName='" + itemName + '\'' +
"itemDesc='" + itemDesc + '\'' +
"quantity='" + quantity + '\'' +
"unitCode='" + unitCode + '\'' +
"salePrice='" + salePrice + '\'' +
"taxRate='" + taxRate + '\'' +
"attribute1='" + attribute1 + '\'' +
"attribute2='" + attribute2 + '\'' +
"attribute3='" + attribute3 + '\'' +
"requiredDate='" + requiredDate + '\'' +
"sumPrice='" + sumPrice + '\'' +
"shipmentType='" + shipmentType + '\'' +
"shipmentNumber='" + shipmentNumber + '\'' +
"shipmentDate='" + shipmentDate + '\'' +
"invId='" + invId + '\'' +
"subinvId='" + subinvId + '\'' +
"locatorId='" + locatorId + '\'' +
"shipmentQuantity='" + shipmentQuantity + '\'' +
'}';
}
}
......@@ -116,6 +116,9 @@ public class PurchaseServer {
public List<RcvReceiptLineV> selectRcvReceiptLineVByInvIdAndStatusAndHeaderId(List<String> invIds, String rcvReceiptLineStatus, String headerId) {
return rcvReceiptLineVMapper.selectByInvIdAndStatusAndHeaderId(invIds, rcvReceiptLineStatus, headerId);
}
public List<RcvReceiptLineV> selectRcvReceiptLineVByInvIdAndStatusAndHeaderIdG(String rcvReceiptLineStatus, String headerId) {
return rcvReceiptLineVMapper.selectByInvIdAndStatusAndHeaderIdG(rcvReceiptLineStatus, headerId);
}
public List<RcvReceiptLineV> selectRcvReceiptLineVByUserNameAndHeaderIdInStatusRange(String userName, String statusFrom, String statusTo, String headerId) {
return rcvReceiptLineVMapper.selectByUserAndHeaderIdInStatusRange(userName, statusFrom, statusTo, headerId);
......
package orthopedics.util;
import java.lang.management.ManagementFactory;
import java.net.InetAddress;
import java.net.NetworkInterface;
/**
* <p>名称:IdWorker.java</p>
* <p>描述:分布式自增长ID</p>
* <pre>
* Twitter的 Snowflake JAVA实现方案
* </pre>
* 核心代码为其IdWorker这个类实现,其原理结构如下,我分别用一个0表示一位,用—分割开部分的作用:
* 1||0---0000000000 0000000000 0000000000 0000000000 0 --- 00000 ---00000 ---000000000000
* 在上面的字符串中,第一位为未使用(实际上也可作为long的符号位),接下来的41位为毫秒级时间,
* 然后5位datacenter标识位,5位机器ID(并不算标识符,实际是为线程标识),
* 然后12位该毫秒内的当前毫秒内的计数,加起来刚好64位,为一个Long型。
* 这样的好处是,整体上按照时间自增排序,并且整个分布式系统内不会产生ID碰撞(由datacenter和机器ID作区分),
* 并且效率较高,经测试,snowflake每秒能够产生26万ID左右,完全满足需要。
* <p>
* 64位ID (42(毫秒)+5(机器ID)+5(业务编码)+12(重复累加))
*
* @author Polim
*/
public class IdWorker {
// 时间起始标记点,作为基准,一般取系统的最近时间(一旦确定不能变动)
private final static long twepoch = 1288834974657L;
// 机器标识位数
private final static long workerIdBits = 5L;
// 数据中心标识位数
private final static long datacenterIdBits = 5L;
// 机器ID最大值
private final static long maxWorkerId = -1L ^ (-1L << workerIdBits);
// 数据中心ID最大值
private final static long maxDatacenterId = -1L ^ (-1L << datacenterIdBits);
// 毫秒内自增位
private final static long sequenceBits = 12L;
// 机器ID偏左移12位
private final static long workerIdShift = sequenceBits;
// 数据中心ID左移17位
private final static long datacenterIdShift = sequenceBits + workerIdBits;
// 时间毫秒左移22位
private final static long timestampLeftShift = sequenceBits + workerIdBits + datacenterIdBits;
private final static long sequenceMask = -1L ^ (-1L << sequenceBits);
/* 上次生产id时间戳 */
private static long lastTimestamp = -1L;
// 0,并发控制
private long sequence = 0L;
private final long workerId;
// 数据标识id部分
private final long datacenterId;
public IdWorker(){
this.datacenterId = getDatacenterId(maxDatacenterId);
this.workerId = getMaxWorkerId(datacenterId, maxWorkerId);
}
/**
* @param workerId
* 工作机器ID
* @param datacenterId
* 序列号
*/
public IdWorker(long workerId, long datacenterId) {
if (workerId > maxWorkerId || workerId < 0) {
throw new IllegalArgumentException(String.format("worker Id can't be greater than %d or less than 0", maxWorkerId));
}
if (datacenterId > maxDatacenterId || datacenterId < 0) {
throw new IllegalArgumentException(String.format("datacenter Id can't be greater than %d or less than 0", maxDatacenterId));
}
this.workerId = workerId;
this.datacenterId = datacenterId;
}
/**
* 获取下一个ID
*
* @return
*/
public synchronized long nextId() {
long timestamp = timeGen();
if (timestamp < lastTimestamp) {
throw new RuntimeException(String.format("Clock moved backwards. Refusing to generate id for %d milliseconds", lastTimestamp - timestamp));
}
if (lastTimestamp == timestamp) {
// 当前毫秒内,则+1
sequence = (sequence + 1) & sequenceMask;
if (sequence == 0) {
// 当前毫秒内计数满了,则等待下一秒
timestamp = tilNextMillis(lastTimestamp);
}
} else {
sequence = 0L;
}
lastTimestamp = timestamp;
// ID偏移组合生成最终的ID,并返回ID
long nextId = ((timestamp - twepoch) << timestampLeftShift)
| (datacenterId << datacenterIdShift)
| (workerId << workerIdShift) | sequence;
return nextId;
}
private long tilNextMillis(final long lastTimestamp) {
long timestamp = this.timeGen();
while (timestamp <= lastTimestamp) {
timestamp = this.timeGen();
}
return timestamp;
}
private long timeGen() {
return System.currentTimeMillis();
}
/**
* <p>
* 获取 maxWorkerId
* </p>
*/
protected static long getMaxWorkerId(long datacenterId, long maxWorkerId) {
StringBuffer mpid = new StringBuffer();
mpid.append(datacenterId);
String name = ManagementFactory.getRuntimeMXBean().getName();
if (!name.isEmpty()) {
/*
* GET jvmPid
*/
mpid.append(name.split("@")[0]);
}
/*
* MAC + PID 的 hashcode 获取16个低位
*/
return (mpid.toString().hashCode() & 0xffff) % (maxWorkerId + 1);
}
/**
* <p>
* 数据标识id部分
* </p>
*/
protected static long getDatacenterId(long maxDatacenterId) {
long id = 0L;
try {
InetAddress ip = InetAddress.getLocalHost();
NetworkInterface network = NetworkInterface.getByInetAddress(ip);
if (network == null) {
id = 1L;
} else {
byte[] mac = network.getHardwareAddress();
id = ((0x000000FF & (long) mac[mac.length - 1])
| (0x0000FF00 & (((long) mac[mac.length - 2]) << 8))) >> 6;
id = id % (maxDatacenterId + 1);
}
} catch (Exception e) {
System.out.println(" getDatacenterId: " + e.getMessage());
}
return id;
}
}
......@@ -11,7 +11,10 @@ spring.messages.encoding=UTF-8
spring.datasource.driverClassName = com.mysql.jdbc.Driver
#书城测试服务器
spring.datasource.url = jdbc:mysql://116.62.111.56:3306/bookcity?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowMultiQueries=true
#书城正式服务器
#spring.datasource.url = jdbc:mysql://10.200.5.45:3306/bookcity?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowMultiQueries=true
spring.datasource.username = root
spring.datasource.password = 123456
......
package orthopedics.test;
import orthopedics.util.HttpUtil;
import orthopedics.util.IdWorker;
import orthopedics.util.MD5Util;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
public class Demo {
public static void main(String[] args) {
System.err.println("789");
if(1 % 10000 == 0){
System.err.println("123");
Set s=new HashSet();
IdWorker id=new IdWorker();
for (long i=0;i<10000000;i++){
s.add(id.nextId());
}
System.err.println(s.size());
}
......
package orthopedics.test;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.apache.ibatis.annotations.Update;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import orthopedics.dao.*;
import orthopedics.model.*;
import orthopedics.service.PropertiesServer;
import orthopedics.service.UserServer;
import orthopedics.util.*;
import java.sql.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.*;
import java.util.Date;
/**
* 将pmp的数据同步到erp临时表
*/
@RunWith(SpringRunner.class)
@SpringBootTest
public class SyncPMPTest {
@Autowired
private UserServer userServer;
@Autowired
private RedisTemplate redisTemplate;
@Autowired
private PropertiesServer propertiesServer;
@Autowired
private SysUserDepartMapper sysUserDepartMapper;
@Autowired
private InvItemMapper invItemMapper;
@Autowired
private InvItemSkuMapper invItemSkuMapper;
@Autowired
private InvItemAttributeMapper invItemAttributeMapper;
@Autowired
private InvItemPmpMapper invItemPmpMapper;
public static long getTimestamp() {
long milli = System.currentTimeMillis() + 8*3600*1000;
return (milli*10000)+621355968000000000L;
}
public Result getPMPInvItemTest(String access_token, String sta, String end) {
SysAccessToken sysAccessToken = userServer.checkToken(access_token);
String gettoken = HttpUtilRSA.getToken();
if(StringUtil.isEmpty(gettoken)){
return new Result(false, StatusCode.ERROR,"获取PMP系统token失败");
}
JSONObject jsonObject = JSONObject.parseObject(gettoken);
String token = jsonObject.getString("Token");
String tempEncryptKey = jsonObject.getString("TempEncryKey");
JSONObject data=new JSONObject();
data.put("uniquekey","获取商品资料列表");
data.put("timestamp", getTimestamp());
data.put("begintime",sta);
data.put("endTime",end);
byte[] encrypt = Aes.encrypt(JSON.toJSONString(data), tempEncryptKey, tempEncryptKey);
try {
byte[] bytes = HttpUtilPMP.postBy("http://pmpapi.szcbfx.com/api/pmp/ExchangePMPData", encrypt,token);
String s = new String(bytes);
JSONObject object = JSONObject.parseObject(s);
Object result = object.get("result");
if(result==null||!result.equals("success")){
return new Result(false,StatusCode.ERROR,"获取商品信息失败");
}
List<JSONObject> retMsg= (List<JSONObject>) object.get("ret_msg");
for (JSONObject item:retMsg) {
//检测是否是重复数据
String plucode = item.getString("PLUCODE");
if(StringUtil.isEmpty(plucode)){
continue;
}
List<InvItem> invItems = invItemMapper.selectByPlucode(plucode);
if(invItems!=null&&invItems.size()>0){
continue;
}
InvItem invItem=new InvItem();
InvItemAttribute invItemAttribute=new InvItemAttribute();
InvItemSku invItemSku=new InvItemSku();
InvItemPmp invItemPmp=new InvItemPmp();
//商品表
invItem.setId(UuidUtil.get32UUIDString());
invItem.setOrgId("964daee94b604cd58e5e6bf48dd9670a");
invItem.setStatus("SALE");
String itemCode = propertiesServer.generateFlowingWater("ITEM_SERIAL");
if(StringUtil.isEmpty(itemCode)){
invItem.setItemCode(UuidUtil.get32UUIDString());
}else{
invItem.setItemCode(itemCode);
}
invItem.setItemName(item.getString("TITLE"));
invItem.setProType("14");
invItem.setItemDesc(item.getString("JP"));
invItem.setPystype(item.getString("PYSTYPE"));
invItem.setIsbn(item.getString("ISBN"));
invItem.setPlucode(item.getString("PLUCODE"));
invItem.setScancode(item.getString("SCANCODE"));
invItem.setExtcode("0");
invItem.setPurchasePrice(item.getString("PRICE"));
invItem.setGeneralName(item.getString("CLSCODE"));
invItem.setManufacturerId(item.getString("PUBLISHER"));
if(!StringUtil.isEmpty(item.getDate("PUBDATE"))){
invItem.setSpecification(item.getDate("PUBDATE").toInstant()
.atZone( ZoneId.systemDefault() )
.toLocalDateTime());
}
invItem.setPrimaryUnit("BEN");
if(item.getString("PYSTYPE").equals("0")||item.getString("PYSTYPE").equals("4")){
invItem.setAttribute1("Book");
invItem.setIsBorrow("Y");
}else{
invItem.setAttribute1("Goods");
invItem.setIsBorrow("N");
}
invItem.setAttribute2("A");
invItem.setTax(item.getString("INCTAX"));
invItem.setDefaultVendorId("000000006c60dba1016c60f839270004");
invItem.setCreateBy(sysAccessToken.getUserName());
invItem.setCreateTime(LocalDateTime.now());
//查询当前用户部门
SysUserDepart sysUserDepart = sysUserDepartMapper.selectByUserId(sysAccessToken.getUserId());
//图书信息
invItemAttribute.setId(UuidUtil.get32UUIDString());
invItemAttribute.setCreateBy(sysAccessToken.getUserName());
invItemAttribute.setCreateTime(LocalDateTime.now());
if(sysUserDepart!=null){
invItemAttribute.setSysOrgCode(sysUserDepart.getDepId());
}
invItemAttribute.setItemId(invItem.getId());
invItemAttribute.setItemCode(invItem.getItemCode());
invItemAttribute.setAuthor(item.getString("AUTHOR"));
invItemAttribute.setReader(item.getString("READER"));
//商品SKU映射
invItemSku.setId(UuidUtil.get32UUIDString());
if(sysUserDepart!=null){
invItemSku.setSysOrgCode(sysUserDepart.getDepId());
}
invItemSku.setOrgId("964daee94b604cd58e5e6bf48dd9670a");
invItemSku.setExternal("PMP");
invItemSku.setItemSku(item.getString("PLUCODE"));
invItemSku.setItemName(invItem.getItemName());
invItemSku.setItemCode(invItem.getItemCode());
invItemSku.setItemDesc(invItem.getItemDesc());
invItemSku.setStatus("A");
invItemSku.setCreateBy(sysAccessToken.getUserName());
invItemSku.setCreateTime(LocalDateTime.now());
//pmp商品缓存表
invItemPmp.setId(UuidUtil.get32UUIDString());
invItemPmp.setPlucode(item.getString("PLUCODE"));
invItemPmp.setPystype(item.getInteger("PYSTYPE"));
invItemPmp.setIsbn(item.getString("ISBN"));
invItemPmp.setScancode(item.getString("SCANCODE"));
invItemPmp.setTitle(item.getString("TITLE"));
invItemPmp.setJp(item.getString("JP"));
invItemPmp.setPrice(item.getBigDecimal("PRICE"));
invItemPmp.setClscode(item.getString("CLSCODE"));
invItemPmp.setClsname(item.getString("CLSNAME"));
invItemPmp.setPublisher(item.getString("PUBLISHER"));
invItemPmp.setPubname(item.getString("PUBNAME"));
if(!StringUtil.isEmpty(item.getDate("PUBDATE"))){
invItemPmp.setPubdate(item.getDate("PUBDATE").toInstant()
.atZone( ZoneId.systemDefault() )
.toLocalDateTime());
}
invItemPmp.setDptcode(item.getString("DPTCODE"));
invItemPmp.setDptname(item.getString("DPTNAME"));
invItemPmp.setSeries(item.getString("SERIES"));
invItemPmp.setAuthor(item.getString("AUTHOR"));
invItemPmp.setReader(item.getString("READER"));
if(!StringUtil.isEmpty(item.getDate("FSTDATE"))){
invItemPmp.setFstdate(item.getDate("FSTDATE").toInstant()
.atZone( ZoneId.systemDefault() )
.toLocalDateTime());
}
invItemPmp.setFstdisc(item.getBigDecimal("FSTDISC"));
invItemPmp.setLstdisc(item.getBigDecimal("LSTDISC"));
invItemPmp.setMaxdisc(item.getBigDecimal("MAXDISC"));
invItemPmp.setMindisc(item.getBigDecimal("MINDISC"));
invItemPmp.setVendor(item.getString("VENDOR"));
invItemPmp.setTranstitle(item.getString("TRANSTITLE"));
invItemPmp.setInctax(item.getInteger("INCTAX"));
invItemPmp.setOriginprice(item.getBigDecimal("ORIGINPRICE"));
invItemPmp.setCurrency(item.getString("CURRENCY"));
invItemPmp.setStatus(1);
invItemMapper.insert(invItem);
invItemSkuMapper.insert(invItemSku);
invItemAttributeMapper.insert(invItemAttribute);
invItemPmpMapper.insert(invItemPmp);
}
return new Result(true,StatusCode.OK,"获取商品信息成功");
} catch (Exception e) {
}
return new Result(false,StatusCode.ERROR,"获取商品信息失败");
}
//获取一年后的时间
public String getDate1(String str) throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date parse = sdf.parse(str);
Calendar cal = Calendar.getInstance();
cal.setTime(parse);
cal.add(Calendar.DATE, 10);//增加5年
return sdf.format(cal.getTime());
}
/**
* 获取pmp商品同步到临时表
*/
@Autowired
private TempItemFomPmpMapper tempItemFomPmpMapper;
@Test
public void getPMPHistoryInvItem(){
String sta = null;
String end = null;
String begintime= (String) redisTemplate.opsForValue().get("getPMPInvItem");
SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" );
if(StringUtil.isEmpty(begintime)){
sta = "1995-1-1 00:00:00";
}else{
sta = begintime;
}
try {
Date parse = sdf.parse(sta);
long time = parse.getTime();
while (time<=new Date().getTime()){
end = getDate1(sta);
String gettoken = HttpUtilRSA.getToken();
JSONObject jsonObject = JSONObject.parseObject(gettoken);
String token = jsonObject.getString("Token");
String tempEncryptKey = jsonObject.getString("TempEncryKey");
JSONObject data=new JSONObject();
data.put("uniquekey","获取商品资料列表");
data.put("timestamp", getTimestamp());
data.put("begintime",sta);
data.put("endTime",end);
byte[] encrypt = Aes.encrypt(JSON.toJSONString(data), tempEncryptKey, tempEncryptKey);
byte[] bytes = HttpUtilPMP.postBy("http://pmpapi.szcbfx.com/api/pmp/ExchangePMPData", encrypt,token);
String s = new String(bytes);
JSONObject object = JSONObject.parseObject(s);
List<JSONObject> retMsg= (List<JSONObject>) object.get("ret_msg");
System.err.println(sta+"获取到"+retMsg.size()+"条商品");
if(retMsg.size()<=0){
redisTemplate.opsForValue().set("getPMPInvItem",end);
System.err.println(sta+"同步了"+retMsg.size()+"条商品");
sta = end;
continue;
}
List<TempItemFomPmp> tempItemFomPmpList=new ArrayList<>();
for (JSONObject item:retMsg){
TempItemFomPmp invItemPmp=new TempItemFomPmp();
//pmp商品缓存表
invItemPmp.setId(UuidUtil.get32UUIDString());
invItemPmp.setPlucode(item.getString("PLUCODE"));
invItemPmp.setPystype(item.getInteger("PYSTYPE"));
invItemPmp.setIsbn(item.getString("ISBN"));
invItemPmp.setScancode(item.getString("SCANCODE"));
invItemPmp.setTitle(item.getString("TITLE"));
invItemPmp.setJp(item.getString("JP"));
invItemPmp.setPrice(item.getBigDecimal("PRICE"));
invItemPmp.setClscode(item.getString("CLSCODE"));
invItemPmp.setClsname(item.getString("CLSNAME"));
invItemPmp.setPublisher(item.getString("PUBLISHER"));
invItemPmp.setPubname(item.getString("PUBNAME"));
if(!StringUtil.isEmpty(item.getDate("PUBDATE"))){
invItemPmp.setPubdate(item.getDate("PUBDATE").toInstant()
.atZone( ZoneId.systemDefault() )
.toLocalDateTime());
}
invItemPmp.setDptcode(item.getString("DPTCODE"));
invItemPmp.setDptname(item.getString("DPTNAME"));
invItemPmp.setSeries(item.getString("SERIES"));
invItemPmp.setAuthor(item.getString("AUTHOR"));
invItemPmp.setReader(item.getString("READER"));
if(!StringUtil.isEmpty(item.getDate("FSTDATE"))){
invItemPmp.setFstdate(item.getDate("FSTDATE").toInstant()
.atZone( ZoneId.systemDefault() )
.toLocalDateTime());
}
invItemPmp.setFstdisc(item.getBigDecimal("FSTDISC"));
invItemPmp.setLstdisc(item.getBigDecimal("LSTDISC"));
invItemPmp.setMaxdisc(item.getBigDecimal("MAXDISC"));
invItemPmp.setMindisc(item.getBigDecimal("MINDISC"));
invItemPmp.setVendor(item.getString("VENDOR"));
invItemPmp.setTranstitle(item.getString("TRANSTITLE"));
invItemPmp.setInctax(item.getInteger("INCTAX"));
invItemPmp.setOriginprice(item.getBigDecimal("ORIGINPRICE"));
invItemPmp.setCurrency(item.getString("CURRENCY"));
invItemPmp.setStatus(1);
tempItemFomPmpList.add(invItemPmp);
// if(i % 10000 == 0){
//package orthopedics.test;
//
//import com.alibaba.fastjson.JSON;
//import com.alibaba.fastjson.JSONObject;
//import org.apache.ibatis.annotations.Update;
//import org.junit.Test;
//import org.junit.runner.RunWith;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.test.context.SpringBootTest;
//import org.springframework.data.redis.core.RedisTemplate;
//import org.springframework.jdbc.core.JdbcTemplate;
//import org.springframework.test.context.junit4.SpringRunner;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestParam;
//import orthopedics.dao.*;
//import orthopedics.model.*;
//import orthopedics.service.PropertiesServer;
//import orthopedics.service.UserServer;
//import orthopedics.util.*;
//
//import java.sql.*;
//import java.text.ParseException;
//import java.text.SimpleDateFormat;
//import java.time.LocalDateTime;
//import java.time.ZoneId;
//import java.util.*;
//import java.util.Date;
//
///**
// * 将pmp的数据同步到erp临时表
// */
//@RunWith(SpringRunner.class)
//@SpringBootTest
//public class SyncPMPTest {
//
// @Autowired
// private UserServer userServer;
//
// @Autowired
// private RedisTemplate redisTemplate;
//
// @Autowired
// private PropertiesServer propertiesServer;
//
// @Autowired
// private SysUserDepartMapper sysUserDepartMapper;
//
// @Autowired
// private InvItemMapper invItemMapper;
//
// @Autowired
// private InvItemSkuMapper invItemSkuMapper;
//
// @Autowired
// private InvItemAttributeMapper invItemAttributeMapper;
//
// @Autowired
// private InvItemPmpMapper invItemPmpMapper;
//
// public static long getTimestamp() {
// long milli = System.currentTimeMillis() + 8*3600*1000;
// return (milli*10000)+621355968000000000L;
// }
//
//
//
// public Result getPMPInvItemTest(String access_token, String sta, String end) {
// SysAccessToken sysAccessToken = userServer.checkToken(access_token);
// String gettoken = HttpUtilRSA.getToken();
// if(StringUtil.isEmpty(gettoken)){
// return new Result(false, StatusCode.ERROR,"获取PMP系统token失败");
// }
// JSONObject jsonObject = JSONObject.parseObject(gettoken);
// String token = jsonObject.getString("Token");
// String tempEncryptKey = jsonObject.getString("TempEncryKey");
//
// JSONObject data=new JSONObject();
// data.put("uniquekey","获取商品资料列表");
// data.put("timestamp", getTimestamp());
// data.put("begintime",sta);
// data.put("endTime",end);
// byte[] encrypt = Aes.encrypt(JSON.toJSONString(data), tempEncryptKey, tempEncryptKey);
// try {
// byte[] bytes = HttpUtilPMP.postBy("http://pmpapi.szcbfx.com/api/pmp/ExchangePMPData", encrypt,token);
// String s = new String(bytes);
// JSONObject object = JSONObject.parseObject(s);
// Object result = object.get("result");
// if(result==null||!result.equals("success")){
// return new Result(false,StatusCode.ERROR,"获取商品信息失败");
// }
// List<JSONObject> retMsg= (List<JSONObject>) object.get("ret_msg");
// for (JSONObject item:retMsg) {
// //检测是否是重复数据
// String plucode = item.getString("PLUCODE");
// if(StringUtil.isEmpty(plucode)){
// continue;
// }
// List<InvItem> invItems = invItemMapper.selectByPlucode(plucode);
// if(invItems!=null&&invItems.size()>0){
// continue;
// }
// InvItem invItem=new InvItem();
// InvItemAttribute invItemAttribute=new InvItemAttribute();
// InvItemSku invItemSku=new InvItemSku();
// InvItemPmp invItemPmp=new InvItemPmp();
// //商品表
// invItem.setId(UuidUtil.get32UUIDString());
// invItem.setOrgId("964daee94b604cd58e5e6bf48dd9670a");
// invItem.setStatus("SALE");
// String itemCode = propertiesServer.generateFlowingWater("ITEM_SERIAL");
// if(StringUtil.isEmpty(itemCode)){
// invItem.setItemCode(UuidUtil.get32UUIDString());
// }else{
// invItem.setItemCode(itemCode);
// }
// invItem.setItemName(item.getString("TITLE"));
// invItem.setProType("14");
// invItem.setItemDesc(item.getString("JP"));
// invItem.setPystype(item.getString("PYSTYPE"));
// invItem.setIsbn(item.getString("ISBN"));
// invItem.setPlucode(item.getString("PLUCODE"));
// invItem.setScancode(item.getString("SCANCODE"));
// invItem.setExtcode("0");
// invItem.setPurchasePrice(item.getString("PRICE"));
// invItem.setGeneralName(item.getString("CLSCODE"));
// invItem.setManufacturerId(item.getString("PUBLISHER"));
// if(!StringUtil.isEmpty(item.getDate("PUBDATE"))){
// invItem.setSpecification(item.getDate("PUBDATE").toInstant()
// .atZone( ZoneId.systemDefault() )
// .toLocalDateTime());
// }
// invItem.setPrimaryUnit("BEN");
// if(item.getString("PYSTYPE").equals("0")||item.getString("PYSTYPE").equals("4")){
// invItem.setAttribute1("Book");
// invItem.setIsBorrow("Y");
// }else{
// invItem.setAttribute1("Goods");
// invItem.setIsBorrow("N");
// }
// invItem.setAttribute2("A");
// invItem.setTax(item.getString("INCTAX"));
// invItem.setDefaultVendorId("000000006c60dba1016c60f839270004");
// invItem.setCreateBy(sysAccessToken.getUserName());
// invItem.setCreateTime(LocalDateTime.now());
// //查询当前用户部门
// SysUserDepart sysUserDepart = sysUserDepartMapper.selectByUserId(sysAccessToken.getUserId());
//
// //图书信息
// invItemAttribute.setId(UuidUtil.get32UUIDString());
// invItemAttribute.setCreateBy(sysAccessToken.getUserName());
// invItemAttribute.setCreateTime(LocalDateTime.now());
// if(sysUserDepart!=null){
// invItemAttribute.setSysOrgCode(sysUserDepart.getDepId());
// }
// invItemAttribute.setItemId(invItem.getId());
// invItemAttribute.setItemCode(invItem.getItemCode());
// invItemAttribute.setAuthor(item.getString("AUTHOR"));
// invItemAttribute.setReader(item.getString("READER"));
//
//
// //商品SKU映射
// invItemSku.setId(UuidUtil.get32UUIDString());
// if(sysUserDepart!=null){
// invItemSku.setSysOrgCode(sysUserDepart.getDepId());
// }
// invItemSku.setOrgId("964daee94b604cd58e5e6bf48dd9670a");
// invItemSku.setExternal("PMP");
// invItemSku.setItemSku(item.getString("PLUCODE"));
// invItemSku.setItemName(invItem.getItemName());
// invItemSku.setItemCode(invItem.getItemCode());
// invItemSku.setItemDesc(invItem.getItemDesc());
// invItemSku.setStatus("A");
// invItemSku.setCreateBy(sysAccessToken.getUserName());
// invItemSku.setCreateTime(LocalDateTime.now());
//
// //pmp商品缓存表
// invItemPmp.setId(UuidUtil.get32UUIDString());
// invItemPmp.setPlucode(item.getString("PLUCODE"));
// invItemPmp.setPystype(item.getInteger("PYSTYPE"));
// invItemPmp.setIsbn(item.getString("ISBN"));
// invItemPmp.setScancode(item.getString("SCANCODE"));
// invItemPmp.setTitle(item.getString("TITLE"));
// invItemPmp.setJp(item.getString("JP"));
// invItemPmp.setPrice(item.getBigDecimal("PRICE"));
// invItemPmp.setClscode(item.getString("CLSCODE"));
// invItemPmp.setClsname(item.getString("CLSNAME"));
// invItemPmp.setPublisher(item.getString("PUBLISHER"));
// invItemPmp.setPubname(item.getString("PUBNAME"));
// if(!StringUtil.isEmpty(item.getDate("PUBDATE"))){
// invItemPmp.setPubdate(item.getDate("PUBDATE").toInstant()
// .atZone( ZoneId.systemDefault() )
// .toLocalDateTime());
// }
// invItemPmp.setDptcode(item.getString("DPTCODE"));
// invItemPmp.setDptname(item.getString("DPTNAME"));
// invItemPmp.setSeries(item.getString("SERIES"));
// invItemPmp.setAuthor(item.getString("AUTHOR"));
// invItemPmp.setReader(item.getString("READER"));
// if(!StringUtil.isEmpty(item.getDate("FSTDATE"))){
// invItemPmp.setFstdate(item.getDate("FSTDATE").toInstant()
// .atZone( ZoneId.systemDefault() )
// .toLocalDateTime());
// }
// invItemPmp.setFstdisc(item.getBigDecimal("FSTDISC"));
// invItemPmp.setLstdisc(item.getBigDecimal("LSTDISC"));
// invItemPmp.setMaxdisc(item.getBigDecimal("MAXDISC"));
// invItemPmp.setMindisc(item.getBigDecimal("MINDISC"));
// invItemPmp.setVendor(item.getString("VENDOR"));
// invItemPmp.setTranstitle(item.getString("TRANSTITLE"));
// invItemPmp.setInctax(item.getInteger("INCTAX"));
// invItemPmp.setOriginprice(item.getBigDecimal("ORIGINPRICE"));
// invItemPmp.setCurrency(item.getString("CURRENCY"));
// invItemPmp.setStatus(1);
// invItemMapper.insert(invItem);
// invItemSkuMapper.insert(invItemSku);
// invItemAttributeMapper.insert(invItemAttribute);
// invItemPmpMapper.insert(invItemPmp);
// }
// return new Result(true,StatusCode.OK,"获取商品信息成功");
// } catch (Exception e) {
//
// }
// return new Result(false,StatusCode.ERROR,"获取商品信息失败");
// }
//
// //获取一年后的时间
// public String getDate1(String str) throws ParseException {
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// Date parse = sdf.parse(str);
// Calendar cal = Calendar.getInstance();
// cal.setTime(parse);
// cal.add(Calendar.DATE, 10);//增加5年
// return sdf.format(cal.getTime());
// }
//
//
// /**
// * 获取pmp商品同步到临时表
// */
// @Autowired
// private TempItemFomPmpMapper tempItemFomPmpMapper;
//
// @Test
// public void getPMPHistoryInvItem(){
// String sta = null;
// String end = null;
// String begintime= (String) redisTemplate.opsForValue().get("getPMPInvItem");
// SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" );
// if(StringUtil.isEmpty(begintime)){
// sta = "1995-1-1 00:00:00";
// }else{
// sta = begintime;
// }
//
// try {
// Date parse = sdf.parse(sta);
// long time = parse.getTime();
// while (time<=new Date().getTime()){
// end = getDate1(sta);
// String gettoken = HttpUtilRSA.getToken();
// JSONObject jsonObject = JSONObject.parseObject(gettoken);
// String token = jsonObject.getString("Token");
// String tempEncryptKey = jsonObject.getString("TempEncryKey");
//
// JSONObject data=new JSONObject();
// data.put("uniquekey","获取商品资料列表");
// data.put("timestamp", getTimestamp());
// data.put("begintime",sta);
// data.put("endTime",end);
// byte[] encrypt = Aes.encrypt(JSON.toJSONString(data), tempEncryptKey, tempEncryptKey);
// byte[] bytes = HttpUtilPMP.postBy("http://pmpapi.szcbfx.com/api/pmp/ExchangePMPData", encrypt,token);
// String s = new String(bytes);
// JSONObject object = JSONObject.parseObject(s);
// List<JSONObject> retMsg= (List<JSONObject>) object.get("ret_msg");
// System.err.println(sta+"获取到"+retMsg.size()+"条商品");
// if(retMsg.size()<=0){
// redisTemplate.opsForValue().set("getPMPInvItem",end);
// System.err.println(sta+"同步了"+retMsg.size()+"条商品");
// sta = end;
// continue;
// }
// List<TempItemFomPmp> tempItemFomPmpList=new ArrayList<>();
// for (JSONObject item:retMsg){
// TempItemFomPmp invItemPmp=new TempItemFomPmp();
// //pmp商品缓存表
// invItemPmp.setId(UuidUtil.get32UUIDString());
// invItemPmp.setPlucode(item.getString("PLUCODE"));
// invItemPmp.setPystype(item.getInteger("PYSTYPE"));
// invItemPmp.setIsbn(item.getString("ISBN"));
// invItemPmp.setScancode(item.getString("SCANCODE"));
// invItemPmp.setTitle(item.getString("TITLE"));
// invItemPmp.setJp(item.getString("JP"));
// invItemPmp.setPrice(item.getBigDecimal("PRICE"));
// invItemPmp.setClscode(item.getString("CLSCODE"));
// invItemPmp.setClsname(item.getString("CLSNAME"));
// invItemPmp.setPublisher(item.getString("PUBLISHER"));
// invItemPmp.setPubname(item.getString("PUBNAME"));
// if(!StringUtil.isEmpty(item.getDate("PUBDATE"))){
// invItemPmp.setPubdate(item.getDate("PUBDATE").toInstant()
// .atZone( ZoneId.systemDefault() )
// .toLocalDateTime());
// }
// invItemPmp.setDptcode(item.getString("DPTCODE"));
// invItemPmp.setDptname(item.getString("DPTNAME"));
// invItemPmp.setSeries(item.getString("SERIES"));
// invItemPmp.setAuthor(item.getString("AUTHOR"));
// invItemPmp.setReader(item.getString("READER"));
// if(!StringUtil.isEmpty(item.getDate("FSTDATE"))){
// invItemPmp.setFstdate(item.getDate("FSTDATE").toInstant()
// .atZone( ZoneId.systemDefault() )
// .toLocalDateTime());
// }
// invItemPmp.setFstdisc(item.getBigDecimal("FSTDISC"));
// invItemPmp.setLstdisc(item.getBigDecimal("LSTDISC"));
// invItemPmp.setMaxdisc(item.getBigDecimal("MAXDISC"));
// invItemPmp.setMindisc(item.getBigDecimal("MINDISC"));
// invItemPmp.setVendor(item.getString("VENDOR"));
// invItemPmp.setTranstitle(item.getString("TRANSTITLE"));
// invItemPmp.setInctax(item.getInteger("INCTAX"));
// invItemPmp.setOriginprice(item.getBigDecimal("ORIGINPRICE"));
// invItemPmp.setCurrency(item.getString("CURRENCY"));
// invItemPmp.setStatus(1);
// tempItemFomPmpList.add(invItemPmp);
//// if(i % 10000 == 0){
//// tempItemFomPmpMapper.insertBatch(tempItemFomPmpList);
//// System.err.println("同步了"+i+"条商品");
//// tempItemFomPmpList.clear();
//// }
// }
// tempItemFomPmpMapper.insertBatch(tempItemFomPmpList);
// System.err.println("同步了"+i+"条商品");
// tempItemFomPmpList.clear();
// }
}
tempItemFomPmpMapper.insertBatch(tempItemFomPmpList);
// getPMPInvItemTest(access_token,sta,end);
redisTemplate.opsForValue().set("getPMPInvItem",end);
System.err.println(sta+"同步了"+retMsg.size()+"条商品");
sta = end;
}
}catch (Exception e){
//logger.error("pmp同步失败时间段"+sta+"---"+end);
System.err.println(e.getMessage());
System.err.println("pmp同步失败时间段"+sta+"---"+end);
}
}
@Autowired
private TempInventoryFomPmpMapper tempInventoryFomPmpMapper;
/**
* 获取pmp仓号同步到临时表
*/
@Test
public void tempInventoryFomPmp(){
String gettoken = HttpUtilRSA.getToken();
System.err.println(gettoken);
String token = (String) JSONObject.parseObject(gettoken).get("Token");
String tempEncryptKey = (String) JSONObject.parseObject(gettoken).get("TempEncryKey");
JSONObject data=new JSONObject();
data.put("uniquekey","获取仓号列表");
data.put("timestamp", getTimestamp());
System.err.println(new Date());
//data.put("begintime","1995-12-23 00:00:00");
// data.put("begintime","2015-01-11 18:00:00");
// data.put("endTime","2020-06-12 18:00:00");
Map headers=new HashMap();
headers.put("Content-Type","application/json");
headers.put("token",token);
byte[] encrypt = Aes.encrypt(JSON.toJSONString(data), tempEncryptKey, tempEncryptKey);
byte[] bytes = new byte[0];
try {
bytes = HttpUtilPMP.postBy("http://pmpapi.szcbfx.com/api/pmp/ExchangePMPData", encrypt,token);
} catch (Exception e) {
e.printStackTrace();
}
//String post = HttpUtilPMP.post("http://pmpapi.szcbfx.com/api/pmp/ExchangePMPData", data, headers, 6000, 6000, "utf-8",tempEncryptKey);
String s = new String(bytes);
JSONObject object = JSONObject.parseObject(s);
List<JSONObject> retMsg= (List<JSONObject>) object.get("ret_msg");
System.err.println(retMsg);
System.err.println(retMsg.size());
List<TempInventoryFomPmp> tempInventoryFomPmpList=new ArrayList<>();
for(JSONObject jsonObject:retMsg){
TempInventoryFomPmp tempInventoryFomPmp=new TempInventoryFomPmp();
String code = jsonObject.getString("code");
String descript = jsonObject.getString("descript");
tempInventoryFomPmp.setId(UuidUtil.get32UUIDString());
tempInventoryFomPmp.setCode(code);
tempInventoryFomPmp.setDescript(descript);
tempInventoryFomPmpList.add(tempInventoryFomPmp);
}
tempInventoryFomPmpMapper.insertBatch(tempInventoryFomPmpList);
}
@Autowired
private TempLocatorFomPmpMapper tempLocatorFomPmpMapper;
/**
* 获取pmp货架号同步到临时表
*/
@Test
public void tempLocatorFomPmp(){
String gettoken = HttpUtilRSA.getToken();
System.err.println(gettoken);
String token = (String) JSONObject.parseObject(gettoken).get("Token");
String tempEncryptKey = (String) JSONObject.parseObject(gettoken).get("TempEncryKey");
JSONObject data=new JSONObject();
data.put("uniquekey","获取架号列表");
data.put("timestamp", getTimestamp());
System.err.println(new Date());
//data.put("begintime","1995-12-23 00:00:00");
// data.put("begintime","2015-01-11 18:00:00");
// data.put("endTime","2020-06-12 18:00:00");
Map headers=new HashMap();
headers.put("Content-Type","application/json");
headers.put("token",token);
byte[] encrypt = Aes.encrypt(JSON.toJSONString(data), tempEncryptKey, tempEncryptKey);
byte[] bytes = new byte[0];
try {
bytes = HttpUtilPMP.postBy("http://pmpapi.szcbfx.com/api/pmp/ExchangePMPData", encrypt,token);
} catch (Exception e) {
e.printStackTrace();
}
//String post = HttpUtilPMP.post("http://pmpapi.szcbfx.com/api/pmp/ExchangePMPData", data, headers, 6000, 6000, "utf-8",tempEncryptKey);
String s = new String(bytes);
JSONObject object = JSONObject.parseObject(s);
List<JSONObject> retMsg= (List<JSONObject>) object.get("ret_msg");
System.err.println(retMsg);
System.err.println(retMsg.size());
List<TempLocatorFomPmp> tempInventoryFomPmpList=new ArrayList<>();
for(JSONObject jsonObject:retMsg){
TempLocatorFomPmp tempLocatorFomPmp=new TempLocatorFomPmp();
String code = jsonObject.getString("code");
String wh = jsonObject.getString("wh");
tempLocatorFomPmp.setId(UuidUtil.get32UUIDString());
tempLocatorFomPmp.setCode(code);
tempLocatorFomPmp.setWh(wh);
tempInventoryFomPmpList.add(tempLocatorFomPmp);
}
tempLocatorFomPmpMapper.insertBatch(tempInventoryFomPmpList);
}
@Autowired
private TempAreaFomPmpMapper tempAreaFomPmpMapper;
/**
* 获取pmp区域同步到临时表
*/
@Test
public void tempAreaFomPmp(){
String gettoken = HttpUtilRSA.getToken();
System.err.println(gettoken);
String token = (String) JSONObject.parseObject(gettoken).get("Token");
String tempEncryptKey = (String) JSONObject.parseObject(gettoken).get("TempEncryKey");
JSONObject data=new JSONObject();
data.put("uniquekey","获取区域列表");
data.put("timestamp", getTimestamp());
System.err.println(new Date());
//data.put("begintime","1995-12-23 00:00:00");
// data.put("begintime","2015-01-11 18:00:00");
// data.put("endTime","2020-06-12 18:00:00");
Map headers=new HashMap();
headers.put("Content-Type","application/json");
headers.put("token",token);
byte[] encrypt = Aes.encrypt(JSON.toJSONString(data), tempEncryptKey, tempEncryptKey);
byte[] bytes = new byte[0];
try {
bytes = HttpUtilPMP.postBy("http://pmpapi.szcbfx.com/api/pmp/ExchangePMPData", encrypt,token);
} catch (Exception e) {
e.printStackTrace();
}
//String post = HttpUtilPMP.post("http://pmpapi.szcbfx.com/api/pmp/ExchangePMPData", data, headers, 6000, 6000, "utf-8",tempEncryptKey);
String s = new String(bytes);
JSONObject object = JSONObject.parseObject(s);
List<JSONObject> retMsg= (List<JSONObject>) object.get("ret_msg");
System.err.println(retMsg);
System.err.println(retMsg.size());
List<TempAreaFomPmp> tempInventoryFomPmpList=new ArrayList<>();
for(JSONObject jsonObject:retMsg){
TempAreaFomPmp tempAreaFomPmp=new TempAreaFomPmp();
String subwh = jsonObject.getString("subwh");
String wh = jsonObject.getString("wh");
String descript = jsonObject.getString("descript");
tempAreaFomPmp.setId(UuidUtil.get32UUIDString());
tempAreaFomPmp.setSubwh(subwh);
tempAreaFomPmp.setWh(wh);
tempAreaFomPmp.setDescript(descript);
tempInventoryFomPmpList.add(tempAreaFomPmp);
}
tempAreaFomPmpMapper.insertBatch(tempInventoryFomPmpList);
}
/**
* 将ERP创建的商品同步到POS
*/
@Test
public void invItemsToPos(){
List<InvItem> invItems = invItemMapper.findByAttribute2();
if(invItems!=null && invItems.size()>0){
Connection ct=null;
PreparedStatement ps=null;
ResultSet rs=null;
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
ct= DriverManager.getConnection("jdbc:sqlserver://130.1.0.32:1433;DatabaseName=shoptxns","wjkj","wjkj123456");
for (InvItem invItem:invItems) {
ps=ct.prepareStatement("insert into plu values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
ps.setString(1,invItem.getItemCode());
ps.setString(2,invItem.getItemName());
//ps.setString(3,invItem.getAttribute1());
ps.setString(3,"");
ps.setString(4,"");
ps.setString(5,"");
ps.setString(6,"");
ps.setInt(7,(int)(Float.parseFloat("12.56")*100));
ps.setInt(8,0);
ps.setInt(9,(int)(Float.parseFloat("12.56")*100));
ps.setInt(10,(int)(Float.parseFloat("12.56")*100));
ps.setInt(11,(int)(Float.parseFloat("12.56")*100));
ps.setString(12,"-");
java.sql.Date date = new java.sql.Date(new java.util.Date().getTime()); //构建一个
ps.setDate(13,date);
ps.setInt(14,0);
ps.setString(15,"由erp同步");
ps.setInt(16,Integer.parseInt(invItem.getTax()));
int i = ps.executeUpdate();
if(i==1){
System.err.println("将ERP创建的商品同步到POS成功");
}else{
System.err.println("将ERP创建的商品同步到POS失败");
}
}
} catch (Exception e) {
System.err.println(e.getMessage());
}finally {
try {
if(rs!=null){
rs.close();
}
if(ps!=null){
ps.close();
}
if(ct!=null){
ct.close();
}
} catch (SQLException e) {
System.err.println("将ERP创建的商品同步到POS流关闭异常");
}
}
}
}
@Autowired
private TempItemSkuFomPmpMapper tempItemSkuFomPmpMapper;
/**
* 获取pmp商品库存信息同步到临时表
*/
@Test
public void tempItemSkuFomPmp(){
List<InvItem> select = invItemMapper.select();
String gettoken = HttpUtilRSA.getToken();
String token = (String) JSONObject.parseObject(gettoken).get("Token");
String tempEncryptKey = (String) JSONObject.parseObject(gettoken).get("TempEncryKey");
JSONObject data=new JSONObject();
List<JSONObject> plulist=new ArrayList<>();
for (InvItem invItem:select) {
if(StringUtil.isEmpty(invItem.getPlucode())){
continue;
}
JSONObject jsonObject=new JSONObject();
jsonObject.put("plucode",invItem.getPlucode());
plulist.add(jsonObject);
}
data.put("uniquekey","可配库存查询");
data.put("timestamp", getTimestamp());
data.put("shop", "2");
data.put("plulist",plulist);
Map headers=new HashMap();
headers.put("Content-Type","application/json");
headers.put("token",token);
byte[] encrypt = Aes.encrypt(JSON.toJSONString(data), tempEncryptKey, tempEncryptKey);
byte[] bytes = new byte[0];
try {
bytes = HttpUtilPMP.postBy("http://pmpapi.szcbfx.com/api/pmp/ExchangePMPData", encrypt,token);
} catch (Exception e) {
e.printStackTrace();
}
//String post = HttpUtilPMP.post("http://pmpapi.szcbfx.com/api/pmp/ExchangePMPData", data, headers, 6000, 6000, "utf-8",tempEncryptKey);
String s = new String(bytes);
JSONObject object = JSONObject.parseObject(s);
List<JSONObject> retMsg= (List<JSONObject>) object.get("ret_msg");
System.err.println(retMsg);
System.err.println(retMsg.size());
List<TempItemSkuFomPmp> tempItemSkuFomPmps=new ArrayList<>();
for (JSONObject jsonObject:retMsg) {
TempItemSkuFomPmp tempItemSkuFomPmp=new TempItemSkuFomPmp();
tempItemSkuFomPmp.setId(UuidUtil.get32UUIDString());
tempItemSkuFomPmp.setRack(jsonObject.getString("rack"));
tempItemSkuFomPmp.setPlucode(jsonObject.getString("plucode"));
tempItemSkuFomPmp.setTitle(jsonObject.getString("title"));
tempItemSkuFomPmp.setPrice(jsonObject.getBigDecimal("price"));
tempItemSkuFomPmp.setQty(jsonObject.getInteger("qty"));
tempItemSkuFomPmps.add(tempItemSkuFomPmp);
}
tempItemSkuFomPmpMapper.insertBatch(tempItemSkuFomPmps);
}
}
//// getPMPInvItemTest(access_token,sta,end);
//
// redisTemplate.opsForValue().set("getPMPInvItem",end);
// System.err.println(sta+"同步了"+retMsg.size()+"条商品");
// sta = end;
//
// }
// }catch (Exception e){
// //logger.error("pmp同步失败时间段"+sta+"---"+end);
// System.err.println(e.getMessage());
// System.err.println("pmp同步失败时间段"+sta+"---"+end);
// }
//
// }
//
//
//
// @Autowired
// private TempInventoryFomPmpMapper tempInventoryFomPmpMapper;
//
// /**
// * 获取pmp仓号同步到临时表
// */
// @Test
// public void tempInventoryFomPmp(){
// String gettoken = HttpUtilRSA.getToken();
// System.err.println(gettoken);
// String token = (String) JSONObject.parseObject(gettoken).get("Token");
// String tempEncryptKey = (String) JSONObject.parseObject(gettoken).get("TempEncryKey");
// JSONObject data=new JSONObject();
// data.put("uniquekey","获取仓号列表");
// data.put("timestamp", getTimestamp());
// System.err.println(new Date());
// //data.put("begintime","1995-12-23 00:00:00");
//// data.put("begintime","2015-01-11 18:00:00");
//// data.put("endTime","2020-06-12 18:00:00");
// Map headers=new HashMap();
// headers.put("Content-Type","application/json");
// headers.put("token",token);
// byte[] encrypt = Aes.encrypt(JSON.toJSONString(data), tempEncryptKey, tempEncryptKey);
// byte[] bytes = new byte[0];
// try {
// bytes = HttpUtilPMP.postBy("http://pmpapi.szcbfx.com/api/pmp/ExchangePMPData", encrypt,token);
// } catch (Exception e) {
// e.printStackTrace();
// }
// //String post = HttpUtilPMP.post("http://pmpapi.szcbfx.com/api/pmp/ExchangePMPData", data, headers, 6000, 6000, "utf-8",tempEncryptKey);
// String s = new String(bytes);
// JSONObject object = JSONObject.parseObject(s);
// List<JSONObject> retMsg= (List<JSONObject>) object.get("ret_msg");
//
// System.err.println(retMsg);
// System.err.println(retMsg.size());
// List<TempInventoryFomPmp> tempInventoryFomPmpList=new ArrayList<>();
// for(JSONObject jsonObject:retMsg){
// TempInventoryFomPmp tempInventoryFomPmp=new TempInventoryFomPmp();
// String code = jsonObject.getString("code");
// String descript = jsonObject.getString("descript");
// tempInventoryFomPmp.setId(UuidUtil.get32UUIDString());
// tempInventoryFomPmp.setCode(code);
// tempInventoryFomPmp.setDescript(descript);
// tempInventoryFomPmpList.add(tempInventoryFomPmp);
// }
//
// tempInventoryFomPmpMapper.insertBatch(tempInventoryFomPmpList);
// }
//
//
// @Autowired
// private TempLocatorFomPmpMapper tempLocatorFomPmpMapper;
// /**
// * 获取pmp货架号同步到临时表
// */
// @Test
// public void tempLocatorFomPmp(){
// String gettoken = HttpUtilRSA.getToken();
// System.err.println(gettoken);
// String token = (String) JSONObject.parseObject(gettoken).get("Token");
// String tempEncryptKey = (String) JSONObject.parseObject(gettoken).get("TempEncryKey");
// JSONObject data=new JSONObject();
// data.put("uniquekey","获取架号列表");
// data.put("timestamp", getTimestamp());
// System.err.println(new Date());
// //data.put("begintime","1995-12-23 00:00:00");
//// data.put("begintime","2015-01-11 18:00:00");
//// data.put("endTime","2020-06-12 18:00:00");
// Map headers=new HashMap();
// headers.put("Content-Type","application/json");
// headers.put("token",token);
// byte[] encrypt = Aes.encrypt(JSON.toJSONString(data), tempEncryptKey, tempEncryptKey);
// byte[] bytes = new byte[0];
// try {
// bytes = HttpUtilPMP.postBy("http://pmpapi.szcbfx.com/api/pmp/ExchangePMPData", encrypt,token);
// } catch (Exception e) {
// e.printStackTrace();
// }
// //String post = HttpUtilPMP.post("http://pmpapi.szcbfx.com/api/pmp/ExchangePMPData", data, headers, 6000, 6000, "utf-8",tempEncryptKey);
// String s = new String(bytes);
// JSONObject object = JSONObject.parseObject(s);
// List<JSONObject> retMsg= (List<JSONObject>) object.get("ret_msg");
//
// System.err.println(retMsg);
// System.err.println(retMsg.size());
// List<TempLocatorFomPmp> tempInventoryFomPmpList=new ArrayList<>();
// for(JSONObject jsonObject:retMsg){
// TempLocatorFomPmp tempLocatorFomPmp=new TempLocatorFomPmp();
// String code = jsonObject.getString("code");
// String wh = jsonObject.getString("wh");
// tempLocatorFomPmp.setId(UuidUtil.get32UUIDString());
// tempLocatorFomPmp.setCode(code);
// tempLocatorFomPmp.setWh(wh);
// tempInventoryFomPmpList.add(tempLocatorFomPmp);
// }
//
// tempLocatorFomPmpMapper.insertBatch(tempInventoryFomPmpList);
// }
//
// @Autowired
// private TempAreaFomPmpMapper tempAreaFomPmpMapper;
// /**
// * 获取pmp区域同步到临时表
// */
// @Test
// public void tempAreaFomPmp(){
// String gettoken = HttpUtilRSA.getToken();
// System.err.println(gettoken);
// String token = (String) JSONObject.parseObject(gettoken).get("Token");
// String tempEncryptKey = (String) JSONObject.parseObject(gettoken).get("TempEncryKey");
// JSONObject data=new JSONObject();
// data.put("uniquekey","获取区域列表");
// data.put("timestamp", getTimestamp());
// System.err.println(new Date());
// //data.put("begintime","1995-12-23 00:00:00");
//// data.put("begintime","2015-01-11 18:00:00");
//// data.put("endTime","2020-06-12 18:00:00");
// Map headers=new HashMap();
// headers.put("Content-Type","application/json");
// headers.put("token",token);
// byte[] encrypt = Aes.encrypt(JSON.toJSONString(data), tempEncryptKey, tempEncryptKey);
// byte[] bytes = new byte[0];
// try {
// bytes = HttpUtilPMP.postBy("http://pmpapi.szcbfx.com/api/pmp/ExchangePMPData", encrypt,token);
// } catch (Exception e) {
// e.printStackTrace();
// }
// //String post = HttpUtilPMP.post("http://pmpapi.szcbfx.com/api/pmp/ExchangePMPData", data, headers, 6000, 6000, "utf-8",tempEncryptKey);
// String s = new String(bytes);
// JSONObject object = JSONObject.parseObject(s);
// List<JSONObject> retMsg= (List<JSONObject>) object.get("ret_msg");
//
// System.err.println(retMsg);
// System.err.println(retMsg.size());
// List<TempAreaFomPmp> tempInventoryFomPmpList=new ArrayList<>();
// for(JSONObject jsonObject:retMsg){
// TempAreaFomPmp tempAreaFomPmp=new TempAreaFomPmp();
// String subwh = jsonObject.getString("subwh");
// String wh = jsonObject.getString("wh");
// String descript = jsonObject.getString("descript");
// tempAreaFomPmp.setId(UuidUtil.get32UUIDString());
// tempAreaFomPmp.setSubwh(subwh);
// tempAreaFomPmp.setWh(wh);
// tempAreaFomPmp.setDescript(descript);
// tempInventoryFomPmpList.add(tempAreaFomPmp);
// }
//
// tempAreaFomPmpMapper.insertBatch(tempInventoryFomPmpList);
// }
//
// /**
// * 将ERP创建的商品同步到POS
// */
// @Test
// public void invItemsToPos(){
// List<InvItem> invItems = invItemMapper.findByAttribute2();
// if(invItems!=null && invItems.size()>0){
// Connection ct=null;
// PreparedStatement ps=null;
// ResultSet rs=null;
// try {
// Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
// ct= DriverManager.getConnection("jdbc:sqlserver://130.1.0.32:1433;DatabaseName=shoptxns","wjkj","wjkj123456");
// for (InvItem invItem:invItems) {
// ps=ct.prepareStatement("insert into plu values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
// ps.setString(1,invItem.getItemCode());
// ps.setString(2,invItem.getItemName());
// //ps.setString(3,invItem.getAttribute1());
// ps.setString(3,"");
// ps.setString(4,"");
// ps.setString(5,"");
// ps.setString(6,"");
// ps.setInt(7,(int)(Float.parseFloat("12.56")*100));
// ps.setInt(8,0);
// ps.setInt(9,(int)(Float.parseFloat("12.56")*100));
// ps.setInt(10,(int)(Float.parseFloat("12.56")*100));
// ps.setInt(11,(int)(Float.parseFloat("12.56")*100));
// ps.setString(12,"-");
// java.sql.Date date = new java.sql.Date(new java.util.Date().getTime()); //构建一个
// ps.setDate(13,date);
// ps.setInt(14,0);
// ps.setString(15,"由erp同步");
// ps.setInt(16,Integer.parseInt(invItem.getTax()));
// int i = ps.executeUpdate();
// if(i==1){
// System.err.println("将ERP创建的商品同步到POS成功");
// }else{
// System.err.println("将ERP创建的商品同步到POS失败");
// }
// }
// } catch (Exception e) {
// System.err.println(e.getMessage());
// }finally {
// try {
// if(rs!=null){
// rs.close();
// }
// if(ps!=null){
// ps.close();
// }
// if(ct!=null){
// ct.close();
// }
// } catch (SQLException e) {
// System.err.println("将ERP创建的商品同步到POS流关闭异常");
// }
// }
// }
// }
//
//
// @Autowired
// private TempItemSkuFomPmpMapper tempItemSkuFomPmpMapper;
//
//
// /**
// * 获取pmp商品库存信息同步到临时表
// */
// @Test
// public void tempItemSkuFomPmp(){
// int i=0;
// while (true){
// List<String> plucodes = tempItemFomPmpMapper.findLimitByStaEnd(i,100000);
// if(plucodes==null || plucodes.size()<=0){
// return;
// }
// System.err.println("查询到"+plucodes.size()+"条数据");
// String gettoken = HttpUtilRSA.getToken();
// String token = (String) JSONObject.parseObject(gettoken).get("Token");
// String tempEncryptKey = (String) JSONObject.parseObject(gettoken).get("TempEncryKey");
// JSONObject data=new JSONObject();
// List<JSONObject> plulist=new ArrayList<>();
// for (String plucode:plucodes) {
// if(StringUtil.isEmpty(plucode)){
// continue;
// }
// JSONObject jsonObject=new JSONObject();
// jsonObject.put("plucode",plucode);
// plulist.add(jsonObject);
//
// }
// data.put("uniquekey","可配库存查询");
// data.put("timestamp", getTimestamp());
// data.put("shop", "2");
// data.put("plulist",plulist);
// Map headers=new HashMap();
// headers.put("Content-Type","application/json");
// headers.put("token",token);
// byte[] encrypt = Aes.encrypt(JSON.toJSONString(data), tempEncryptKey, tempEncryptKey);
// byte[] bytes = new byte[0];
// try {
// bytes = HttpUtilPMP.postBy("http://pmpapi.szcbfx.com/api/pmp/ExchangePMPData", encrypt,token);
// } catch (Exception e) {
// e.printStackTrace();
// }
// //String post = HttpUtilPMP.post("http://pmpapi.szcbfx.com/api/pmp/ExchangePMPData", data, headers, 6000, 6000, "utf-8",tempEncryptKey);
// String s = new String(bytes);
// JSONObject object = JSONObject.parseObject(s);
// List<JSONObject> retMsg= (List<JSONObject>) object.get("ret_msg");
//
// System.err.println(retMsg.size());
// List<TempItemSkuFomPmp> tempItemSkuFomPmps=new ArrayList<>();
// for (JSONObject jsonObject:retMsg) {
// TempItemSkuFomPmp tempItemSkuFomPmp=new TempItemSkuFomPmp();
// tempItemSkuFomPmp.setId(UuidUtil.get32UUIDString());
// tempItemSkuFomPmp.setRack(jsonObject.getString("rack"));
// tempItemSkuFomPmp.setPlucode(jsonObject.getString("plucode"));
// tempItemSkuFomPmp.setTitle(jsonObject.getString("title"));
// tempItemSkuFomPmp.setPrice(jsonObject.getBigDecimal("price"));
// tempItemSkuFomPmp.setQty(jsonObject.getInteger("qty"));
// tempItemSkuFomPmps.add(tempItemSkuFomPmp);
// }
// tempItemSkuFomPmpMapper.insertBatch(tempItemSkuFomPmps);
// i=i+99999;
// System.err.println("前"+i+"条数据同步完成");
// }
//
// }
//
//}
package orthopedics.test;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.test.context.junit4.SpringRunner;
import orthopedics.controller.v1.TransactionController;
import orthopedics.dao.*;
import orthopedics.model.*;
import orthopedics.service.PropertiesServer;
import orthopedics.service.UserServer;
import orthopedics.util.*;
import java.sql.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;
import java.util.*;
/**
* 将临时表数据同步到正式表
*/
@RunWith(SpringRunner.class)
@SpringBootTest
public class TempToOfficial {
@Autowired
private TempInventoryFomPmpMapper tempInventoryFomPmpMapper;
@Autowired
private InvInventoryMapper invInventoryMapper;
/**
* temp_inventory_fom_pmp临时表创建库存信息inv_inventory
*/
@Test
public void addInventory(){
List<TempInventoryFomPmp> select = tempInventoryFomPmpMapper.select();
List<InvInventory> invInventories=new ArrayList<>();
int i=0;
for (TempInventoryFomPmp tempInventoryFomPmp:select) {
InvInventory byInvCode = invInventoryMapper.findByInvCode("WH" + tempInventoryFomPmp.getCode());
if(byInvCode!=null){
continue;
}
InvInventory invInventory=new InvInventory();
invInventory.setId(UuidUtil.get32UUIDString());
invInventory.setOrg_id("2c9007626dde3f4f016deda2151f1a42");
invInventory.setInv_code("WH"+tempInventoryFomPmp.getCode());
invInventory.setInv_name(tempInventoryFomPmp.getDescript());
invInventory.setInv_desc("-1");
invInventory.setSortid(tempInventoryFomPmp.getCode());
invInventory.setStatus("A");
invInventory.setCreate_by("0f98872af64711e9a1b10242ac110002");
invInventory.setCreate_time(LocalDateTime.now());
invInventories.add(invInventory);
i++;
invInventoryMapper.insert(invInventory);
}
//invInventoryMapper.insertBatch(invInventories);
System.err.println(i);
}
@Autowired
private TempAreaFomPmpMapper tempAreaFomPmpMapper;
@Autowired
private InvSubinventoryMapper invSubinventoryMapper;
/**
* temp_area_fom_pmp临时表创建库区信息inv_subinventory
*/
@Test
public void addSubinventory(){
List<TempAreaFomPmp> select = tempAreaFomPmpMapper.select();
int i=0;
System.err.println("查询到"+select.size()+"条数据");
for (TempAreaFomPmp tempAreaFomPmp:select) {
InvSubinventory bySubinvCode = invSubinventoryMapper.findBySubinvCode("KQ" + tempAreaFomPmp.getSubwh());
if(bySubinvCode!=null){
continue;
}
InvSubinventory invSubinventory=new InvSubinventory();
invSubinventory.setId(UuidUtil.get32UUIDString());
invSubinventory.setCreateDate(LocalDateTime.now());
invSubinventory.setCreateBy("0f98872af64711e9a1b10242ac110002");
InvInventory bySortid = invInventoryMapper.findBySortid(tempAreaFomPmp.getWh());
if(bySortid==null){
continue;
}
invSubinventory.setInvId(bySortid.getId());
invSubinventory.setSubinvType("STORAGE");
invSubinventory.setSubinvCode("KQ"+tempAreaFomPmp.getSubwh());
invSubinventory.setSubinvName("存储区");
invSubinventory.setSubinvDesc("-1");
invSubinventory.setLocatorControl("Y");
invSubinventory.setStatus("A");
i++;
invSubinventoryMapper.insert(invSubinventory);
}
System.err.println("处理了"+i+"条数据");
}
@Autowired
private TempLocatorFomPmpMapper tempLocatorFomPmpMapper;
@Autowired
private InvLocatorMapper invLocatorMapper;
/**
* temp_locator_fom_pmp临时表创建h货架信息inv_locator
*/
@Test
public void addLocator(){
List<TempLocatorFomPmp> select = tempLocatorFomPmpMapper.select();
int i=0;
System.err.println("查询到"+select.size()+"条数据");
// List<InvLocator> invLocators=new ArrayList<>();
for (TempLocatorFomPmp tempLocatorFomPmp:select) {
List<InvLocator> invLocatorList = invLocatorMapper.selectLocatorByCode("HJ" + tempLocatorFomPmp.getCode());
if(invLocatorList!=null && invLocatorList.size()>0){
continue;
}
InvLocator invLocator=new InvLocator();
invLocator.setId(UuidUtil.get32UUIDString());
invLocator.setCreateBy("0f98872af64711e9a1b10242ac110002");
invLocator.setCreateTime(LocalDateTime.now());
InvInventory bySortid = invInventoryMapper.findBySortid(tempLocatorFomPmp.getWh());
if(bySortid==null){
continue;
}
invLocator.setInvId(bySortid.getId());
List<InvSubinventory> invSubinventories = invSubinventoryMapper.selectByInvIdAndSubinvName(bySortid.getId());
if(invSubinventories==null || invSubinventories.size()<=0){
continue;
}
invLocator.setSubinvId(invSubinventories.get(0).getId());
invLocator.setLocatorCode("HJ"+tempLocatorFomPmp.getCode());
invLocator.setLocatorName(tempLocatorFomPmp.getCode());
invLocator.setLocatorDesc("-1");
invLocator.setStatus("A");
// invLocators.add(invLocator);
invLocatorMapper.insert(invLocator);
i++;
System.err.println("第"+i+"条处理完毕");
}
// invLocatorMapper.insertBatch(invLocators);
System.err.println("处理了"+i+"条数据");
}
@Autowired
private TempItemFomPmpMapper tempItemFomPmpMapper;
@Autowired
private InvItemMapper invItemMapper;
@Autowired
private PropertiesServer propertiesServer;
@Autowired
private SysUserDepartMapper sysUserDepartMapper;
@Autowired
private InvItemSkuMapper invItemSkuMapper;
@Autowired
private InvItemAttributeMapper invItemAttributeMapper;
/**
* 将商品信息从临时表temp_item_fom_pmp同步到正式表inv_item 2683351
*/
@Test
public void addInvItem(){
boolean i=true;
int j=0;
while (i){
List<TempItemFomPmp> limit = tempItemFomPmpMapper.findLimit(j);
System.err.println("查询到"+limit.size()+"条数据");
if(limit.size()<=0){
System.err.println("所有数据同步完成!!!");
return;
}
List<InvItem> invItems=new ArrayList<>();
List<InvItemAttribute> invItemAttributes=new ArrayList<>();
List<InvItemSku> invItemSkus=new ArrayList<>();
for (TempItemFomPmp tempItemFomPmp:limit) {
InvItem plucode = invItemMapper.findByPlucode(tempItemFomPmp.getPlucode());
if(plucode!=null){
continue;
}
InvItem invItem=new InvItem();
InvItemAttribute invItemAttribute=new InvItemAttribute();
InvItemSku invItemSku=new InvItemSku();
//商品表
invItem.setId(UuidUtil.get32UUIDString());
invItem.setOrgId("964daee94b604cd58e5e6bf48dd9670a");
invItem.setStatus("SALE");
invItem.setProType("14");
String newItemCode = invItemMapper.selectTheNewItemCode("14");
String itemCode;
if(newItemCode == null || "".equals(newItemCode)){
itemCode = invItem.getProType() ;
for(int u=0;u<(13-invItem.getProType().length()-1);u++){
itemCode = itemCode + "0";
}
itemCode = itemCode + "1";
}else {
//商品代码加1
itemCode = String.valueOf(Long.parseLong(newItemCode)+1);
}
invItem.setItemCode(itemCode);
invItem.setItemName(tempItemFomPmp.getTitle());
invItem.setItemDesc(tempItemFomPmp.getJp());
invItem.setPystype(tempItemFomPmp.getPystype()+"");
invItem.setIsbn(tempItemFomPmp.getIsbn());
invItem.setPlucode(tempItemFomPmp.getPlucode());
invItem.setScancode(tempItemFomPmp.getScancode());
invItem.setExtcode("0");
invItem.setPurchasePrice(tempItemFomPmp.getPrice()+"");
invItem.setGeneralName(tempItemFomPmp.getClscode());
invItem.setManufacturerId(tempItemFomPmp.getPublisher());
invItem.setSpecification(tempItemFomPmp.getPubdate());
invItem.setPrimaryUnit("BEN");
if(tempItemFomPmp.getPystype()==0||tempItemFomPmp.getPystype()==4){
invItem.setAttribute1("Book");
invItem.setIsBorrow("Y");
}else{
invItem.setAttribute1("Goods");
invItem.setIsBorrow("N");
}
invItem.setAttribute2("A");
invItem.setTax(tempItemFomPmp.getInctax()+"");
invItem.setDefaultVendorId("000000006c60dba1016c60f839270004");
invItem.setCreateBy("PMP同步");
invItem.setCreateTime(LocalDateTime.now());
//查询当前用户部门
SysUserDepart sysUserDepart = sysUserDepartMapper.selectByUserId("b7b819e3a7fb25699ff5e10332f089f7");
//图书信息
invItemAttribute.setId(UuidUtil.get32UUIDString());
invItemAttribute.setCreateBy("PMP同步");
invItemAttribute.setCreateTime(LocalDateTime.now());
if(sysUserDepart!=null){
invItemAttribute.setSysOrgCode(sysUserDepart.getDepId());
}
invItemAttribute.setItemId(invItem.getId());
invItemAttribute.setItemCode(invItem.getItemCode());
invItemAttribute.setAuthor(tempItemFomPmp.getAuthor());
invItemAttribute.setReader(tempItemFomPmp.getReader());
//商品SKU映射
invItemSku.setId(UuidUtil.get32UUIDString());
if(sysUserDepart!=null){
invItemSku.setSysOrgCode(sysUserDepart.getDepId());
}
invItemSku.setOrgId("964daee94b604cd58e5e6bf48dd9670a");
invItemSku.setExternal("PMP");
invItemSku.setItemSku(tempItemFomPmp.getPlucode());
invItemSku.setItemName(invItem.getItemName());
invItemSku.setItemCode(invItem.getItemCode());
invItemSku.setItemDesc(invItem.getItemDesc());
invItemSku.setStatus("A");
invItemSku.setCreateBy("PMP同步");
invItemSku.setCreateTime(LocalDateTime.now());
}
System.err.println("数据封装完成");
invItemMapper.insertBatch(invItems);
invItemSkuMapper.insertBatch(invItemSkus);
invItemAttributeMapper.insertBatch(invItemAttributes);
System.err.println("前"+j+"条同步完成");
j=j+10000;
}
}
@Autowired
private TempItemSkuFomPmpMapper tempItemSkuFomPmpMapper;
@Autowired
private TransactionController transactionController;
/**
* 将商品库存信息从临时表temp_item_sku_fom_pmp同步到正式库存
*/
@Test
public void addInvItemSku(){
List<TempItemSkuFomPmp> select = tempItemSkuFomPmpMapper.select();
int i=0;
for (TempItemSkuFomPmp tempItemSkuFomPmp:select) {
JSONObject jsonObject=new JSONObject();
JSONObject data=new JSONObject();
data.put("inv_code","WH2");
data.put("subinv_code","KQ2");
data.put("locator_code","HJ"+tempItemSkuFomPmp.getRack());
InvItem byPlucode = invItemMapper.findByPlucode(tempItemSkuFomPmp.getPlucode());
data.put("item_code",byPlucode.getItemCode());
data.put("tx_type_code","PMP_SYN");
data.put("tx_date",new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
data.put("tx_quantity",tempItemSkuFomPmp.getQty());
data.put("tx_price",tempItemSkuFomPmp.getPrice());
jsonObject.put("data",data);
String s = transactionController.invItemInOut("201910271129039497a78b526d9a246eca0abb1025986f25cG7BHIxhVaDO6MYm", jsonObject);
i++;
System.err.println(i);
}
}
}
//package orthopedics.test;
//
//import com.alibaba.fastjson.JSON;
//import com.alibaba.fastjson.JSONObject;
//import org.junit.Test;
//import org.junit.runner.RunWith;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.test.context.SpringBootTest;
//import org.springframework.data.redis.core.RedisTemplate;
//import org.springframework.test.context.junit4.SpringRunner;
//import org.springframework.transaction.annotation.Transactional;
//import orthopedics.controller.v1.TransactionController;
//import orthopedics.dao.*;
//import orthopedics.model.*;
//import orthopedics.service.PropertiesServer;
//import orthopedics.service.UserServer;
//import orthopedics.util.*;
//
//import java.sql.*;
//import java.text.ParseException;
//import java.text.SimpleDateFormat;
//import java.time.LocalDateTime;
//import java.time.ZoneId;
//import java.util.Date;
//import java.util.*;
//
///**
// * 将临时表数据同步到正式表
// */
//@RunWith(SpringRunner.class)
//@SpringBootTest
//public class TempToOfficial {
//
// @Autowired
// private TempInventoryFomPmpMapper tempInventoryFomPmpMapper;
//
// @Autowired
// private InvInventoryMapper invInventoryMapper;
//
// /**
// * temp_inventory_fom_pmp临时表创建库存信息inv_inventory
// */
// @Test
// public void addInventory(){
// List<TempInventoryFomPmp> select = tempInventoryFomPmpMapper.select();
// List<InvInventory> invInventories=new ArrayList<>();
// int i=0;
// for (TempInventoryFomPmp tempInventoryFomPmp:select) {
// InvInventory byInvCode = invInventoryMapper.findByInvCode("WH" + tempInventoryFomPmp.getCode());
// if(byInvCode!=null){
// continue;
// }
// InvInventory invInventory=new InvInventory();
// invInventory.setId(UuidUtil.get32UUIDString());
// invInventory.setOrg_id("2c9007626dde3f4f016deda2151f1a42");
// invInventory.setInv_code("WH"+tempInventoryFomPmp.getCode());
// invInventory.setInv_name(tempInventoryFomPmp.getDescript());
// invInventory.setInv_desc("-1");
// invInventory.setSortid(tempInventoryFomPmp.getCode());
// invInventory.setStatus("A");
// invInventory.setCreate_by("0f98872af64711e9a1b10242ac110002");
// invInventory.setCreate_time(LocalDateTime.now());
// invInventories.add(invInventory);
// i++;
// invInventoryMapper.insert(invInventory);
// }
// //invInventoryMapper.insertBatch(invInventories);
// System.err.println(i);
// }
//
// @Autowired
// private TempAreaFomPmpMapper tempAreaFomPmpMapper;
//
// @Autowired
// private InvSubinventoryMapper invSubinventoryMapper;
//
// /**
// * temp_area_fom_pmp临时表创建库区信息inv_subinventory
// */
// @Test
// public void addSubinventory(){
// List<TempAreaFomPmp> select = tempAreaFomPmpMapper.select();
// int i=0;
// System.err.println("查询到"+select.size()+"条数据");
// for (TempAreaFomPmp tempAreaFomPmp:select) {
// InvSubinventory bySubinvCode = invSubinventoryMapper.findBySubinvCode("KQ" + tempAreaFomPmp.getSubwh());
// if(bySubinvCode!=null){
// continue;
// }
// InvSubinventory invSubinventory=new InvSubinventory();
// invSubinventory.setId(UuidUtil.get32UUIDString());
// invSubinventory.setCreateDate(LocalDateTime.now());
// invSubinventory.setCreateBy("0f98872af64711e9a1b10242ac110002");
// InvInventory bySortid = invInventoryMapper.findBySortid(tempAreaFomPmp.getWh());
// if(bySortid==null){
// continue;
// }
// invSubinventory.setInvId(bySortid.getId());
// invSubinventory.setSubinvType("STORAGE");
// invSubinventory.setSubinvCode("KQ"+tempAreaFomPmp.getSubwh());
// invSubinventory.setSubinvName("存储区");
// invSubinventory.setSubinvDesc("-1");
// invSubinventory.setLocatorControl("Y");
// invSubinventory.setStatus("A");
// i++;
// invSubinventoryMapper.insert(invSubinventory);
// }
// System.err.println("处理了"+i+"条数据");
// }
//
//
// @Autowired
// private TempLocatorFomPmpMapper tempLocatorFomPmpMapper;
//
// @Autowired
// private InvLocatorMapper invLocatorMapper;
// /**
// * temp_locator_fom_pmp临时表创建h货架信息inv_locator
// */
// @Test
// public void addLocator(){
// List<TempLocatorFomPmp> select = tempLocatorFomPmpMapper.select();
// int i=0;
// System.err.println("查询到"+select.size()+"条数据");
//// List<InvLocator> invLocators=new ArrayList<>();
// for (TempLocatorFomPmp tempLocatorFomPmp:select) {
// InvLocator invLocatorList = invLocatorMapper.findLocatorByCode("HJ" + tempLocatorFomPmp.getCode());
// if(invLocatorList!=null){
// continue;
// }
// InvLocator invLocator=new InvLocator();
// invLocator.setId(UuidUtil.get32UUIDString());
// invLocator.setCreateBy("0f98872af64711e9a1b10242ac110002");
// invLocator.setCreateTime(LocalDateTime.now());
// InvInventory bySortid = invInventoryMapper.findBySortid(tempLocatorFomPmp.getWh());
// if(bySortid==null){
// continue;
// }
// invLocator.setInvId(bySortid.getId());
// List<InvSubinventory> invSubinventories = invSubinventoryMapper.selectByInvIdAndSubinvName(bySortid.getId());
// if(invSubinventories==null || invSubinventories.size()<=0){
// continue;
// }
// invLocator.setSubinvId(invSubinventories.get(0).getId());
// invLocator.setLocatorCode("HJ"+tempLocatorFomPmp.getCode());
// invLocator.setLocatorName(tempLocatorFomPmp.getCode());
// invLocator.setLocatorDesc("-1");
// invLocator.setStatus("A");
//
//// invLocators.add(invLocator);
// invLocatorMapper.insert(invLocator);
// i++;
// System.err.println("第"+i+"条处理完毕");
// }
//// invLocatorMapper.insertBatch(invLocators);
// System.err.println("处理了"+i+"条数据");
// }
//
// @Autowired
// private TempItemFomPmpMapper tempItemFomPmpMapper;
//
// @Autowired
// private InvItemMapper invItemMapper;
//
// @Autowired
// private PropertiesServer propertiesServer;
//
// @Autowired
// private SysUserDepartMapper sysUserDepartMapper;
//
// @Autowired
// private InvItemSkuMapper invItemSkuMapper;
//
// @Autowired
// private InvItemAttributeMapper invItemAttributeMapper;
//
// @Autowired
// private IdWorker idWorker;
//
// /**
// * 将商品信息从临时表temp_item_fom_pmp同步到正式表inv_item 2683351
// */
// @Test
// public void addInvItem(){
// int j=208054;
// while (true){
// List<TempItemFomPmp> limit = tempItemFomPmpMapper.findLimit(j);
// System.err.println("查询到"+limit.size()+"条数据");
// if(limit.size()<=0){
// System.err.println("所有数据同步完成!!!");
// return;
// }
// List<InvItem> invItems=new ArrayList<>();
// List<InvItemAttribute> invItemAttributes=new ArrayList<>();
// List<InvItemSku> invItemSkus=new ArrayList<>();
// for (TempItemFomPmp tempItemFomPmp:limit) {
// String plucode = invItemMapper.getPlucode(tempItemFomPmp.getPlucode());
// if(plucode!=null){
// continue;
// }
// InvItem invItem=new InvItem();
// InvItemAttribute invItemAttribute=new InvItemAttribute();
// InvItemSku invItemSku=new InvItemSku();
//
// //商品表
// invItem.setId(UuidUtil.get32UUIDString());
// invItem.setOrgId("2c9007626dde3f4f016deda2151f1a42");
// invItem.setStatus("SALE");
// invItem.setProType(tempItemFomPmp.getClscode());
// invItem.setItemCode(idWorker.nextId()+"");
// invItem.setItemName(tempItemFomPmp.getTitle());
// invItem.setItemDesc(tempItemFomPmp.getJp());
// invItem.setPystype(tempItemFomPmp.getPystype()+"");
// invItem.setIsbn(tempItemFomPmp.getIsbn());
// invItem.setPlucode(tempItemFomPmp.getPlucode());
// invItem.setScancode(tempItemFomPmp.getScancode());
// invItem.setExtcode("0");
// invItem.setPurchasePrice(tempItemFomPmp.getPrice()+"");
// invItem.setGeneralName(tempItemFomPmp.getClscode());
// invItem.setManufacturerId(tempItemFomPmp.getPublisher());
// invItem.setSpecification(tempItemFomPmp.getPubdate());
// invItem.setPrimaryUnit("BEN");
// if(tempItemFomPmp.getPystype()==0||tempItemFomPmp.getPystype()==4){
// invItem.setAttribute1("Book");
// invItem.setIsBorrow("Y");
// }else{
// invItem.setAttribute1("Goods");
// invItem.setIsBorrow("N");
// }
// invItem.setAttribute2("A");
// invItem.setTax(tempItemFomPmp.getInctax()+"");
// invItem.setDefaultVendorId("000000006c60dba1016c60f839270004");
// invItem.setCreateBy("PMP同步");
// invItem.setCreateTime(LocalDateTime.now());
// //查询当前用户部门
// //SysUserDepart sysUserDepart = sysUserDepartMapper.selectByUserId("b7b819e3a7fb25699ff5e10332f089f7");
//
// //图书信息
// invItemAttribute.setId(UuidUtil.get32UUIDString());
// invItemAttribute.setCreateBy("PMP同步");
// invItemAttribute.setCreateTime(LocalDateTime.now());
//// if(sysUserDepart!=null){
//// invItemAttribute.setSysOrgCode(sysUserDepart.getDepId());
//// }
// invItemAttribute.setItemId(invItem.getId());
// invItemAttribute.setItemCode(invItem.getItemCode());
// invItemAttribute.setAuthor(tempItemFomPmp.getAuthor());
// invItemAttribute.setReader(tempItemFomPmp.getReader());
//
//
// //商品SKU映射
// invItemSku.setId(UuidUtil.get32UUIDString());
//// if(sysUserDepart!=null){
//// invItemSku.setSysOrgCode(sysUserDepart.getDepId());
//// }
// invItemSku.setOrgId("2c9007626dde3f4f016deda2151f1a42");
// invItemSku.setExternal("PMP");
// invItemSku.setItemSku(tempItemFomPmp.getPlucode());
// invItemSku.setItemName(invItem.getItemName());
// invItemSku.setItemCode(invItem.getItemCode());
// invItemSku.setItemDesc(invItem.getItemDesc());
// invItemSku.setStatus("A");
// invItemSku.setCreateBy("PMP同步");
// invItemSku.setCreateTime(LocalDateTime.now());
// invItems.add(invItem);
// invItemAttributes.add(invItemAttribute);
// invItemSkus.add(invItemSku);
// }
// System.err.println("数据封装完成");
// invItemMapper.insertBatch(invItems);
// invItemSkuMapper.insertBatch(invItemSkus);
// invItemAttributeMapper.insertBatch(invItemAttributes);
// j=j+999;
// System.err.println("前"+j+"条同步完成");
//
// }
// }
//
// /**
// * 将商品信息从临时表temp_item_fom_pmp同步到正式表inv_item 2683351
// */
// @Test
// public void addInvItems(){
// int i=0;
// int j=0;
// while (true){
// List<TempItemFomPmp> limit = tempItemFomPmpMapper.findLimit(j);
// System.err.println("查询到"+limit.size()+"条数据");
// if(limit.size()<=0){
// System.err.println("所有数据同步完成!!!");
// return;
// }
// for (TempItemFomPmp tempItemFomPmp:limit) {
// InvItem plucode = invItemMapper.findByPlucode(tempItemFomPmp.getPlucode());
// if(plucode!=null){
// i++;
// System.err.println("第"+i+"条同步完成");
// continue;
// }
// InvItem invItem=new InvItem();
// InvItemAttribute invItemAttribute=new InvItemAttribute();
// InvItemSku invItemSku=new InvItemSku();
//
// //商品表
// invItem.setId(UuidUtil.get32UUIDString());
// invItem.setOrgId("2c9007626dde3f4f016deda2151f1a42");
// invItem.setStatus("SALE");
// invItem.setProType(tempItemFomPmp.getClscode());
// invItem.setItemCode(idWorker.nextId()+"");
// invItem.setItemName(tempItemFomPmp.getTitle());
// invItem.setItemDesc(tempItemFomPmp.getJp());
// invItem.setPystype(tempItemFomPmp.getPystype()+"");
// invItem.setIsbn(tempItemFomPmp.getIsbn());
// invItem.setPlucode(tempItemFomPmp.getPlucode());
// invItem.setScancode(tempItemFomPmp.getScancode());
// invItem.setExtcode("0");
// invItem.setPurchasePrice(tempItemFomPmp.getPrice()+"");
// invItem.setGeneralName(tempItemFomPmp.getClscode());
// invItem.setManufacturerId(tempItemFomPmp.getPublisher());
// invItem.setSpecification(tempItemFomPmp.getPubdate());
// invItem.setPrimaryUnit("BEN");
// if(tempItemFomPmp.getPystype()==0||tempItemFomPmp.getPystype()==4){
// invItem.setAttribute1("Book");
// invItem.setIsBorrow("Y");
// }else{
// invItem.setAttribute1("Goods");
// invItem.setIsBorrow("N");
// }
// invItem.setAttribute2("A");
// invItem.setTax(tempItemFomPmp.getInctax()+"");
// invItem.setDefaultVendorId("000000006c60dba1016c60f839270004");
// invItem.setCreateBy("PMP同步");
// invItem.setCreateTime(LocalDateTime.now());
// //查询当前用户部门
// //SysUserDepart sysUserDepart = sysUserDepartMapper.selectByUserId("b7b819e3a7fb25699ff5e10332f089f7");
//
// //图书信息
// invItemAttribute.setId(UuidUtil.get32UUIDString());
// invItemAttribute.setCreateBy("PMP同步");
// invItemAttribute.setCreateTime(LocalDateTime.now());
//// if(sysUserDepart!=null){
//// invItemAttribute.setSysOrgCode(sysUserDepart.getDepId());
//// }
// invItemAttribute.setItemId(invItem.getId());
// invItemAttribute.setItemCode(invItem.getItemCode());
// invItemAttribute.setAuthor(tempItemFomPmp.getAuthor());
// invItemAttribute.setReader(tempItemFomPmp.getReader());
//
//
// //商品SKU映射
// invItemSku.setId(UuidUtil.get32UUIDString());
//// if(sysUserDepart!=null){
//// invItemSku.setSysOrgCode(sysUserDepart.getDepId());
//// }
// invItemSku.setOrgId("2c9007626dde3f4f016deda2151f1a42");
// invItemSku.setExternal("PMP");
// invItemSku.setItemSku(tempItemFomPmp.getPlucode());
// invItemSku.setItemName(invItem.getItemName());
// invItemSku.setItemCode(invItem.getItemCode());
// invItemSku.setItemDesc(invItem.getItemDesc());
// invItemSku.setStatus("A");
// invItemSku.setCreateBy("PMP同步");
// invItemSku.setCreateTime(LocalDateTime.now());
// invItemMapper.insert(invItem);
// invItemSkuMapper.insert(invItemSku);
// invItemAttributeMapper.insert(invItemAttribute);
// i++;
// System.err.println("第"+i+"条同步完成");
// }
// j=j+99999;
// }
//
// }
//
//
// @Autowired
// private TempItemSkuFomPmpMapper tempItemSkuFomPmpMapper;
//
// @Autowired
// private TransactionController transactionController;
// /**
// * 将商品库存信息从临时表temp_item_sku_fom_pmp同步到正式库存
// */
// @Test
// public void addInvItemSku(){
// List<TempItemSkuFomPmp> select = tempItemSkuFomPmpMapper.select();
// System.err.println(select.size());
// int i=0;
// for (TempItemSkuFomPmp tempItemSkuFomPmp:select) {
// JSONObject jsonObject=new JSONObject();
// JSONObject data=new JSONObject();
// data.put("inv_code","WH2");
// data.put("subinv_code","KQ22");
// data.put("locator_code","HJ"+tempItemSkuFomPmp.getRack());
// String itemcode = invItemMapper.getPlucode(tempItemSkuFomPmp.getPlucode());
// if(itemcode==null){
// continue;
// }
// data.put("item_code",itemcode);
// data.put("tx_type_code","PMP_SYN");
// data.put("tx_date",new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
// data.put("tx_quantity",tempItemSkuFomPmp.getQty());
// data.put("tx_price",tempItemSkuFomPmp.getPrice());
// jsonObject.put("data",data);
// String s = transactionController.invItemInOut("201910271129039497a78b526d9a246eca0abb1025986f25cG7BHIxhVaDO6MYm", jsonObject);
// i++;
// System.err.println(i+"--"+select.size());
// }
// }
//}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment