Commit 8dab0a00 by 肖洋洋

外部接口对接代码2

parent c99ed9f9
Showing with 2024 additions and 1065 deletions
...@@ -3,7 +3,9 @@ package orthopedics; ...@@ -3,7 +3,9 @@ package orthopedics;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
import orthopedics.util.IdWorker;
@SpringBootApplication @SpringBootApplication
//@EnableScheduling //@EnableScheduling
...@@ -13,5 +15,8 @@ public class Application { ...@@ -13,5 +15,8 @@ public class Application {
SpringApplication.run(Application.class, args); 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; ...@@ -10,8 +10,10 @@ import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import orthopedics.dao.InvItemBalanceSummaryVMapper; import orthopedics.dao.InvItemBalanceSummaryVMapper;
import orthopedics.dao.InvLocatorMapper;
import orthopedics.dao.SalOrderHeaderMapper; import orthopedics.dao.SalOrderHeaderMapper;
import orthopedics.model.InvItemBalanceSummaryV; import orthopedics.model.InvItemBalanceSummaryV;
import orthopedics.model.InvLocator;
import orthopedics.model.SalOrderHeader; import orthopedics.model.SalOrderHeader;
import orthopedics.util.*; import orthopedics.util.*;
...@@ -24,6 +26,9 @@ public class SyncItemSku { ...@@ -24,6 +26,9 @@ public class SyncItemSku {
@Autowired @Autowired
private InvItemBalanceSummaryVMapper invItemBalanceSummaryVMapper; private InvItemBalanceSummaryVMapper invItemBalanceSummaryVMapper;
@Autowired
private InvLocatorMapper invLocatorMapper;
/** /**
* 将商品库存同步到PMP * 将商品库存同步到PMP
*/ */
...@@ -41,7 +46,8 @@ public class SyncItemSku { ...@@ -41,7 +46,8 @@ public class SyncItemSku {
JSONObject jsonObject=new JSONObject(); JSONObject jsonObject=new JSONObject();
if(invItemBalanceSummaryV.getLocator_id()!=null && invItemBalanceSummaryV.getBalance()!=null){ if(invItemBalanceSummaryV.getLocator_id()!=null && invItemBalanceSummaryV.getBalance()!=null){
jsonObject.put("wh",invItemBalanceSummaryV.getInv_id()); 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("plucode",invItemBalanceSummaryV.getPlucode());
jsonObject.put("qty",invItemBalanceSummaryV.getBalance()); jsonObject.put("qty",invItemBalanceSummaryV.getBalance());
plulist.add(jsonObject); plulist.add(jsonObject);
......
...@@ -60,10 +60,24 @@ public class SyncSalFromPos { ...@@ -60,10 +60,24 @@ public class SyncSalFromPos {
ps.setString(1,invItem.getItemCode()); ps.setString(1,invItem.getItemCode());
rs = ps.executeQuery(); rs = ps.executeQuery();
while (rs.next()){ while (rs.next()){
String operator = rs.getString(2);//收银员账号
Timestamp timestamp = rs.getTimestamp(3);//订单时间 Timestamp timestamp = rs.getTimestamp(3);//订单时间
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); long vouchnum = rs.getLong(4);//小票单号
// String dateStr = sdf.format(date); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String paymentMethod = rs.getString(8);//支付方式 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 quantity = rs.getInt(13);//数量
int attribute1 = rs.getInt(14);//单价 int attribute1 = rs.getInt(14);//单价
int attribute3 = rs.getInt(15);//折扣 int attribute3 = rs.getInt(15);//折扣
......
...@@ -9,10 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -9,10 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import orthopedics.dao.InvItemMapper; import orthopedics.dao.*;
import orthopedics.dao.InvLocatorMapper;
import orthopedics.dao.InvSubinventoryMapper;
import orthopedics.dao.SalOrderLineVMapper;
import orthopedics.model.*; import orthopedics.model.*;
import orthopedics.util.Aes; import orthopedics.util.Aes;
import orthopedics.util.HttpUtilPMP; import orthopedics.util.HttpUtilPMP;
...@@ -37,6 +34,9 @@ public class SyncSalOrderHeader { ...@@ -37,6 +34,9 @@ public class SyncSalOrderHeader {
@Autowired @Autowired
private InvLocatorMapper invLocatorMapper; private InvLocatorMapper invLocatorMapper;
@Autowired
private SalOrderLineDetailVMapper salOrderLineDetailVMapper;
/** /**
* 将销售订单同步到PMP * 将销售订单同步到PMP
*/ */
...@@ -57,26 +57,17 @@ public class SyncSalOrderHeader { ...@@ -57,26 +57,17 @@ public class SyncSalOrderHeader {
jsonObject.put("seq",salOrderLineV.getLineNumber()); jsonObject.put("seq",salOrderLineV.getLineNumber());
jsonObject.put("plucode",salOrderLineV.getPlucode()); jsonObject.put("plucode",salOrderLineV.getPlucode());
// jsonObject.put("fwh",salOrderLineV); // jsonObject.put("fwh",salOrderLineV);
InvItem invItem = invItemMapper.selectInvItemById(salOrderLineV.getItemId()); SalOrderLineDetailV byOrderNumber = salOrderLineDetailVMapper.findByOrderNumber(salOrderLineV.getOrderNumber());
if(invItem==null){ if(byOrderNumber==null){
logger.error("销售订单商品id【"+salOrderLineV.getItemId()+"】查询不到商品信息"); logger.error(salOrderLineV.getOrderNumber()+"查询不到销售订单执行报表");
return; continue;
}
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;
} }
List<InvLocator> byInvIdAndSubinvId = invLocatorMapper.findByInvIdAndSubinvId(invItem.getInvId(), invSubinventories.get(0).getId()); InvLocator byId = invLocatorMapper.findById(byOrderNumber.getLocatorId());
if(invSubinventories==null||invSubinventories.size()<=0){ if(byId==null){
logger.error("商品code:"+invItem.getItemCode()+"库存id和存储库区id查询不到货架"); logger.error(salOrderLineV.getOrderNumber()+"查询不到货架号");
return; continue;
} }
jsonObject.put("frack",byInvIdAndSubinvId.get(0).getLocatorCode()); jsonObject.put("frack",byId.getLocatorName());
jsonObject.put("qty",salOrderLineV.getQuantity()); jsonObject.put("qty",salOrderLineV.getQuantity());
jsonObject.put("disc",salOrderLineV.getAttribute3()); jsonObject.put("disc",salOrderLineV.getAttribute3());
jsonObject.put("apvby",salOrderLineV.getOrderDate()); jsonObject.put("apvby",salOrderLineV.getOrderDate());
......
...@@ -170,6 +170,28 @@ public class InvCountHeaderController { ...@@ -170,6 +170,28 @@ public class InvCountHeaderController {
return new Result(true,StatusCode.OK,"盘点单查询成功",invCountHeaderPage); 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") @GetMapping("/findByCountNumberToSku")
public Result findByCountNumberToSku(@RequestParam(value = "access_token",required = true)String token,@RequestParam(value = "countNumber",required = true) String countNumber){ public Result findByCountNumberToSku(@RequestParam(value = "access_token",required = true)String token,@RequestParam(value = "countNumber",required = true) String countNumber){
SysAccessToken sysAccessToken = userServer.checkToken(token); SysAccessToken sysAccessToken = userServer.checkToken(token);
......
...@@ -40,10 +40,10 @@ public class InvCountPrintController { ...@@ -40,10 +40,10 @@ public class InvCountPrintController {
private InvItemBalanceSummaryVMapper invItemBalanceSummaryVMapper; private InvItemBalanceSummaryVMapper invItemBalanceSummaryVMapper;
@GetMapping("/findByPrintNumber") @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); SysAccessToken sysAccessToken = userServer.checkToken(token);
List<InvCountPrintPage> ichp=new ArrayList<>(); List<InvCountPrintPage> ichp=new ArrayList<>();
if(StringUtil.isEmpty(printNumber)){ if(StringUtil.isEmpty(printInvId)){
List<SysOrgAccess> sysOrgAccesses = userServer.selectSysOrgAccessByUserId(sysAccessToken.getUserId()); List<SysOrgAccess> sysOrgAccesses = userServer.selectSysOrgAccessByUserId(sysAccessToken.getUserId());
if(sysOrgAccesses==null || sysOrgAccesses.size()<=0){ if(sysOrgAccesses==null || sysOrgAccesses.size()<=0){
return new Result(false, StatusCode.ERROR,"当前用户不属于任何组织"); return new Result(false, StatusCode.ERROR,"当前用户不属于任何组织");
...@@ -63,23 +63,32 @@ public class InvCountPrintController { ...@@ -63,23 +63,32 @@ public class InvCountPrintController {
} }
return new Result(true,StatusCode.OK,"盘点计划查询成功",ichp); 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(); InvCountPrintPage invCountPrintPage=new InvCountPrintPage();
InvCountPrint byPrintNumber = invCountPrintMapper.findByPrintNumber(printNumber); BeanUtils.copyProperties(invCountPrint,invCountPrintPage);
if(byPrintNumber==null){ List<InvCountPrintLine> invCountPrintLines = invCountPrintLineMapper.findByPrintId(invCountPrint.getId());
return new Result(false, StatusCode.ERROR,"判断顺序号查询不到数据"); if(invCountPrintLines==null || invCountPrintLines.size()<=0){
continue;
} }
List<InvCountPrintLine> byPrintId = invCountPrintLineMapper.findByPrintId(byPrintNumber.getId()); invCountPrintPage.setInvCountPrintLines(invCountPrintLines);
BeanUtils.copyProperties(byPrintNumber,invCountPrintPage); ichp.add(invCountPrintPage);
invCountPrintPage.setInvCountPrintLines(byPrintId); }
return new Result(true,StatusCode.OK,"盘点计划查询成功",invCountPrintPage); return new Result(true,StatusCode.OK,"盘点计划查询成功",ichp);
} }
@GetMapping("/findByPrintNumberToSku") @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); SysAccessToken sysAccessToken = userServer.checkToken(token);
if(StringUtil.isEmpty(printNumber)){ if(StringUtil.isEmpty(printNumber)){
return new Result(false, StatusCode.ERROR,"顺序号为空"); return new Result(false, StatusCode.ERROR,"顺序号为空");
} }
if(StringUtil.isEmpty(invId)){
return new Result(false, StatusCode.ERROR,"库存为空");
}
InvCountPrint byPrintNumber = invCountPrintMapper.findByPrintNumber(printNumber); InvCountPrint byPrintNumber = invCountPrintMapper.findByPrintNumber(printNumber);
if(byPrintNumber==null){ if(byPrintNumber==null){
return new Result(false, StatusCode.ERROR,"判断顺序号查询不到数据"); return new Result(false, StatusCode.ERROR,"判断顺序号查询不到数据");
...@@ -88,8 +97,8 @@ public class InvCountPrintController { ...@@ -88,8 +97,8 @@ public class InvCountPrintController {
if(byPrintId==null || byPrintId.size()<=0){ if(byPrintId==null || byPrintId.size()<=0){
return new Result(false, StatusCode.ERROR,"顺序号为【"+printNumber+"】没有子表数据"); return new Result(false, StatusCode.ERROR,"顺序号为【"+printNumber+"】没有子表数据");
} }
String sql = "";
String sqld="'"; String sqld="'";
String sql = " inv_id="+sqld+invId+sqld;
for (InvCountPrintLine invCountPrintLine:byPrintId) { for (InvCountPrintLine invCountPrintLine:byPrintId) {
SysDictItem sysDictItem = sysDictItemMapper.findByItemValue(invCountPrintLine.getCompare()); SysDictItem sysDictItem = sysDictItemMapper.findByItemValue(invCountPrintLine.getCompare());
if(sysDictItem==null){ if(sysDictItem==null){
......
...@@ -227,12 +227,13 @@ public class SalOrderHeaderController { ...@@ -227,12 +227,13 @@ public class SalOrderHeaderController {
if(warehouseCode==null||warehouseCode.equals("")){ if(warehouseCode==null||warehouseCode.equals("")){
return new Result(false, StatusCode.ERROR,"缺少库存code信息"); return new Result(false, StatusCode.ERROR,"缺少库存code信息");
} }
//装重复商品id
List skulist=new ArrayList<>();
if(type.equals("1")){ if(type.equals("1")){
//入库 //入库
List<SalOrderHeader> salOrderHeaders = salOrderHeaderMapper.selectSalOrderByattribute1(orderId); List<SalOrderHeader> salOrderHeaders = salOrderHeaderMapper.selectSalOrderByattribute1(orderId);
if(salOrderHeaders==null||salOrderHeaders.size()<=0){ 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"); salOrderHeaderMapper.updateStatus(salOrderHeaders.get(0).getId(),"refund");
for (JSONObject jsonObject:items) { for (JSONObject jsonObject:items) {
...@@ -249,6 +250,7 @@ public class SalOrderHeaderController { ...@@ -249,6 +250,7 @@ public class SalOrderHeaderController {
if(StringUtil.isEmpty(skuid)){ if(StringUtil.isEmpty(skuid)){
return new Result(false, StatusCode.ERROR,"缺少商品skuid"); return new Result(false, StatusCode.ERROR,"缺少商品skuid");
} }
int quantity=0; int quantity=0;
for (JSONObject jsonObject1:items) { for (JSONObject jsonObject1:items) {
JSONObject sku1 = (JSONObject) jsonObject1.get("sku"); JSONObject sku1 = (JSONObject) jsonObject1.get("sku");
...@@ -329,10 +331,14 @@ public class SalOrderHeaderController { ...@@ -329,10 +331,14 @@ public class SalOrderHeaderController {
if(StringUtil.isEmpty(skuid)){ if(StringUtil.isEmpty(skuid)){
return new Result(false, StatusCode.ERROR,"缺少商品skuid"); return new Result(false, StatusCode.ERROR,"缺少商品skuid");
} }
if(skulist.contains(skuid)){
continue;
}
skulist.add(skuid);
int quantity=0; int quantity=0;
for (JSONObject jsonObject1:items) { for (JSONObject jsonObject1:items) {
JSONObject sku1 = (JSONObject) jsonObject1.get("sku"); JSONObject sku1 = (JSONObject) jsonObject1.get("sku");
String id = (String) sku.get("_id"); String id = (String) sku1.get("_id");
if(id.equals(skuid)){ if(id.equals(skuid)){
quantity=quantity+1; quantity=quantity+1;
} }
...@@ -468,12 +474,13 @@ public class SalOrderHeaderController { ...@@ -468,12 +474,13 @@ public class SalOrderHeaderController {
if(warehouseCode==null||warehouseCode.equals("")){ if(warehouseCode==null||warehouseCode.equals("")){
return new Result(false, StatusCode.ERROR,"缺少库存code信息"); return new Result(false, StatusCode.ERROR,"缺少库存code信息");
} }
//装重复商品id
List skulist=new ArrayList<>();
if(status.equals("Return")){ if(status.equals("Return")){
//入库 //入库
List<SalOrderHeader> salOrderHeaders = salOrderHeaderMapper.selectSalOrderByattribute1(borrowId); List<SalOrderHeader> salOrderHeaders = salOrderHeaderMapper.selectSalOrderByattribute1(borrowId);
if(salOrderHeaders==null||salOrderHeaders.size()<=0){ 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"); salOrderHeaderMapper.updateStatus(salOrderHeaders.get(0).getId(),"return");
for (JSONObject jsonObject:items) { for (JSONObject jsonObject:items) {
...@@ -570,10 +577,14 @@ public class SalOrderHeaderController { ...@@ -570,10 +577,14 @@ public class SalOrderHeaderController {
if(StringUtil.isEmpty(skuid)){ if(StringUtil.isEmpty(skuid)){
return new Result(false, StatusCode.ERROR,"缺少商品skuid"); return new Result(false, StatusCode.ERROR,"缺少商品skuid");
} }
if(skulist.contains(skuid)){
continue;
}
skulist.add(skuid);
int quantity=0; int quantity=0;
for (JSONObject jsonObject1:items) { for (JSONObject jsonObject1:items) {
JSONObject sku1 = (JSONObject) jsonObject1.get("sku"); JSONObject sku1 = (JSONObject) jsonObject1.get("sku");
String id = (String) sku.get("_id"); String id = (String) sku1.get("_id");
if(id.equals(skuid)){ if(id.equals(skuid)){
quantity=quantity+1; quantity=quantity+1;
} }
...@@ -729,4 +740,5 @@ public class SalOrderHeaderController { ...@@ -729,4 +740,5 @@ public class SalOrderHeaderController {
data.put("data",jsonObject); data.put("data",jsonObject);
return new Result(true, StatusCode.ERROR,"数据封装完毕",data); return new Result(true, StatusCode.ERROR,"数据封装完毕",data);
} }
} }
...@@ -51,7 +51,7 @@ public class TakeStockController { ...@@ -51,7 +51,7 @@ public class TakeStockController {
*/ */
@PostMapping("/invInventory/search") @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); SysAccessToken sysAccessToken = userServer.checkToken(token);
if(requestJson==null||requestJson.size()<=0){ if(requestJson==null||requestJson.size()<=0){
List<InvInventory> select = invInventoryMapper.select(); List<InvInventory> select = invInventoryMapper.select();
...@@ -77,7 +77,7 @@ public class TakeStockController { ...@@ -77,7 +77,7 @@ public class TakeStockController {
*/ */
@PostMapping("/invSubinventory/search") @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); SysAccessToken sysAccessToken = userServer.checkToken(token);
if(requestJson==null||requestJson.size()<=0){ if(requestJson==null||requestJson.size()<=0){
List<InvSubinventory> select = invSubinventoryMapper.select(); List<InvSubinventory> select = invSubinventoryMapper.select();
...@@ -104,7 +104,7 @@ public class TakeStockController { ...@@ -104,7 +104,7 @@ public class TakeStockController {
*/ */
@PostMapping("/invLocator/search") @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); SysAccessToken sysAccessToken = userServer.checkToken(token);
if(requestJson==null||requestJson.size()<=0){ if(requestJson==null||requestJson.size()<=0){
List<InvLocator> select = invLocatorMapper.select(); List<InvLocator> select = invLocatorMapper.select();
...@@ -129,7 +129,7 @@ public class TakeStockController { ...@@ -129,7 +129,7 @@ public class TakeStockController {
* @throws Exception * @throws Exception
*/ */
@PostMapping("/sku/search") @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); SysAccessToken sysAccessToken = userServer.checkToken(token);
if(requestJson==null||requestJson.size()<=0){ if(requestJson==null||requestJson.size()<=0){
List<InvItemBalanceSummaryV> select = invItemBalanceSummaryVMapper.select(); List<InvItemBalanceSummaryV> select = invItemBalanceSummaryVMapper.select();
...@@ -173,7 +173,7 @@ public class TakeStockController { ...@@ -173,7 +173,7 @@ public class TakeStockController {
* @throws Exception * @throws Exception
*/ */
@GetMapping("/sku/findLikeSku") @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); SysAccessToken sysAccessToken = userServer.checkToken(token);
if(StringUtil.isEmpty(request)){ if(StringUtil.isEmpty(request)){
return new Result(false,StatusCode.ERROR,"参数为空"); return new Result(false,StatusCode.ERROR,"参数为空");
...@@ -183,6 +183,27 @@ public class TakeStockController { ...@@ -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 @Autowired
private RedisTemplate redisTemplate; private RedisTemplate redisTemplate;
......
...@@ -2015,11 +2015,7 @@ public class PurchaseController { ...@@ -2015,11 +2015,7 @@ public class PurchaseController {
//status和headerId为筛选条件 //status和headerId为筛选条件
private List<RcvReceiptLineV> getUniqueRcvReceiptLine(String userName, String userId, String status, String headerId) { private List<RcvReceiptLineV> getUniqueRcvReceiptLine(String userName, String userId, String status, String headerId) {
List<RcvReceiptLineV> rcvReceiptLineVList = new ArrayList<>(); List<RcvReceiptLineV> rcvReceiptLineVList = new ArrayList<>();
rcvReceiptLineVList.addAll(purchaseServer.selectRcvReceiptLineVByUserNameAndStatusAndHeaderId(userName, status, headerId)); rcvReceiptLineVList.addAll(purchaseServer.selectRcvReceiptLineVByInvIdAndStatusAndHeaderIdG(status, headerId));
List<String> invList = getValidInvIdByUserId(userId);
if (invList.size() > 0) {
rcvReceiptLineVList.addAll(purchaseServer.selectRcvReceiptLineVByInvIdAndStatusAndHeaderId(invList,status, headerId));
}
//去重 //去重
return rcvReceiptLineVList.stream().collect( return rcvReceiptLineVList.stream().collect(
Collectors.collectingAndThen(Collectors.toCollection( Collectors.collectingAndThen(Collectors.toCollection(
......
...@@ -19,23 +19,8 @@ import org.slf4j.Logger; ...@@ -19,23 +19,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import orthopedics.controller.error.ErrorEnum; import orthopedics.controller.error.ErrorEnum;
import orthopedics.controller.operation.SaleOrderProcessEnum; import orthopedics.controller.operation.SaleOrderProcessEnum;
import orthopedics.model.HrOrganization; import orthopedics.dao.WshParameterMapper;
import orthopedics.model.InvItem; import orthopedics.model.*;
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.service.InventoryServer; import orthopedics.service.InventoryServer;
import orthopedics.service.OrganzitionServer; import orthopedics.service.OrganzitionServer;
import orthopedics.service.ProcessLogServer; import orthopedics.service.ProcessLogServer;
...@@ -406,7 +391,8 @@ public class SaleController { ...@@ -406,7 +391,8 @@ public class SaleController {
return responseResult.toJSONString(); return responseResult.toJSONString();
} }
@Autowired
private WshParameterMapper wshParameterMapper;
public String saleOrderHeaderCreateG(JSONObject requestJson) { public String saleOrderHeaderCreateG(JSONObject requestJson) {
logger.info(String.format("----销售订单信息创建接口----- requestJson %s", requestJson.toJSONString())); logger.info(String.format("----销售订单信息创建接口----- requestJson %s", requestJson.toJSONString()));
...@@ -511,7 +497,7 @@ public class SaleController { ...@@ -511,7 +497,7 @@ public class SaleController {
if (saleOrderLineArray != null) { if (saleOrderLineArray != null) {
//line_number 不能重复 //line_number 不能重复
List<String> lineNumberList = new ArrayList<>(); //List<String> lineNumberList = new ArrayList<>();
for (int i = 0; i < saleOrderLineArray.size(); i++) { for (int i = 0; i < saleOrderLineArray.size(); i++) {
JSONObject line = saleOrderLineArray.getJSONObject(i); JSONObject line = saleOrderLineArray.getJSONObject(i);
...@@ -523,14 +509,14 @@ public class SaleController { ...@@ -523,14 +509,14 @@ public class SaleController {
}); });
Double taxRate = line.getDouble("tax_rate"); Double taxRate = line.getDouble("tax_rate");
String lineNumber = line.getString("line_number"); // String lineNumber = line.getString("line_number");
if (lineNumberList.contains(lineNumber)) { // if (lineNumberList.contains(lineNumber) ) {
logger.info(String.format("line_number%s重复了", lineNumber)); // logger.info(String.format("line_number%s重复了", lineNumber));
return "line_number不能为"+lineNumber; // return "line_number不能为"+lineNumber;
} // }
else { // else {
lineNumberList.add(lineNumber); // lineNumberList.add(lineNumber);
} // }
String salePrice = StringUtil.valueOf(line.get("sale_price")); String salePrice = StringUtil.valueOf(line.get("sale_price"));
if (!StringUtil.isPrice(salePrice)) { if (!StringUtil.isPrice(salePrice)) {
logger.info(String.format("sale_price非价格形式", salePrice)); logger.info(String.format("sale_price非价格形式", salePrice));
...@@ -556,15 +542,16 @@ public class SaleController { ...@@ -556,15 +542,16 @@ public class SaleController {
if (StringUtil.notEmpty(unitCode)) { if (StringUtil.notEmpty(unitCode)) {
checkUnitCode(unitCode); checkUnitCode(unitCode);
} }
SalParameter salParameter = saleServer.selectParameterByOrgId(orgId); //SalParameter salParameter = saleServer.selectParameterByOrgId(orgId);
if (salParameter == null) { // List<WshParameter> wshParameters = wshParameterMapper.selectWshParamByOrg(orgId);
logger.info(String.format("orgCode%s找不到相应的parameter", data.getString("org_code"))); // if (wshParameters == null || wshParameters.size()<=0) {
return "org_code不能为"+data.getString("org_code"); // logger.info(String.format("orgCode%s找不到相应的parameter", data.getString("org_code")));
} // return "org_code不能为"+data.getString("org_code");
// }
String itemCode = line.getString("item_code"); String itemCode = line.getString("item_code");
InvItem invItem = inventoryServer.selectInvItemByItemCodeWithInvIdG(itemCode); InvItem invItem = inventoryServer.selectInvItemByItemCodeWithInvIdG(itemCode);
if (invItem == null) { 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; return "itemCode不能为"+itemCode;
} }
String lineId = line.getString("lineId"); String lineId = line.getString("lineId");
...@@ -598,7 +585,7 @@ public class SaleController { ...@@ -598,7 +585,7 @@ public class SaleController {
salOrderLine.setItemCode(itemCode); salOrderLine.setItemCode(itemCode);
salOrderLine.setSalOrderHeaderId(headId); salOrderLine.setSalOrderHeaderId(headId);
salOrderLine.setOrderHeaderId(headId); salOrderLine.setOrderHeaderId(headId);
salOrderLine.setLineNumber(StringUtil.notEmpty(lineNumber) ? lineNumber : String.valueOf(i+1)); salOrderLine.setLineNumber(String.valueOf(i+1));
salOrderLine.setItemId(invItem.getId()); salOrderLine.setItemId(invItem.getId());
String itemName = line.getString("item_name"); String itemName = line.getString("item_name");
salOrderLine.setItemName(StringUtil.notEmpty(itemName) ? itemName : invItem.getItemName()); salOrderLine.setItemName(StringUtil.notEmpty(itemName) ? itemName : invItem.getItemName());
......
...@@ -79,8 +79,13 @@ int updateInvCountHeaderStatus(@Param("status") String status, @Param("id") Stri ...@@ -79,8 +79,13 @@ int updateInvCountHeaderStatus(@Param("status") String status, @Param("id") Stri
@ResultMap("invcountheader") @ResultMap("invcountheader")
public List<InvCountHeader> fingBySysOrgCode(@Param("sysOrgCode") String sysOrgCode); public List<InvCountHeader> fingBySysOrgCode(@Param("sysOrgCode") String sysOrgCode);
//根据sysOrgCode查询 //根据countNumber查询
@Select("select * from inv_count_header where count_number = #{countNumber}") @Select("select * from inv_count_header where count_number = #{countNumber}")
@ResultMap("invcountheader") @ResultMap("invcountheader")
public InvCountHeader fingByCountNumber(@Param("countNumber") String countNumber); 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); ...@@ -68,8 +68,13 @@ Integer insert(InvCountPrint InvCountPrint);
@ResultMap("invcountprint") @ResultMap("invcountprint")
List<InvCountPrint> findByOrgId(@Param("orgId")String orgId); List<InvCountPrint> findByOrgId(@Param("orgId")String orgId);
//通过组织id查询 //通过顺序号查询
@Select("SELECT * FROM inv_count_print WHERE print_number = #{printNumber} ") @Select("SELECT * FROM inv_count_print WHERE print_number = #{printNumber} ")
@ResultMap("invcountprint") @ResultMap("invcountprint")
InvCountPrint findByPrintNumber(@Param("printNumber")String printNumber); 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{ ...@@ -126,6 +126,8 @@ public interface InvItemBalanceSummaryVMapper{
@ResultMap("invitembalancesummaryv") @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); 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{ ...@@ -61,6 +61,7 @@ public interface InvItemMapper{
@Result(property = "rfid", column = "rfid"), @Result(property = "rfid", column = "rfid"),
@Result(property = "language", column = "language"), @Result(property = "language", column = "language"),
@Result(property = "marketingStatus", column = "marketing_status"), @Result(property = "marketingStatus", column = "marketing_status"),
@Result(property = "maxInvQty", column = "max_inv_qty"),
}) })
public List<InvItem> select(); public List<InvItem> select();
...@@ -78,16 +79,16 @@ public interface InvItemMapper{ ...@@ -78,16 +79,16 @@ public interface InvItemMapper{
InvItem selectByItemId(@Param("itemId") String itemId); InvItem selectByItemId(@Param("itemId") String itemId);
@Insert("<script>" + @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=','>" + "<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>" + "</foreach>" +
"</script>") "</script>")
Integer insertBatch(@Param("invitems")List<InvItem> InvItemList); Integer insertBatch(@Param("invitems")List<InvItem> InvItemList);
@Insert( @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" + "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})" "(#{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); Integer insert(InvItem InvItem);
...@@ -139,4 +140,7 @@ public interface InvItemMapper{ ...@@ -139,4 +140,7 @@ public interface InvItemMapper{
@Select("SELECT * FROM inv_item WHERE plucode = #{plucode}") @Select("SELECT * FROM inv_item WHERE plucode = #{plucode}")
@ResultMap("invitem") @ResultMap("invitem")
InvItem findByPlucode(@Param("plucode") String plucode); 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{ ...@@ -75,4 +75,8 @@ public interface InvLocatorMapper{
@ResultMap("invlocator") @ResultMap("invlocator")
InvLocator findById(@Param("id")String id); 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(); ...@@ -104,6 +104,19 @@ public List<RcvReceiptLineV> select();
public List<RcvReceiptLineV> selectByInvIdAndStatusAndHeaderId public List<RcvReceiptLineV> selectByInvIdAndStatusAndHeaderId
(@Param("invIds")List<String> invIds, @Param("rcvReceiptLineStatus")String rcvReceiptLineStatus,@Param("headerId")String headerId); (@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("<script>" +
"SELECT * FROM rcv_receipt_line_v rl " + "SELECT * FROM rcv_receipt_line_v rl " +
"LEFT JOIN sys_value_set_v vs " + "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); ...@@ -66,7 +66,10 @@ Integer insert(TempItemFomPmp TempItemFomPmp);
@Select("select count(temp_item_fom_pmp.`id`) from temp_item_fom_pmp") @Select("select count(temp_item_fom_pmp.`id`) from temp_item_fom_pmp")
Integer findCount(); Integer findCount();
@Select("SELECT * FROM temp_item_fom_pmp LIMIT ${sta},10000") @Select("SELECT * FROM temp_item_fom_pmp LIMIT ${sta},5000")
@ResultMap("tempitemfompmp") @ResultMap("tempitemfompmp")
public List<TempItemFomPmp> findLimit(@Param("sta") int sta); 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; ...@@ -5,16 +5,13 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.List; import java.util.List;
import com.alibaba.fastjson.annotation.JSONField; 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 { 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 { ...@@ -33,43 +30,43 @@ public class InvItem implements Serializable {
private String attributeCategory; private String attributeCategory;
/** /**
* 备用字段1 * 商品类型
* isNullAble:1 * isNullAble:0
*/ */
@JSONField(name = "attribute1") @JSONField(name = "attribute1")
private String attribute1; private String attribute1;
/** /**
* 备用字段2 * 采购类型
* isNullAble:1 * isNullAble:0
*/ */
@JSONField(name = "attribute2") @JSONField(name = "attribute2")
private String attribute2; private String attribute2;
/** /**
* 备用子段3 * 寄售
* isNullAble:1 * isNullAble:1
*/ */
@JSONField(name = "attribute3") @JSONField(name = "attribute3")
private String attribute3; private String attribute3;
/** /**
* 备用字段4 * 扣点%
* isNullAble:1 * isNullAble:1
*/ */
@JSONField(name = "attribute4") @JSONField(name = "attribute4")
private String attribute4; private String attribute4;
/** /**
* 备用字段5 * 库存信息同步到pmp
* isNullAble:1 * isNullAble:1
*/ */
@JSONField(name = "attribute5") @JSONField(name = "attribute5")
private String attribute5; private String attribute5;
/** /**
* 备用字段6 * 商品信息同步到是否pos
* isNullAble:1 * isNullAble:1,defaultVal:0
*/ */
@JSONField(name = "attribute6") @JSONField(name = "attribute6")
private String attribute6; private String attribute6;
...@@ -111,14 +108,14 @@ public class InvItem implements Serializable { ...@@ -111,14 +108,14 @@ public class InvItem implements Serializable {
/** /**
* 商品代码 * 商品代码
* isNullAble:0 * isNullAble:1
*/ */
@JSONField(name = "item_code") @JSONField(name = "item_code")
private String itemCode; private String itemCode;
/** /**
* 商品名称 * 商品名称
* isNullAble:1 * isNullAble:0
*/ */
@JSONField(name = "item_name") @JSONField(name = "item_name")
private String itemName; private String itemName;
...@@ -153,28 +150,28 @@ public class InvItem implements Serializable { ...@@ -153,28 +150,28 @@ public class InvItem implements Serializable {
/** /**
* 货号 * 货号
* isNullAble:0 * isNullAble:1
*/ */
@JSONField(name = "plucode") @JSONField(name = "plucode")
private String plucode; private String plucode;
/** /**
* 扫描码 * 扫描码
* isNullAble:0 * isNullAble:1
*/ */
@JSONField(name = "scancode") @JSONField(name = "scancode")
private String scancode; private String scancode;
/** /**
* 延长码 * 延长码
* isNullAble:1,defaultVal:3 * isNullAble:1,defaultVal:0
*/ */
@JSONField(name = "extcode") @JSONField(name = "extcode")
private String extcode; private String extcode;
/** /**
* 价格 * 价格
* isNullAble:1 * isNullAble:0
*/ */
@JSONField(name = "purchase_price") @JSONField(name = "purchase_price")
private String purchasePrice; private String purchasePrice;
...@@ -188,7 +185,7 @@ public class InvItem implements Serializable { ...@@ -188,7 +185,7 @@ public class InvItem implements Serializable {
/** /**
* CIP分类 * CIP分类
* isNullAble:0 * isNullAble:1
*/ */
@JSONField(name = "cip") @JSONField(name = "cip")
private String cip; private String cip;
...@@ -205,8 +202,6 @@ public class InvItem implements Serializable { ...@@ -205,8 +202,6 @@ public class InvItem implements Serializable {
* isNullAble:1 * isNullAble:1
*/ */
@JSONField(name = "specification") @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; private java.time.LocalDateTime specification;
/** /**
...@@ -260,21 +255,21 @@ public class InvItem implements Serializable { ...@@ -260,21 +255,21 @@ public class InvItem implements Serializable {
/** /**
* 单位 * 单位
* isNullAble:1 * isNullAble:0
*/ */
@JSONField(name = "primary_unit") @JSONField(name = "primary_unit")
private String primaryUnit; private String primaryUnit;
/** /**
* 批次控制 * 批次控制
* isNullAble:1 * isNullAble:1,defaultVal:N
*/ */
@JSONField(name = "lot_control") @JSONField(name = "lot_control")
private String lotControl; private String lotControl;
/** /**
* 序列控制 * 序列控制
* isNullAble:1 * isNullAble:1,defaultVal:N
*/ */
@JSONField(name = "serial_control") @JSONField(name = "serial_control")
private String serialControl; private String serialControl;
...@@ -305,8 +300,6 @@ public class InvItem implements Serializable { ...@@ -305,8 +300,6 @@ public class InvItem implements Serializable {
* isNullAble:1 * isNullAble:1
*/ */
@JSONField(name = "create_time") @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; private java.time.LocalDateTime createTime;
/** /**
...@@ -321,20 +314,18 @@ public class InvItem implements Serializable { ...@@ -321,20 +314,18 @@ public class InvItem implements Serializable {
* isNullAble:1 * isNullAble:1
*/ */
@JSONField(name = "update_time") @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; private java.time.LocalDateTime updateTime;
/** /**
* 商品类型 * 商品分类
* isNullAble:0 * isNullAble:1
*/ */
@JSONField(name = "pro_type") @JSONField(name = "pro_type")
private String proType; private String proType;
/** /**
* 可借阅 * 可借阅
* isNullAble:1 * isNullAble:0
*/ */
@JSONField(name = "is_borrow") @JSONField(name = "is_borrow")
private String isBorrow; private String isBorrow;
...@@ -360,6 +351,13 @@ public class InvItem implements Serializable { ...@@ -360,6 +351,13 @@ public class InvItem implements Serializable {
@JSONField(name = "marketing_status") @JSONField(name = "marketing_status")
private String marketingStatus; private String marketingStatus;
/**
* 库存上限
* isNullAble:1
*/
@JSONField(name = "max_inv_qty")
private String maxInvQty;
public void setId(String id){this.id = id;} public void setId(String id){this.id = id;}
...@@ -552,6 +550,10 @@ public class InvItem implements Serializable { ...@@ -552,6 +550,10 @@ public class InvItem implements Serializable {
public void setMarketingStatus(String marketingStatus){this.marketingStatus = marketingStatus;} public void setMarketingStatus(String marketingStatus){this.marketingStatus = marketingStatus;}
public String getMarketingStatus(){return this.marketingStatus;} public String getMarketingStatus(){return this.marketingStatus;}
public void setMaxInvQty(String maxInvQty){this.maxInvQty = maxInvQty;}
public String getMaxInvQty(){return this.maxInvQty;}
@Override @Override
public String toString() { public String toString() {
return "InvItem{" + return "InvItem{" +
...@@ -603,6 +605,7 @@ public class InvItem implements Serializable { ...@@ -603,6 +605,7 @@ public class InvItem implements Serializable {
"rfid='" + rfid + '\'' + "rfid='" + rfid + '\'' +
"language='" + language + '\'' + "language='" + language + '\'' +
"marketingStatus='" + marketingStatus + '\'' + "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 { ...@@ -116,6 +116,9 @@ public class PurchaseServer {
public List<RcvReceiptLineV> selectRcvReceiptLineVByInvIdAndStatusAndHeaderId(List<String> invIds, String rcvReceiptLineStatus, String headerId) { public List<RcvReceiptLineV> selectRcvReceiptLineVByInvIdAndStatusAndHeaderId(List<String> invIds, String rcvReceiptLineStatus, String headerId) {
return rcvReceiptLineVMapper.selectByInvIdAndStatusAndHeaderId(invIds, rcvReceiptLineStatus, 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) { public List<RcvReceiptLineV> selectRcvReceiptLineVByUserNameAndHeaderIdInStatusRange(String userName, String statusFrom, String statusTo, String headerId) {
return rcvReceiptLineVMapper.selectByUserAndHeaderIdInStatusRange(userName, statusFrom, statusTo, 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 ...@@ -11,7 +11,10 @@ spring.messages.encoding=UTF-8
spring.datasource.driverClassName = com.mysql.jdbc.Driver 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://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.username = root
spring.datasource.password = 123456 spring.datasource.password = 123456
......
package orthopedics.test; package orthopedics.test;
import orthopedics.util.HttpUtil; import orthopedics.util.HttpUtil;
import orthopedics.util.IdWorker;
import orthopedics.util.MD5Util; import orthopedics.util.MD5Util;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set;
public class Demo { public class Demo {
public static void main(String[] args) { public static void main(String[] args) {
System.err.println("789"); Set s=new HashSet();
if(1 % 10000 == 0){ IdWorker id=new IdWorker();
System.err.println("123"); for (long i=0;i<10000000;i++){
s.add(id.nextId());
} }
System.err.println(s.size());
} }
......
package orthopedics.test; //package orthopedics.test;
//
import com.alibaba.fastjson.JSON; //import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; //import com.alibaba.fastjson.JSONObject;
import org.apache.ibatis.annotations.Update; //import org.apache.ibatis.annotations.Update;
import org.junit.Test; //import org.junit.Test;
import org.junit.runner.RunWith; //import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; //import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; //import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate; //import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.jdbc.core.JdbcTemplate; //import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.junit4.SpringRunner; //import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.web.bind.annotation.PostMapping; //import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam; //import org.springframework.web.bind.annotation.RequestParam;
import orthopedics.dao.*; //import orthopedics.dao.*;
import orthopedics.model.*; //import orthopedics.model.*;
import orthopedics.service.PropertiesServer; //import orthopedics.service.PropertiesServer;
import orthopedics.service.UserServer; //import orthopedics.service.UserServer;
import orthopedics.util.*; //import orthopedics.util.*;
//
import java.sql.*; //import java.sql.*;
import java.text.ParseException; //import java.text.ParseException;
import java.text.SimpleDateFormat; //import java.text.SimpleDateFormat;
import java.time.LocalDateTime; //import java.time.LocalDateTime;
import java.time.ZoneId; //import java.time.ZoneId;
import java.util.*; //import java.util.*;
import java.util.Date; //import java.util.Date;
//
/** ///**
* 将pmp的数据同步到erp临时表 // * 将pmp的数据同步到erp临时表
*/ // */
@RunWith(SpringRunner.class) //@RunWith(SpringRunner.class)
@SpringBootTest //@SpringBootTest
public class SyncPMPTest { //public class SyncPMPTest {
//
@Autowired // @Autowired
private UserServer userServer; // private UserServer userServer;
//
@Autowired // @Autowired
private RedisTemplate redisTemplate; // private RedisTemplate redisTemplate;
//
@Autowired // @Autowired
private PropertiesServer propertiesServer; // private PropertiesServer propertiesServer;
//
@Autowired // @Autowired
private SysUserDepartMapper sysUserDepartMapper; // private SysUserDepartMapper sysUserDepartMapper;
//
@Autowired // @Autowired
private InvItemMapper invItemMapper; // private InvItemMapper invItemMapper;
//
@Autowired // @Autowired
private InvItemSkuMapper invItemSkuMapper; // private InvItemSkuMapper invItemSkuMapper;
//
@Autowired // @Autowired
private InvItemAttributeMapper invItemAttributeMapper; // private InvItemAttributeMapper invItemAttributeMapper;
//
@Autowired // @Autowired
private InvItemPmpMapper invItemPmpMapper; // private InvItemPmpMapper invItemPmpMapper;
//
public static long getTimestamp() { // public static long getTimestamp() {
long milli = System.currentTimeMillis() + 8*3600*1000; // long milli = System.currentTimeMillis() + 8*3600*1000;
return (milli*10000)+621355968000000000L; // return (milli*10000)+621355968000000000L;
} // }
//
//
//
public Result getPMPInvItemTest(String access_token, String sta, String end) { // public Result getPMPInvItemTest(String access_token, String sta, String end) {
SysAccessToken sysAccessToken = userServer.checkToken(access_token); // SysAccessToken sysAccessToken = userServer.checkToken(access_token);
String gettoken = HttpUtilRSA.getToken(); // String gettoken = HttpUtilRSA.getToken();
if(StringUtil.isEmpty(gettoken)){ // if(StringUtil.isEmpty(gettoken)){
return new Result(false, StatusCode.ERROR,"获取PMP系统token失败"); // return new Result(false, StatusCode.ERROR,"获取PMP系统token失败");
} // }
JSONObject jsonObject = JSONObject.parseObject(gettoken); // JSONObject jsonObject = JSONObject.parseObject(gettoken);
String token = jsonObject.getString("Token"); // String token = jsonObject.getString("Token");
String tempEncryptKey = jsonObject.getString("TempEncryKey"); // String tempEncryptKey = jsonObject.getString("TempEncryKey");
//
JSONObject data=new JSONObject(); // JSONObject data=new JSONObject();
data.put("uniquekey","获取商品资料列表"); // data.put("uniquekey","获取商品资料列表");
data.put("timestamp", getTimestamp()); // data.put("timestamp", getTimestamp());
data.put("begintime",sta); // data.put("begintime",sta);
data.put("endTime",end); // data.put("endTime",end);
byte[] encrypt = Aes.encrypt(JSON.toJSONString(data), tempEncryptKey, tempEncryptKey); // byte[] encrypt = Aes.encrypt(JSON.toJSONString(data), tempEncryptKey, tempEncryptKey);
try { // try {
byte[] bytes = HttpUtilPMP.postBy("http://pmpapi.szcbfx.com/api/pmp/ExchangePMPData", encrypt,token); // byte[] bytes = HttpUtilPMP.postBy("http://pmpapi.szcbfx.com/api/pmp/ExchangePMPData", encrypt,token);
String s = new String(bytes); // String s = new String(bytes);
JSONObject object = JSONObject.parseObject(s); // JSONObject object = JSONObject.parseObject(s);
Object result = object.get("result"); // Object result = object.get("result");
if(result==null||!result.equals("success")){ // if(result==null||!result.equals("success")){
return new Result(false,StatusCode.ERROR,"获取商品信息失败"); // return new Result(false,StatusCode.ERROR,"获取商品信息失败");
} // }
List<JSONObject> retMsg= (List<JSONObject>) object.get("ret_msg"); // List<JSONObject> retMsg= (List<JSONObject>) object.get("ret_msg");
for (JSONObject item:retMsg) { // for (JSONObject item:retMsg) {
//检测是否是重复数据 // //检测是否是重复数据
String plucode = item.getString("PLUCODE"); // String plucode = item.getString("PLUCODE");
if(StringUtil.isEmpty(plucode)){ // if(StringUtil.isEmpty(plucode)){
continue; // continue;
} // }
List<InvItem> invItems = invItemMapper.selectByPlucode(plucode); // List<InvItem> invItems = invItemMapper.selectByPlucode(plucode);
if(invItems!=null&&invItems.size()>0){ // if(invItems!=null&&invItems.size()>0){
continue; // continue;
} // }
InvItem invItem=new InvItem(); // InvItem invItem=new InvItem();
InvItemAttribute invItemAttribute=new InvItemAttribute(); // InvItemAttribute invItemAttribute=new InvItemAttribute();
InvItemSku invItemSku=new InvItemSku(); // InvItemSku invItemSku=new InvItemSku();
InvItemPmp invItemPmp=new InvItemPmp(); // InvItemPmp invItemPmp=new InvItemPmp();
//商品表 // //商品表
invItem.setId(UuidUtil.get32UUIDString()); // invItem.setId(UuidUtil.get32UUIDString());
invItem.setOrgId("964daee94b604cd58e5e6bf48dd9670a"); // invItem.setOrgId("964daee94b604cd58e5e6bf48dd9670a");
invItem.setStatus("SALE"); // invItem.setStatus("SALE");
String itemCode = propertiesServer.generateFlowingWater("ITEM_SERIAL"); // String itemCode = propertiesServer.generateFlowingWater("ITEM_SERIAL");
if(StringUtil.isEmpty(itemCode)){ // if(StringUtil.isEmpty(itemCode)){
invItem.setItemCode(UuidUtil.get32UUIDString()); // invItem.setItemCode(UuidUtil.get32UUIDString());
}else{ // }else{
invItem.setItemCode(itemCode); // invItem.setItemCode(itemCode);
} // }
invItem.setItemName(item.getString("TITLE")); // invItem.setItemName(item.getString("TITLE"));
invItem.setProType("14"); // invItem.setProType("14");
invItem.setItemDesc(item.getString("JP")); // invItem.setItemDesc(item.getString("JP"));
invItem.setPystype(item.getString("PYSTYPE")); // invItem.setPystype(item.getString("PYSTYPE"));
invItem.setIsbn(item.getString("ISBN")); // invItem.setIsbn(item.getString("ISBN"));
invItem.setPlucode(item.getString("PLUCODE")); // invItem.setPlucode(item.getString("PLUCODE"));
invItem.setScancode(item.getString("SCANCODE")); // invItem.setScancode(item.getString("SCANCODE"));
invItem.setExtcode("0"); // invItem.setExtcode("0");
invItem.setPurchasePrice(item.getString("PRICE")); // invItem.setPurchasePrice(item.getString("PRICE"));
invItem.setGeneralName(item.getString("CLSCODE")); // invItem.setGeneralName(item.getString("CLSCODE"));
invItem.setManufacturerId(item.getString("PUBLISHER")); // invItem.setManufacturerId(item.getString("PUBLISHER"));
if(!StringUtil.isEmpty(item.getDate("PUBDATE"))){ // if(!StringUtil.isEmpty(item.getDate("PUBDATE"))){
invItem.setSpecification(item.getDate("PUBDATE").toInstant() // invItem.setSpecification(item.getDate("PUBDATE").toInstant()
.atZone( ZoneId.systemDefault() ) // .atZone( ZoneId.systemDefault() )
.toLocalDateTime()); // .toLocalDateTime());
} // }
invItem.setPrimaryUnit("BEN"); // invItem.setPrimaryUnit("BEN");
if(item.getString("PYSTYPE").equals("0")||item.getString("PYSTYPE").equals("4")){ // if(item.getString("PYSTYPE").equals("0")||item.getString("PYSTYPE").equals("4")){
invItem.setAttribute1("Book"); // invItem.setAttribute1("Book");
invItem.setIsBorrow("Y"); // invItem.setIsBorrow("Y");
}else{ // }else{
invItem.setAttribute1("Goods"); // invItem.setAttribute1("Goods");
invItem.setIsBorrow("N"); // invItem.setIsBorrow("N");
} // }
invItem.setAttribute2("A"); // invItem.setAttribute2("A");
invItem.setTax(item.getString("INCTAX")); // invItem.setTax(item.getString("INCTAX"));
invItem.setDefaultVendorId("000000006c60dba1016c60f839270004"); // invItem.setDefaultVendorId("000000006c60dba1016c60f839270004");
invItem.setCreateBy(sysAccessToken.getUserName()); // invItem.setCreateBy(sysAccessToken.getUserName());
invItem.setCreateTime(LocalDateTime.now()); // invItem.setCreateTime(LocalDateTime.now());
//查询当前用户部门 // //查询当前用户部门
SysUserDepart sysUserDepart = sysUserDepartMapper.selectByUserId(sysAccessToken.getUserId()); // SysUserDepart sysUserDepart = sysUserDepartMapper.selectByUserId(sysAccessToken.getUserId());
//
//图书信息 // //图书信息
invItemAttribute.setId(UuidUtil.get32UUIDString()); // invItemAttribute.setId(UuidUtil.get32UUIDString());
invItemAttribute.setCreateBy(sysAccessToken.getUserName()); // invItemAttribute.setCreateBy(sysAccessToken.getUserName());
invItemAttribute.setCreateTime(LocalDateTime.now()); // invItemAttribute.setCreateTime(LocalDateTime.now());
if(sysUserDepart!=null){ // if(sysUserDepart!=null){
invItemAttribute.setSysOrgCode(sysUserDepart.getDepId()); // invItemAttribute.setSysOrgCode(sysUserDepart.getDepId());
} // }
invItemAttribute.setItemId(invItem.getId()); // invItemAttribute.setItemId(invItem.getId());
invItemAttribute.setItemCode(invItem.getItemCode()); // invItemAttribute.setItemCode(invItem.getItemCode());
invItemAttribute.setAuthor(item.getString("AUTHOR")); // invItemAttribute.setAuthor(item.getString("AUTHOR"));
invItemAttribute.setReader(item.getString("READER")); // invItemAttribute.setReader(item.getString("READER"));
//
//
//商品SKU映射 // //商品SKU映射
invItemSku.setId(UuidUtil.get32UUIDString()); // invItemSku.setId(UuidUtil.get32UUIDString());
if(sysUserDepart!=null){ // if(sysUserDepart!=null){
invItemSku.setSysOrgCode(sysUserDepart.getDepId()); // invItemSku.setSysOrgCode(sysUserDepart.getDepId());
} // }
invItemSku.setOrgId("964daee94b604cd58e5e6bf48dd9670a"); // invItemSku.setOrgId("964daee94b604cd58e5e6bf48dd9670a");
invItemSku.setExternal("PMP"); // invItemSku.setExternal("PMP");
invItemSku.setItemSku(item.getString("PLUCODE")); // invItemSku.setItemSku(item.getString("PLUCODE"));
invItemSku.setItemName(invItem.getItemName()); // invItemSku.setItemName(invItem.getItemName());
invItemSku.setItemCode(invItem.getItemCode()); // invItemSku.setItemCode(invItem.getItemCode());
invItemSku.setItemDesc(invItem.getItemDesc()); // invItemSku.setItemDesc(invItem.getItemDesc());
invItemSku.setStatus("A"); // invItemSku.setStatus("A");
invItemSku.setCreateBy(sysAccessToken.getUserName()); // invItemSku.setCreateBy(sysAccessToken.getUserName());
invItemSku.setCreateTime(LocalDateTime.now()); // invItemSku.setCreateTime(LocalDateTime.now());
//
//pmp商品缓存表 // //pmp商品缓存表
invItemPmp.setId(UuidUtil.get32UUIDString()); // invItemPmp.setId(UuidUtil.get32UUIDString());
invItemPmp.setPlucode(item.getString("PLUCODE")); // invItemPmp.setPlucode(item.getString("PLUCODE"));
invItemPmp.setPystype(item.getInteger("PYSTYPE")); // invItemPmp.setPystype(item.getInteger("PYSTYPE"));
invItemPmp.setIsbn(item.getString("ISBN")); // invItemPmp.setIsbn(item.getString("ISBN"));
invItemPmp.setScancode(item.getString("SCANCODE")); // invItemPmp.setScancode(item.getString("SCANCODE"));
invItemPmp.setTitle(item.getString("TITLE")); // invItemPmp.setTitle(item.getString("TITLE"));
invItemPmp.setJp(item.getString("JP")); // invItemPmp.setJp(item.getString("JP"));
invItemPmp.setPrice(item.getBigDecimal("PRICE")); // invItemPmp.setPrice(item.getBigDecimal("PRICE"));
invItemPmp.setClscode(item.getString("CLSCODE")); // invItemPmp.setClscode(item.getString("CLSCODE"));
invItemPmp.setClsname(item.getString("CLSNAME")); // invItemPmp.setClsname(item.getString("CLSNAME"));
invItemPmp.setPublisher(item.getString("PUBLISHER")); // invItemPmp.setPublisher(item.getString("PUBLISHER"));
invItemPmp.setPubname(item.getString("PUBNAME")); // invItemPmp.setPubname(item.getString("PUBNAME"));
if(!StringUtil.isEmpty(item.getDate("PUBDATE"))){ // if(!StringUtil.isEmpty(item.getDate("PUBDATE"))){
invItemPmp.setPubdate(item.getDate("PUBDATE").toInstant() // invItemPmp.setPubdate(item.getDate("PUBDATE").toInstant()
.atZone( ZoneId.systemDefault() ) // .atZone( ZoneId.systemDefault() )
.toLocalDateTime()); // .toLocalDateTime());
} // }
invItemPmp.setDptcode(item.getString("DPTCODE")); // invItemPmp.setDptcode(item.getString("DPTCODE"));
invItemPmp.setDptname(item.getString("DPTNAME")); // invItemPmp.setDptname(item.getString("DPTNAME"));
invItemPmp.setSeries(item.getString("SERIES")); // invItemPmp.setSeries(item.getString("SERIES"));
invItemPmp.setAuthor(item.getString("AUTHOR")); // invItemPmp.setAuthor(item.getString("AUTHOR"));
invItemPmp.setReader(item.getString("READER")); // invItemPmp.setReader(item.getString("READER"));
if(!StringUtil.isEmpty(item.getDate("FSTDATE"))){ // if(!StringUtil.isEmpty(item.getDate("FSTDATE"))){
invItemPmp.setFstdate(item.getDate("FSTDATE").toInstant() // invItemPmp.setFstdate(item.getDate("FSTDATE").toInstant()
.atZone( ZoneId.systemDefault() ) // .atZone( ZoneId.systemDefault() )
.toLocalDateTime()); // .toLocalDateTime());
} // }
invItemPmp.setFstdisc(item.getBigDecimal("FSTDISC")); // invItemPmp.setFstdisc(item.getBigDecimal("FSTDISC"));
invItemPmp.setLstdisc(item.getBigDecimal("LSTDISC")); // invItemPmp.setLstdisc(item.getBigDecimal("LSTDISC"));
invItemPmp.setMaxdisc(item.getBigDecimal("MAXDISC")); // invItemPmp.setMaxdisc(item.getBigDecimal("MAXDISC"));
invItemPmp.setMindisc(item.getBigDecimal("MINDISC")); // invItemPmp.setMindisc(item.getBigDecimal("MINDISC"));
invItemPmp.setVendor(item.getString("VENDOR")); // invItemPmp.setVendor(item.getString("VENDOR"));
invItemPmp.setTranstitle(item.getString("TRANSTITLE")); // invItemPmp.setTranstitle(item.getString("TRANSTITLE"));
invItemPmp.setInctax(item.getInteger("INCTAX")); // invItemPmp.setInctax(item.getInteger("INCTAX"));
invItemPmp.setOriginprice(item.getBigDecimal("ORIGINPRICE")); // invItemPmp.setOriginprice(item.getBigDecimal("ORIGINPRICE"));
invItemPmp.setCurrency(item.getString("CURRENCY")); // invItemPmp.setCurrency(item.getString("CURRENCY"));
invItemPmp.setStatus(1); // invItemPmp.setStatus(1);
invItemMapper.insert(invItem); // invItemMapper.insert(invItem);
invItemSkuMapper.insert(invItemSku); // invItemSkuMapper.insert(invItemSku);
invItemAttributeMapper.insert(invItemAttribute); // invItemAttributeMapper.insert(invItemAttribute);
invItemPmpMapper.insert(invItemPmp); // invItemPmpMapper.insert(invItemPmp);
} // }
return new Result(true,StatusCode.OK,"获取商品信息成功"); // return new Result(true,StatusCode.OK,"获取商品信息成功");
} catch (Exception e) { // } catch (Exception e) {
//
} // }
return new Result(false,StatusCode.ERROR,"获取商品信息失败"); // return new Result(false,StatusCode.ERROR,"获取商品信息失败");
} // }
//
//获取一年后的时间 // //获取一年后的时间
public String getDate1(String str) throws ParseException { // public String getDate1(String str) throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date parse = sdf.parse(str); // Date parse = sdf.parse(str);
Calendar cal = Calendar.getInstance(); // Calendar cal = Calendar.getInstance();
cal.setTime(parse); // cal.setTime(parse);
cal.add(Calendar.DATE, 10);//增加5年 // cal.add(Calendar.DATE, 10);//增加5年
return sdf.format(cal.getTime()); // return sdf.format(cal.getTime());
} // }
//
//
/** // /**
* 获取pmp商品同步到临时表 // * 获取pmp商品同步到临时表
*/ // */
@Autowired // @Autowired
private TempItemFomPmpMapper tempItemFomPmpMapper; // private TempItemFomPmpMapper tempItemFomPmpMapper;
//
@Test // @Test
public void getPMPHistoryInvItem(){ // public void getPMPHistoryInvItem(){
String sta = null; // String sta = null;
String end = null; // String end = null;
String begintime= (String) redisTemplate.opsForValue().get("getPMPInvItem"); // String begintime= (String) redisTemplate.opsForValue().get("getPMPInvItem");
SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" ); // SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" );
if(StringUtil.isEmpty(begintime)){ // if(StringUtil.isEmpty(begintime)){
sta = "1995-1-1 00:00:00"; // sta = "1995-1-1 00:00:00";
}else{ // }else{
sta = begintime; // sta = begintime;
} // }
//
try { // try {
Date parse = sdf.parse(sta); // Date parse = sdf.parse(sta);
long time = parse.getTime(); // long time = parse.getTime();
while (time<=new Date().getTime()){ // while (time<=new Date().getTime()){
end = getDate1(sta); // end = getDate1(sta);
String gettoken = HttpUtilRSA.getToken(); // String gettoken = HttpUtilRSA.getToken();
JSONObject jsonObject = JSONObject.parseObject(gettoken); // JSONObject jsonObject = JSONObject.parseObject(gettoken);
String token = jsonObject.getString("Token"); // String token = jsonObject.getString("Token");
String tempEncryptKey = jsonObject.getString("TempEncryKey"); // String tempEncryptKey = jsonObject.getString("TempEncryKey");
//
JSONObject data=new JSONObject(); // JSONObject data=new JSONObject();
data.put("uniquekey","获取商品资料列表"); // data.put("uniquekey","获取商品资料列表");
data.put("timestamp", getTimestamp()); // data.put("timestamp", getTimestamp());
data.put("begintime",sta); // data.put("begintime",sta);
data.put("endTime",end); // data.put("endTime",end);
byte[] encrypt = Aes.encrypt(JSON.toJSONString(data), tempEncryptKey, tempEncryptKey); // byte[] encrypt = Aes.encrypt(JSON.toJSONString(data), tempEncryptKey, tempEncryptKey);
byte[] bytes = HttpUtilPMP.postBy("http://pmpapi.szcbfx.com/api/pmp/ExchangePMPData", encrypt,token); // byte[] bytes = HttpUtilPMP.postBy("http://pmpapi.szcbfx.com/api/pmp/ExchangePMPData", encrypt,token);
String s = new String(bytes); // String s = new String(bytes);
JSONObject object = JSONObject.parseObject(s); // JSONObject object = JSONObject.parseObject(s);
List<JSONObject> retMsg= (List<JSONObject>) object.get("ret_msg"); // List<JSONObject> retMsg= (List<JSONObject>) object.get("ret_msg");
System.err.println(sta+"获取到"+retMsg.size()+"条商品"); // System.err.println(sta+"获取到"+retMsg.size()+"条商品");
if(retMsg.size()<=0){ // if(retMsg.size()<=0){
redisTemplate.opsForValue().set("getPMPInvItem",end); // redisTemplate.opsForValue().set("getPMPInvItem",end);
System.err.println(sta+"同步了"+retMsg.size()+"条商品"); // System.err.println(sta+"同步了"+retMsg.size()+"条商品");
sta = end; // sta = end;
continue; // continue;
} // }
List<TempItemFomPmp> tempItemFomPmpList=new ArrayList<>(); // List<TempItemFomPmp> tempItemFomPmpList=new ArrayList<>();
for (JSONObject item:retMsg){ // for (JSONObject item:retMsg){
TempItemFomPmp invItemPmp=new TempItemFomPmp(); // TempItemFomPmp invItemPmp=new TempItemFomPmp();
//pmp商品缓存表 // //pmp商品缓存表
invItemPmp.setId(UuidUtil.get32UUIDString()); // invItemPmp.setId(UuidUtil.get32UUIDString());
invItemPmp.setPlucode(item.getString("PLUCODE")); // invItemPmp.setPlucode(item.getString("PLUCODE"));
invItemPmp.setPystype(item.getInteger("PYSTYPE")); // invItemPmp.setPystype(item.getInteger("PYSTYPE"));
invItemPmp.setIsbn(item.getString("ISBN")); // invItemPmp.setIsbn(item.getString("ISBN"));
invItemPmp.setScancode(item.getString("SCANCODE")); // invItemPmp.setScancode(item.getString("SCANCODE"));
invItemPmp.setTitle(item.getString("TITLE")); // invItemPmp.setTitle(item.getString("TITLE"));
invItemPmp.setJp(item.getString("JP")); // invItemPmp.setJp(item.getString("JP"));
invItemPmp.setPrice(item.getBigDecimal("PRICE")); // invItemPmp.setPrice(item.getBigDecimal("PRICE"));
invItemPmp.setClscode(item.getString("CLSCODE")); // invItemPmp.setClscode(item.getString("CLSCODE"));
invItemPmp.setClsname(item.getString("CLSNAME")); // invItemPmp.setClsname(item.getString("CLSNAME"));
invItemPmp.setPublisher(item.getString("PUBLISHER")); // invItemPmp.setPublisher(item.getString("PUBLISHER"));
invItemPmp.setPubname(item.getString("PUBNAME")); // invItemPmp.setPubname(item.getString("PUBNAME"));
if(!StringUtil.isEmpty(item.getDate("PUBDATE"))){ // if(!StringUtil.isEmpty(item.getDate("PUBDATE"))){
invItemPmp.setPubdate(item.getDate("PUBDATE").toInstant() // invItemPmp.setPubdate(item.getDate("PUBDATE").toInstant()
.atZone( ZoneId.systemDefault() ) // .atZone( ZoneId.systemDefault() )
.toLocalDateTime()); // .toLocalDateTime());
} // }
invItemPmp.setDptcode(item.getString("DPTCODE")); // invItemPmp.setDptcode(item.getString("DPTCODE"));
invItemPmp.setDptname(item.getString("DPTNAME")); // invItemPmp.setDptname(item.getString("DPTNAME"));
invItemPmp.setSeries(item.getString("SERIES")); // invItemPmp.setSeries(item.getString("SERIES"));
invItemPmp.setAuthor(item.getString("AUTHOR")); // invItemPmp.setAuthor(item.getString("AUTHOR"));
invItemPmp.setReader(item.getString("READER")); // invItemPmp.setReader(item.getString("READER"));
if(!StringUtil.isEmpty(item.getDate("FSTDATE"))){ // if(!StringUtil.isEmpty(item.getDate("FSTDATE"))){
invItemPmp.setFstdate(item.getDate("FSTDATE").toInstant() // invItemPmp.setFstdate(item.getDate("FSTDATE").toInstant()
.atZone( ZoneId.systemDefault() ) // .atZone( ZoneId.systemDefault() )
.toLocalDateTime()); // .toLocalDateTime());
} // }
invItemPmp.setFstdisc(item.getBigDecimal("FSTDISC")); // invItemPmp.setFstdisc(item.getBigDecimal("FSTDISC"));
invItemPmp.setLstdisc(item.getBigDecimal("LSTDISC")); // invItemPmp.setLstdisc(item.getBigDecimal("LSTDISC"));
invItemPmp.setMaxdisc(item.getBigDecimal("MAXDISC")); // invItemPmp.setMaxdisc(item.getBigDecimal("MAXDISC"));
invItemPmp.setMindisc(item.getBigDecimal("MINDISC")); // invItemPmp.setMindisc(item.getBigDecimal("MINDISC"));
invItemPmp.setVendor(item.getString("VENDOR")); // invItemPmp.setVendor(item.getString("VENDOR"));
invItemPmp.setTranstitle(item.getString("TRANSTITLE")); // invItemPmp.setTranstitle(item.getString("TRANSTITLE"));
invItemPmp.setInctax(item.getInteger("INCTAX")); // invItemPmp.setInctax(item.getInteger("INCTAX"));
invItemPmp.setOriginprice(item.getBigDecimal("ORIGINPRICE")); // invItemPmp.setOriginprice(item.getBigDecimal("ORIGINPRICE"));
invItemPmp.setCurrency(item.getString("CURRENCY")); // invItemPmp.setCurrency(item.getString("CURRENCY"));
invItemPmp.setStatus(1); // invItemPmp.setStatus(1);
tempItemFomPmpList.add(invItemPmp); // tempItemFomPmpList.add(invItemPmp);
// if(i % 10000 == 0){ //// if(i % 10000 == 0){
//// tempItemFomPmpMapper.insertBatch(tempItemFomPmpList);
//// System.err.println("同步了"+i+"条商品");
//// tempItemFomPmpList.clear();
//// }
// }
// tempItemFomPmpMapper.insertBatch(tempItemFomPmpList); // tempItemFomPmpMapper.insertBatch(tempItemFomPmpList);
// System.err.println("同步了"+i+"条商品"); //// getPMPInvItemTest(access_token,sta,end);
// tempItemFomPmpList.clear(); //
// } // redisTemplate.opsForValue().set("getPMPInvItem",end);
} // System.err.println(sta+"同步了"+retMsg.size()+"条商品");
tempItemFomPmpMapper.insertBatch(tempItemFomPmpList); // sta = end;
// getPMPInvItemTest(access_token,sta,end); //
// }
redisTemplate.opsForValue().set("getPMPInvItem",end); // }catch (Exception e){
System.err.println(sta+"同步了"+retMsg.size()+"条商品"); // //logger.error("pmp同步失败时间段"+sta+"---"+end);
sta = end; // System.err.println(e.getMessage());
// System.err.println("pmp同步失败时间段"+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仓号同步到临时表
@Autowired // */
private TempInventoryFomPmpMapper tempInventoryFomPmpMapper; // @Test
// public void tempInventoryFomPmp(){
/** // String gettoken = HttpUtilRSA.getToken();
* 获取pmp仓号同步到临时表 // System.err.println(gettoken);
*/ // String token = (String) JSONObject.parseObject(gettoken).get("Token");
@Test // String tempEncryptKey = (String) JSONObject.parseObject(gettoken).get("TempEncryKey");
public void tempInventoryFomPmp(){ // JSONObject data=new JSONObject();
String gettoken = HttpUtilRSA.getToken(); // data.put("uniquekey","获取仓号列表");
System.err.println(gettoken); // data.put("timestamp", getTimestamp());
String token = (String) JSONObject.parseObject(gettoken).get("Token"); // System.err.println(new Date());
String tempEncryptKey = (String) JSONObject.parseObject(gettoken).get("TempEncryKey"); // //data.put("begintime","1995-12-23 00:00:00");
JSONObject data=new JSONObject(); //// data.put("begintime","2015-01-11 18:00:00");
data.put("uniquekey","获取仓号列表"); //// data.put("endTime","2020-06-12 18:00:00");
data.put("timestamp", getTimestamp()); // Map headers=new HashMap();
System.err.println(new Date()); // headers.put("Content-Type","application/json");
//data.put("begintime","1995-12-23 00:00:00"); // headers.put("token",token);
// data.put("begintime","2015-01-11 18:00:00"); // byte[] encrypt = Aes.encrypt(JSON.toJSONString(data), tempEncryptKey, tempEncryptKey);
// data.put("endTime","2020-06-12 18:00:00"); // byte[] bytes = new byte[0];
Map headers=new HashMap(); // try {
headers.put("Content-Type","application/json"); // bytes = HttpUtilPMP.postBy("http://pmpapi.szcbfx.com/api/pmp/ExchangePMPData", encrypt,token);
headers.put("token",token); // } catch (Exception e) {
byte[] encrypt = Aes.encrypt(JSON.toJSONString(data), tempEncryptKey, tempEncryptKey); // e.printStackTrace();
byte[] bytes = new byte[0]; // }
try { // //String post = HttpUtilPMP.post("http://pmpapi.szcbfx.com/api/pmp/ExchangePMPData", data, headers, 6000, 6000, "utf-8",tempEncryptKey);
bytes = HttpUtilPMP.postBy("http://pmpapi.szcbfx.com/api/pmp/ExchangePMPData", encrypt,token); // String s = new String(bytes);
} catch (Exception e) { // JSONObject object = JSONObject.parseObject(s);
e.printStackTrace(); // List<JSONObject> retMsg= (List<JSONObject>) object.get("ret_msg");
} //
//String post = HttpUtilPMP.post("http://pmpapi.szcbfx.com/api/pmp/ExchangePMPData", data, headers, 6000, 6000, "utf-8",tempEncryptKey); // System.err.println(retMsg);
String s = new String(bytes); // System.err.println(retMsg.size());
JSONObject object = JSONObject.parseObject(s); // List<TempInventoryFomPmp> tempInventoryFomPmpList=new ArrayList<>();
List<JSONObject> retMsg= (List<JSONObject>) object.get("ret_msg"); // for(JSONObject jsonObject:retMsg){
// TempInventoryFomPmp tempInventoryFomPmp=new TempInventoryFomPmp();
System.err.println(retMsg); // String code = jsonObject.getString("code");
System.err.println(retMsg.size()); // String descript = jsonObject.getString("descript");
List<TempInventoryFomPmp> tempInventoryFomPmpList=new ArrayList<>(); // tempInventoryFomPmp.setId(UuidUtil.get32UUIDString());
for(JSONObject jsonObject:retMsg){ // tempInventoryFomPmp.setCode(code);
TempInventoryFomPmp tempInventoryFomPmp=new TempInventoryFomPmp(); // tempInventoryFomPmp.setDescript(descript);
String code = jsonObject.getString("code"); // tempInventoryFomPmpList.add(tempInventoryFomPmp);
String descript = jsonObject.getString("descript"); // }
tempInventoryFomPmp.setId(UuidUtil.get32UUIDString()); //
tempInventoryFomPmp.setCode(code); // tempInventoryFomPmpMapper.insertBatch(tempInventoryFomPmpList);
tempInventoryFomPmp.setDescript(descript); // }
tempInventoryFomPmpList.add(tempInventoryFomPmp); //
} //
// @Autowired
tempInventoryFomPmpMapper.insertBatch(tempInventoryFomPmpList); // private TempLocatorFomPmpMapper tempLocatorFomPmpMapper;
} // /**
// * 获取pmp货架号同步到临时表
// */
@Autowired // @Test
private TempLocatorFomPmpMapper tempLocatorFomPmpMapper; // public void tempLocatorFomPmp(){
/** // String gettoken = HttpUtilRSA.getToken();
* 获取pmp货架号同步到临时表 // System.err.println(gettoken);
*/ // String token = (String) JSONObject.parseObject(gettoken).get("Token");
@Test // String tempEncryptKey = (String) JSONObject.parseObject(gettoken).get("TempEncryKey");
public void tempLocatorFomPmp(){ // JSONObject data=new JSONObject();
String gettoken = HttpUtilRSA.getToken(); // data.put("uniquekey","获取架号列表");
System.err.println(gettoken); // data.put("timestamp", getTimestamp());
String token = (String) JSONObject.parseObject(gettoken).get("Token"); // System.err.println(new Date());
String tempEncryptKey = (String) JSONObject.parseObject(gettoken).get("TempEncryKey"); // //data.put("begintime","1995-12-23 00:00:00");
JSONObject data=new JSONObject(); //// data.put("begintime","2015-01-11 18:00:00");
data.put("uniquekey","获取架号列表"); //// data.put("endTime","2020-06-12 18:00:00");
data.put("timestamp", getTimestamp()); // Map headers=new HashMap();
System.err.println(new Date()); // headers.put("Content-Type","application/json");
//data.put("begintime","1995-12-23 00:00:00"); // headers.put("token",token);
// data.put("begintime","2015-01-11 18:00:00"); // byte[] encrypt = Aes.encrypt(JSON.toJSONString(data), tempEncryptKey, tempEncryptKey);
// data.put("endTime","2020-06-12 18:00:00"); // byte[] bytes = new byte[0];
Map headers=new HashMap(); // try {
headers.put("Content-Type","application/json"); // bytes = HttpUtilPMP.postBy("http://pmpapi.szcbfx.com/api/pmp/ExchangePMPData", encrypt,token);
headers.put("token",token); // } catch (Exception e) {
byte[] encrypt = Aes.encrypt(JSON.toJSONString(data), tempEncryptKey, tempEncryptKey); // e.printStackTrace();
byte[] bytes = new byte[0]; // }
try { // //String post = HttpUtilPMP.post("http://pmpapi.szcbfx.com/api/pmp/ExchangePMPData", data, headers, 6000, 6000, "utf-8",tempEncryptKey);
bytes = HttpUtilPMP.postBy("http://pmpapi.szcbfx.com/api/pmp/ExchangePMPData", encrypt,token); // String s = new String(bytes);
} catch (Exception e) { // JSONObject object = JSONObject.parseObject(s);
e.printStackTrace(); // List<JSONObject> retMsg= (List<JSONObject>) object.get("ret_msg");
} //
//String post = HttpUtilPMP.post("http://pmpapi.szcbfx.com/api/pmp/ExchangePMPData", data, headers, 6000, 6000, "utf-8",tempEncryptKey); // System.err.println(retMsg);
String s = new String(bytes); // System.err.println(retMsg.size());
JSONObject object = JSONObject.parseObject(s); // List<TempLocatorFomPmp> tempInventoryFomPmpList=new ArrayList<>();
List<JSONObject> retMsg= (List<JSONObject>) object.get("ret_msg"); // for(JSONObject jsonObject:retMsg){
// TempLocatorFomPmp tempLocatorFomPmp=new TempLocatorFomPmp();
System.err.println(retMsg); // String code = jsonObject.getString("code");
System.err.println(retMsg.size()); // String wh = jsonObject.getString("wh");
List<TempLocatorFomPmp> tempInventoryFomPmpList=new ArrayList<>(); // tempLocatorFomPmp.setId(UuidUtil.get32UUIDString());
for(JSONObject jsonObject:retMsg){ // tempLocatorFomPmp.setCode(code);
TempLocatorFomPmp tempLocatorFomPmp=new TempLocatorFomPmp(); // tempLocatorFomPmp.setWh(wh);
String code = jsonObject.getString("code"); // tempInventoryFomPmpList.add(tempLocatorFomPmp);
String wh = jsonObject.getString("wh"); // }
tempLocatorFomPmp.setId(UuidUtil.get32UUIDString()); //
tempLocatorFomPmp.setCode(code); // tempLocatorFomPmpMapper.insertBatch(tempInventoryFomPmpList);
tempLocatorFomPmp.setWh(wh); // }
tempInventoryFomPmpList.add(tempLocatorFomPmp); //
} // @Autowired
// private TempAreaFomPmpMapper tempAreaFomPmpMapper;
tempLocatorFomPmpMapper.insertBatch(tempInventoryFomPmpList); // /**
} // * 获取pmp区域同步到临时表
// */
@Autowired // @Test
private TempAreaFomPmpMapper tempAreaFomPmpMapper; // public void tempAreaFomPmp(){
/** // String gettoken = HttpUtilRSA.getToken();
* 获取pmp区域同步到临时表 // System.err.println(gettoken);
*/ // String token = (String) JSONObject.parseObject(gettoken).get("Token");
@Test // String tempEncryptKey = (String) JSONObject.parseObject(gettoken).get("TempEncryKey");
public void tempAreaFomPmp(){ // JSONObject data=new JSONObject();
String gettoken = HttpUtilRSA.getToken(); // data.put("uniquekey","获取区域列表");
System.err.println(gettoken); // data.put("timestamp", getTimestamp());
String token = (String) JSONObject.parseObject(gettoken).get("Token"); // System.err.println(new Date());
String tempEncryptKey = (String) JSONObject.parseObject(gettoken).get("TempEncryKey"); // //data.put("begintime","1995-12-23 00:00:00");
JSONObject data=new JSONObject(); //// data.put("begintime","2015-01-11 18:00:00");
data.put("uniquekey","获取区域列表"); //// data.put("endTime","2020-06-12 18:00:00");
data.put("timestamp", getTimestamp()); // Map headers=new HashMap();
System.err.println(new Date()); // headers.put("Content-Type","application/json");
//data.put("begintime","1995-12-23 00:00:00"); // headers.put("token",token);
// data.put("begintime","2015-01-11 18:00:00"); // byte[] encrypt = Aes.encrypt(JSON.toJSONString(data), tempEncryptKey, tempEncryptKey);
// data.put("endTime","2020-06-12 18:00:00"); // byte[] bytes = new byte[0];
Map headers=new HashMap(); // try {
headers.put("Content-Type","application/json"); // bytes = HttpUtilPMP.postBy("http://pmpapi.szcbfx.com/api/pmp/ExchangePMPData", encrypt,token);
headers.put("token",token); // } catch (Exception e) {
byte[] encrypt = Aes.encrypt(JSON.toJSONString(data), tempEncryptKey, tempEncryptKey); // e.printStackTrace();
byte[] bytes = new byte[0]; // }
try { // //String post = HttpUtilPMP.post("http://pmpapi.szcbfx.com/api/pmp/ExchangePMPData", data, headers, 6000, 6000, "utf-8",tempEncryptKey);
bytes = HttpUtilPMP.postBy("http://pmpapi.szcbfx.com/api/pmp/ExchangePMPData", encrypt,token); // String s = new String(bytes);
} catch (Exception e) { // JSONObject object = JSONObject.parseObject(s);
e.printStackTrace(); // List<JSONObject> retMsg= (List<JSONObject>) object.get("ret_msg");
} //
//String post = HttpUtilPMP.post("http://pmpapi.szcbfx.com/api/pmp/ExchangePMPData", data, headers, 6000, 6000, "utf-8",tempEncryptKey); // System.err.println(retMsg);
String s = new String(bytes); // System.err.println(retMsg.size());
JSONObject object = JSONObject.parseObject(s); // List<TempAreaFomPmp> tempInventoryFomPmpList=new ArrayList<>();
List<JSONObject> retMsg= (List<JSONObject>) object.get("ret_msg"); // for(JSONObject jsonObject:retMsg){
// TempAreaFomPmp tempAreaFomPmp=new TempAreaFomPmp();
System.err.println(retMsg); // String subwh = jsonObject.getString("subwh");
System.err.println(retMsg.size()); // String wh = jsonObject.getString("wh");
List<TempAreaFomPmp> tempInventoryFomPmpList=new ArrayList<>(); // String descript = jsonObject.getString("descript");
for(JSONObject jsonObject:retMsg){ // tempAreaFomPmp.setId(UuidUtil.get32UUIDString());
TempAreaFomPmp tempAreaFomPmp=new TempAreaFomPmp(); // tempAreaFomPmp.setSubwh(subwh);
String subwh = jsonObject.getString("subwh"); // tempAreaFomPmp.setWh(wh);
String wh = jsonObject.getString("wh"); // tempAreaFomPmp.setDescript(descript);
String descript = jsonObject.getString("descript"); // tempInventoryFomPmpList.add(tempAreaFomPmp);
tempAreaFomPmp.setId(UuidUtil.get32UUIDString()); // }
tempAreaFomPmp.setSubwh(subwh); //
tempAreaFomPmp.setWh(wh); // tempAreaFomPmpMapper.insertBatch(tempInventoryFomPmpList);
tempAreaFomPmp.setDescript(descript); // }
tempInventoryFomPmpList.add(tempAreaFomPmp); //
} // /**
// * 将ERP创建的商品同步到POS
tempAreaFomPmpMapper.insertBatch(tempInventoryFomPmpList); // */
} // @Test
// public void invItemsToPos(){
/** // List<InvItem> invItems = invItemMapper.findByAttribute2();
* 将ERP创建的商品同步到POS // if(invItems!=null && invItems.size()>0){
*/ // Connection ct=null;
@Test // PreparedStatement ps=null;
public void invItemsToPos(){ // ResultSet rs=null;
List<InvItem> invItems = invItemMapper.findByAttribute2(); // try {
if(invItems!=null && invItems.size()>0){ // Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection ct=null; // ct= DriverManager.getConnection("jdbc:sqlserver://130.1.0.32:1433;DatabaseName=shoptxns","wjkj","wjkj123456");
PreparedStatement ps=null; // for (InvItem invItem:invItems) {
ResultSet rs=null; // ps=ct.prepareStatement("insert into plu values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
try { // ps.setString(1,invItem.getItemCode());
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); // ps.setString(2,invItem.getItemName());
ct= DriverManager.getConnection("jdbc:sqlserver://130.1.0.32:1433;DatabaseName=shoptxns","wjkj","wjkj123456"); // //ps.setString(3,invItem.getAttribute1());
for (InvItem invItem:invItems) { // ps.setString(3,"");
ps=ct.prepareStatement("insert into plu values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); // ps.setString(4,"");
ps.setString(1,invItem.getItemCode()); // ps.setString(5,"");
ps.setString(2,invItem.getItemName()); // ps.setString(6,"");
//ps.setString(3,invItem.getAttribute1()); // ps.setInt(7,(int)(Float.parseFloat("12.56")*100));
ps.setString(3,""); // ps.setInt(8,0);
ps.setString(4,""); // ps.setInt(9,(int)(Float.parseFloat("12.56")*100));
ps.setString(5,""); // ps.setInt(10,(int)(Float.parseFloat("12.56")*100));
ps.setString(6,""); // ps.setInt(11,(int)(Float.parseFloat("12.56")*100));
ps.setInt(7,(int)(Float.parseFloat("12.56")*100)); // ps.setString(12,"-");
ps.setInt(8,0); // java.sql.Date date = new java.sql.Date(new java.util.Date().getTime()); //构建一个
ps.setInt(9,(int)(Float.parseFloat("12.56")*100)); // ps.setDate(13,date);
ps.setInt(10,(int)(Float.parseFloat("12.56")*100)); // ps.setInt(14,0);
ps.setInt(11,(int)(Float.parseFloat("12.56")*100)); // ps.setString(15,"由erp同步");
ps.setString(12,"-"); // ps.setInt(16,Integer.parseInt(invItem.getTax()));
java.sql.Date date = new java.sql.Date(new java.util.Date().getTime()); //构建一个 // int i = ps.executeUpdate();
ps.setDate(13,date); // if(i==1){
ps.setInt(14,0); // System.err.println("将ERP创建的商品同步到POS成功");
ps.setString(15,"由erp同步"); // }else{
ps.setInt(16,Integer.parseInt(invItem.getTax())); // System.err.println("将ERP创建的商品同步到POS失败");
int i = ps.executeUpdate(); // }
if(i==1){ // }
System.err.println("将ERP创建的商品同步到POS成功"); // } catch (Exception e) {
}else{ // System.err.println(e.getMessage());
System.err.println("将ERP创建的商品同步到POS失败"); // }finally {
} // try {
} // if(rs!=null){
} catch (Exception e) { // rs.close();
System.err.println(e.getMessage()); // }
}finally { // if(ps!=null){
try { // ps.close();
if(rs!=null){ // }
rs.close(); // if(ct!=null){
} // ct.close();
if(ps!=null){ // }
ps.close(); // } catch (SQLException e) {
} // System.err.println("将ERP创建的商品同步到POS流关闭异常");
if(ct!=null){ // }
ct.close(); // }
} // }
} catch (SQLException e) { // }
System.err.println("将ERP创建的商品同步到POS流关闭异常"); //
} //
} // @Autowired
} // private TempItemSkuFomPmpMapper tempItemSkuFomPmpMapper;
} //
//
// /**
@Autowired // * 获取pmp商品库存信息同步到临时表
private TempItemSkuFomPmpMapper tempItemSkuFomPmpMapper; // */
// @Test
// public void tempItemSkuFomPmp(){
/** // int i=0;
* 获取pmp商品库存信息同步到临时表 // while (true){
*/ // List<String> plucodes = tempItemFomPmpMapper.findLimitByStaEnd(i,100000);
@Test // if(plucodes==null || plucodes.size()<=0){
public void tempItemSkuFomPmp(){ // return;
List<InvItem> select = invItemMapper.select(); // }
String gettoken = HttpUtilRSA.getToken(); // System.err.println("查询到"+plucodes.size()+"条数据");
String token = (String) JSONObject.parseObject(gettoken).get("Token"); // String gettoken = HttpUtilRSA.getToken();
String tempEncryptKey = (String) JSONObject.parseObject(gettoken).get("TempEncryKey"); // String token = (String) JSONObject.parseObject(gettoken).get("Token");
JSONObject data=new JSONObject(); // String tempEncryptKey = (String) JSONObject.parseObject(gettoken).get("TempEncryKey");
List<JSONObject> plulist=new ArrayList<>(); // JSONObject data=new JSONObject();
for (InvItem invItem:select) { // List<JSONObject> plulist=new ArrayList<>();
if(StringUtil.isEmpty(invItem.getPlucode())){ // for (String plucode:plucodes) {
continue; // if(StringUtil.isEmpty(plucode)){
} // continue;
JSONObject jsonObject=new JSONObject(); // }
jsonObject.put("plucode",invItem.getPlucode()); // JSONObject jsonObject=new JSONObject();
plulist.add(jsonObject); // jsonObject.put("plucode",plucode);
// plulist.add(jsonObject);
} //
data.put("uniquekey","可配库存查询"); // }
data.put("timestamp", getTimestamp()); // data.put("uniquekey","可配库存查询");
data.put("shop", "2"); // data.put("timestamp", getTimestamp());
data.put("plulist",plulist); // data.put("shop", "2");
Map headers=new HashMap(); // data.put("plulist",plulist);
headers.put("Content-Type","application/json"); // Map headers=new HashMap();
headers.put("token",token); // headers.put("Content-Type","application/json");
byte[] encrypt = Aes.encrypt(JSON.toJSONString(data), tempEncryptKey, tempEncryptKey); // headers.put("token",token);
byte[] bytes = new byte[0]; // byte[] encrypt = Aes.encrypt(JSON.toJSONString(data), tempEncryptKey, tempEncryptKey);
try { // byte[] bytes = new byte[0];
bytes = HttpUtilPMP.postBy("http://pmpapi.szcbfx.com/api/pmp/ExchangePMPData", encrypt,token); // try {
} catch (Exception e) { // bytes = HttpUtilPMP.postBy("http://pmpapi.szcbfx.com/api/pmp/ExchangePMPData", encrypt,token);
e.printStackTrace(); // } 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); // //String post = HttpUtilPMP.post("http://pmpapi.szcbfx.com/api/pmp/ExchangePMPData", data, headers, 6000, 6000, "utf-8",tempEncryptKey);
JSONObject object = JSONObject.parseObject(s); // String s = new String(bytes);
List<JSONObject> retMsg= (List<JSONObject>) object.get("ret_msg"); // JSONObject object = JSONObject.parseObject(s);
// List<JSONObject> retMsg= (List<JSONObject>) object.get("ret_msg");
System.err.println(retMsg); //
System.err.println(retMsg.size()); // System.err.println(retMsg.size());
List<TempItemSkuFomPmp> tempItemSkuFomPmps=new ArrayList<>(); // List<TempItemSkuFomPmp> tempItemSkuFomPmps=new ArrayList<>();
for (JSONObject jsonObject:retMsg) { // for (JSONObject jsonObject:retMsg) {
TempItemSkuFomPmp tempItemSkuFomPmp=new TempItemSkuFomPmp(); // TempItemSkuFomPmp tempItemSkuFomPmp=new TempItemSkuFomPmp();
tempItemSkuFomPmp.setId(UuidUtil.get32UUIDString()); // tempItemSkuFomPmp.setId(UuidUtil.get32UUIDString());
tempItemSkuFomPmp.setRack(jsonObject.getString("rack")); // tempItemSkuFomPmp.setRack(jsonObject.getString("rack"));
tempItemSkuFomPmp.setPlucode(jsonObject.getString("plucode")); // tempItemSkuFomPmp.setPlucode(jsonObject.getString("plucode"));
tempItemSkuFomPmp.setTitle(jsonObject.getString("title")); // tempItemSkuFomPmp.setTitle(jsonObject.getString("title"));
tempItemSkuFomPmp.setPrice(jsonObject.getBigDecimal("price")); // tempItemSkuFomPmp.setPrice(jsonObject.getBigDecimal("price"));
tempItemSkuFomPmp.setQty(jsonObject.getInteger("qty")); // tempItemSkuFomPmp.setQty(jsonObject.getInteger("qty"));
tempItemSkuFomPmps.add(tempItemSkuFomPmp); // tempItemSkuFomPmps.add(tempItemSkuFomPmp);
} // }
tempItemSkuFomPmpMapper.insertBatch(tempItemSkuFomPmps); // tempItemSkuFomPmpMapper.insertBatch(tempItemSkuFomPmps);
} // i=i+99999;
} // System.err.println("前"+i+"条数据同步完成");
// }
//
// }
//
//}
package orthopedics.test; //package orthopedics.test;
//
import com.alibaba.fastjson.JSON; //import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; //import com.alibaba.fastjson.JSONObject;
import org.junit.Test; //import org.junit.Test;
import org.junit.runner.RunWith; //import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; //import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; //import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate; //import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.test.context.junit4.SpringRunner; //import org.springframework.test.context.junit4.SpringRunner;
import orthopedics.controller.v1.TransactionController; //import org.springframework.transaction.annotation.Transactional;
import orthopedics.dao.*; //import orthopedics.controller.v1.TransactionController;
import orthopedics.model.*; //import orthopedics.dao.*;
import orthopedics.service.PropertiesServer; //import orthopedics.model.*;
import orthopedics.service.UserServer; //import orthopedics.service.PropertiesServer;
import orthopedics.util.*; //import orthopedics.service.UserServer;
//import orthopedics.util.*;
import java.sql.*; //
import java.text.ParseException; //import java.sql.*;
import java.text.SimpleDateFormat; //import java.text.ParseException;
import java.time.LocalDateTime; //import java.text.SimpleDateFormat;
import java.time.ZoneId; //import java.time.LocalDateTime;
import java.util.Date; //import java.time.ZoneId;
import java.util.*; //import java.util.Date;
//import java.util.*;
/** //
* 将临时表数据同步到正式表 ///**
*/ // * 将临时表数据同步到正式表
@RunWith(SpringRunner.class) // */
@SpringBootTest //@RunWith(SpringRunner.class)
public class TempToOfficial { //@SpringBootTest
//public class TempToOfficial {
@Autowired //
private TempInventoryFomPmpMapper tempInventoryFomPmpMapper; // @Autowired
// private TempInventoryFomPmpMapper tempInventoryFomPmpMapper;
@Autowired //
private InvInventoryMapper invInventoryMapper; // @Autowired
// private InvInventoryMapper invInventoryMapper;
/** //
* temp_inventory_fom_pmp临时表创建库存信息inv_inventory // /**
*/ // * temp_inventory_fom_pmp临时表创建库存信息inv_inventory
@Test // */
public void addInventory(){ // @Test
List<TempInventoryFomPmp> select = tempInventoryFomPmpMapper.select(); // public void addInventory(){
List<InvInventory> invInventories=new ArrayList<>(); // List<TempInventoryFomPmp> select = tempInventoryFomPmpMapper.select();
int i=0; // List<InvInventory> invInventories=new ArrayList<>();
for (TempInventoryFomPmp tempInventoryFomPmp:select) { // int i=0;
InvInventory byInvCode = invInventoryMapper.findByInvCode("WH" + tempInventoryFomPmp.getCode()); // for (TempInventoryFomPmp tempInventoryFomPmp:select) {
if(byInvCode!=null){ // InvInventory byInvCode = invInventoryMapper.findByInvCode("WH" + tempInventoryFomPmp.getCode());
continue; // if(byInvCode!=null){
} // continue;
InvInventory invInventory=new InvInventory(); // }
invInventory.setId(UuidUtil.get32UUIDString()); // InvInventory invInventory=new InvInventory();
invInventory.setOrg_id("2c9007626dde3f4f016deda2151f1a42"); // invInventory.setId(UuidUtil.get32UUIDString());
invInventory.setInv_code("WH"+tempInventoryFomPmp.getCode()); // invInventory.setOrg_id("2c9007626dde3f4f016deda2151f1a42");
invInventory.setInv_name(tempInventoryFomPmp.getDescript()); // invInventory.setInv_code("WH"+tempInventoryFomPmp.getCode());
invInventory.setInv_desc("-1"); // invInventory.setInv_name(tempInventoryFomPmp.getDescript());
invInventory.setSortid(tempInventoryFomPmp.getCode()); // invInventory.setInv_desc("-1");
invInventory.setStatus("A"); // invInventory.setSortid(tempInventoryFomPmp.getCode());
invInventory.setCreate_by("0f98872af64711e9a1b10242ac110002"); // invInventory.setStatus("A");
invInventory.setCreate_time(LocalDateTime.now()); // invInventory.setCreate_by("0f98872af64711e9a1b10242ac110002");
invInventories.add(invInventory); // invInventory.setCreate_time(LocalDateTime.now());
i++; // invInventories.add(invInventory);
invInventoryMapper.insert(invInventory); // i++;
} // invInventoryMapper.insert(invInventory);
//invInventoryMapper.insertBatch(invInventories); // }
System.err.println(i); // //invInventoryMapper.insertBatch(invInventories);
} // System.err.println(i);
// }
@Autowired //
private TempAreaFomPmpMapper tempAreaFomPmpMapper; // @Autowired
// private TempAreaFomPmpMapper tempAreaFomPmpMapper;
@Autowired //
private InvSubinventoryMapper invSubinventoryMapper; // @Autowired
// private InvSubinventoryMapper invSubinventoryMapper;
/** //
* temp_area_fom_pmp临时表创建库区信息inv_subinventory // /**
*/ // * temp_area_fom_pmp临时表创建库区信息inv_subinventory
@Test // */
public void addSubinventory(){ // @Test
List<TempAreaFomPmp> select = tempAreaFomPmpMapper.select(); // public void addSubinventory(){
int i=0; // List<TempAreaFomPmp> select = tempAreaFomPmpMapper.select();
System.err.println("查询到"+select.size()+"条数据"); // int i=0;
for (TempAreaFomPmp tempAreaFomPmp:select) { // System.err.println("查询到"+select.size()+"条数据");
InvSubinventory bySubinvCode = invSubinventoryMapper.findBySubinvCode("KQ" + tempAreaFomPmp.getSubwh()); // for (TempAreaFomPmp tempAreaFomPmp:select) {
if(bySubinvCode!=null){ // InvSubinventory bySubinvCode = invSubinventoryMapper.findBySubinvCode("KQ" + tempAreaFomPmp.getSubwh());
continue; // if(bySubinvCode!=null){
} // continue;
InvSubinventory invSubinventory=new InvSubinventory(); // }
invSubinventory.setId(UuidUtil.get32UUIDString()); // InvSubinventory invSubinventory=new InvSubinventory();
invSubinventory.setCreateDate(LocalDateTime.now()); // invSubinventory.setId(UuidUtil.get32UUIDString());
invSubinventory.setCreateBy("0f98872af64711e9a1b10242ac110002"); // invSubinventory.setCreateDate(LocalDateTime.now());
InvInventory bySortid = invInventoryMapper.findBySortid(tempAreaFomPmp.getWh()); // invSubinventory.setCreateBy("0f98872af64711e9a1b10242ac110002");
if(bySortid==null){ // InvInventory bySortid = invInventoryMapper.findBySortid(tempAreaFomPmp.getWh());
continue; // if(bySortid==null){
} // continue;
invSubinventory.setInvId(bySortid.getId()); // }
invSubinventory.setSubinvType("STORAGE"); // invSubinventory.setInvId(bySortid.getId());
invSubinventory.setSubinvCode("KQ"+tempAreaFomPmp.getSubwh()); // invSubinventory.setSubinvType("STORAGE");
invSubinventory.setSubinvName("存储区"); // invSubinventory.setSubinvCode("KQ"+tempAreaFomPmp.getSubwh());
invSubinventory.setSubinvDesc("-1"); // invSubinventory.setSubinvName("存储区");
invSubinventory.setLocatorControl("Y"); // invSubinventory.setSubinvDesc("-1");
invSubinventory.setStatus("A"); // invSubinventory.setLocatorControl("Y");
i++; // invSubinventory.setStatus("A");
invSubinventoryMapper.insert(invSubinventory); // i++;
} // invSubinventoryMapper.insert(invSubinventory);
System.err.println("处理了"+i+"条数据"); // }
} // System.err.println("处理了"+i+"条数据");
// }
//
@Autowired //
private TempLocatorFomPmpMapper tempLocatorFomPmpMapper; // @Autowired
// private TempLocatorFomPmpMapper tempLocatorFomPmpMapper;
@Autowired //
private InvLocatorMapper invLocatorMapper; // @Autowired
/** // private InvLocatorMapper invLocatorMapper;
* temp_locator_fom_pmp临时表创建h货架信息inv_locator // /**
*/ // * temp_locator_fom_pmp临时表创建h货架信息inv_locator
@Test // */
public void addLocator(){ // @Test
List<TempLocatorFomPmp> select = tempLocatorFomPmpMapper.select(); // public void addLocator(){
int i=0; // List<TempLocatorFomPmp> select = tempLocatorFomPmpMapper.select();
System.err.println("查询到"+select.size()+"条数据"); // int i=0;
// List<InvLocator> invLocators=new ArrayList<>(); // System.err.println("查询到"+select.size()+"条数据");
for (TempLocatorFomPmp tempLocatorFomPmp:select) { //// List<InvLocator> invLocators=new ArrayList<>();
List<InvLocator> invLocatorList = invLocatorMapper.selectLocatorByCode("HJ" + tempLocatorFomPmp.getCode()); // for (TempLocatorFomPmp tempLocatorFomPmp:select) {
if(invLocatorList!=null && invLocatorList.size()>0){ // InvLocator invLocatorList = invLocatorMapper.findLocatorByCode("HJ" + tempLocatorFomPmp.getCode());
continue; // if(invLocatorList!=null){
} // continue;
InvLocator invLocator=new InvLocator(); // }
invLocator.setId(UuidUtil.get32UUIDString()); // InvLocator invLocator=new InvLocator();
invLocator.setCreateBy("0f98872af64711e9a1b10242ac110002"); // invLocator.setId(UuidUtil.get32UUIDString());
invLocator.setCreateTime(LocalDateTime.now()); // invLocator.setCreateBy("0f98872af64711e9a1b10242ac110002");
InvInventory bySortid = invInventoryMapper.findBySortid(tempLocatorFomPmp.getWh()); // invLocator.setCreateTime(LocalDateTime.now());
if(bySortid==null){ // InvInventory bySortid = invInventoryMapper.findBySortid(tempLocatorFomPmp.getWh());
continue; // if(bySortid==null){
} // continue;
invLocator.setInvId(bySortid.getId()); // }
List<InvSubinventory> invSubinventories = invSubinventoryMapper.selectByInvIdAndSubinvName(bySortid.getId()); // invLocator.setInvId(bySortid.getId());
if(invSubinventories==null || invSubinventories.size()<=0){ // List<InvSubinventory> invSubinventories = invSubinventoryMapper.selectByInvIdAndSubinvName(bySortid.getId());
continue; // if(invSubinventories==null || invSubinventories.size()<=0){
} // continue;
invLocator.setSubinvId(invSubinventories.get(0).getId()); // }
invLocator.setLocatorCode("HJ"+tempLocatorFomPmp.getCode()); // invLocator.setSubinvId(invSubinventories.get(0).getId());
invLocator.setLocatorName(tempLocatorFomPmp.getCode()); // invLocator.setLocatorCode("HJ"+tempLocatorFomPmp.getCode());
invLocator.setLocatorDesc("-1"); // invLocator.setLocatorName(tempLocatorFomPmp.getCode());
invLocator.setStatus("A"); // invLocator.setLocatorDesc("-1");
// invLocator.setStatus("A");
// invLocators.add(invLocator); //
invLocatorMapper.insert(invLocator); //// invLocators.add(invLocator);
i++; // invLocatorMapper.insert(invLocator);
System.err.println("第"+i+"条处理完毕"); // i++;
} // System.err.println("第"+i+"条处理完毕");
// invLocatorMapper.insertBatch(invLocators); // }
System.err.println("处理了"+i+"条数据"); //// invLocatorMapper.insertBatch(invLocators);
} // System.err.println("处理了"+i+"条数据");
// }
@Autowired //
private TempItemFomPmpMapper tempItemFomPmpMapper; // @Autowired
// private TempItemFomPmpMapper tempItemFomPmpMapper;
@Autowired //
private InvItemMapper invItemMapper; // @Autowired
// private InvItemMapper invItemMapper;
@Autowired //
private PropertiesServer propertiesServer; // @Autowired
// private PropertiesServer propertiesServer;
@Autowired //
private SysUserDepartMapper sysUserDepartMapper; // @Autowired
// private SysUserDepartMapper sysUserDepartMapper;
@Autowired //
private InvItemSkuMapper invItemSkuMapper; // @Autowired
// private InvItemSkuMapper invItemSkuMapper;
@Autowired //
private InvItemAttributeMapper invItemAttributeMapper; // @Autowired
// private InvItemAttributeMapper invItemAttributeMapper;
/** //
* 将商品信息从临时表temp_item_fom_pmp同步到正式表inv_item 2683351 // @Autowired
*/ // private IdWorker idWorker;
@Test //
public void addInvItem(){ // /**
boolean i=true; // * 将商品信息从临时表temp_item_fom_pmp同步到正式表inv_item 2683351
int j=0; // */
while (i){ // @Test
List<TempItemFomPmp> limit = tempItemFomPmpMapper.findLimit(j); // public void addInvItem(){
System.err.println("查询到"+limit.size()+"条数据"); // int j=208054;
if(limit.size()<=0){ // while (true){
System.err.println("所有数据同步完成!!!"); // List<TempItemFomPmp> limit = tempItemFomPmpMapper.findLimit(j);
return; // System.err.println("查询到"+limit.size()+"条数据");
} // if(limit.size()<=0){
List<InvItem> invItems=new ArrayList<>(); // System.err.println("所有数据同步完成!!!");
List<InvItemAttribute> invItemAttributes=new ArrayList<>(); // return;
List<InvItemSku> invItemSkus=new ArrayList<>(); // }
for (TempItemFomPmp tempItemFomPmp:limit) { // List<InvItem> invItems=new ArrayList<>();
InvItem plucode = invItemMapper.findByPlucode(tempItemFomPmp.getPlucode()); // List<InvItemAttribute> invItemAttributes=new ArrayList<>();
if(plucode!=null){ // List<InvItemSku> invItemSkus=new ArrayList<>();
continue; // for (TempItemFomPmp tempItemFomPmp:limit) {
} // String plucode = invItemMapper.getPlucode(tempItemFomPmp.getPlucode());
InvItem invItem=new InvItem(); // if(plucode!=null){
InvItemAttribute invItemAttribute=new InvItemAttribute(); // continue;
InvItemSku invItemSku=new InvItemSku(); // }
// InvItem invItem=new InvItem();
//商品表 // InvItemAttribute invItemAttribute=new InvItemAttribute();
invItem.setId(UuidUtil.get32UUIDString()); // InvItemSku invItemSku=new InvItemSku();
invItem.setOrgId("964daee94b604cd58e5e6bf48dd9670a"); //
invItem.setStatus("SALE"); // //商品表
invItem.setProType("14"); // invItem.setId(UuidUtil.get32UUIDString());
String newItemCode = invItemMapper.selectTheNewItemCode("14"); // invItem.setOrgId("2c9007626dde3f4f016deda2151f1a42");
String itemCode; // invItem.setStatus("SALE");
if(newItemCode == null || "".equals(newItemCode)){ // invItem.setProType(tempItemFomPmp.getClscode());
itemCode = invItem.getProType() ; // invItem.setItemCode(idWorker.nextId()+"");
for(int u=0;u<(13-invItem.getProType().length()-1);u++){ // invItem.setItemName(tempItemFomPmp.getTitle());
itemCode = itemCode + "0"; // invItem.setItemDesc(tempItemFomPmp.getJp());
} // invItem.setPystype(tempItemFomPmp.getPystype()+"");
itemCode = itemCode + "1"; // invItem.setIsbn(tempItemFomPmp.getIsbn());
}else { // invItem.setPlucode(tempItemFomPmp.getPlucode());
//商品代码加1 // invItem.setScancode(tempItemFomPmp.getScancode());
itemCode = String.valueOf(Long.parseLong(newItemCode)+1); // invItem.setExtcode("0");
} // invItem.setPurchasePrice(tempItemFomPmp.getPrice()+"");
invItem.setItemCode(itemCode); // invItem.setGeneralName(tempItemFomPmp.getClscode());
invItem.setItemName(tempItemFomPmp.getTitle()); // invItem.setManufacturerId(tempItemFomPmp.getPublisher());
invItem.setItemDesc(tempItemFomPmp.getJp()); // invItem.setSpecification(tempItemFomPmp.getPubdate());
invItem.setPystype(tempItemFomPmp.getPystype()+""); // invItem.setPrimaryUnit("BEN");
invItem.setIsbn(tempItemFomPmp.getIsbn()); // if(tempItemFomPmp.getPystype()==0||tempItemFomPmp.getPystype()==4){
invItem.setPlucode(tempItemFomPmp.getPlucode()); // invItem.setAttribute1("Book");
invItem.setScancode(tempItemFomPmp.getScancode()); // invItem.setIsBorrow("Y");
invItem.setExtcode("0"); // }else{
invItem.setPurchasePrice(tempItemFomPmp.getPrice()+""); // invItem.setAttribute1("Goods");
invItem.setGeneralName(tempItemFomPmp.getClscode()); // invItem.setIsBorrow("N");
invItem.setManufacturerId(tempItemFomPmp.getPublisher()); // }
invItem.setSpecification(tempItemFomPmp.getPubdate()); // invItem.setAttribute2("A");
invItem.setPrimaryUnit("BEN"); // invItem.setTax(tempItemFomPmp.getInctax()+"");
if(tempItemFomPmp.getPystype()==0||tempItemFomPmp.getPystype()==4){ // invItem.setDefaultVendorId("000000006c60dba1016c60f839270004");
invItem.setAttribute1("Book"); // invItem.setCreateBy("PMP同步");
invItem.setIsBorrow("Y"); // invItem.setCreateTime(LocalDateTime.now());
}else{ // //查询当前用户部门
invItem.setAttribute1("Goods"); // //SysUserDepart sysUserDepart = sysUserDepartMapper.selectByUserId("b7b819e3a7fb25699ff5e10332f089f7");
invItem.setIsBorrow("N"); //
} // //图书信息
invItem.setAttribute2("A"); // invItemAttribute.setId(UuidUtil.get32UUIDString());
invItem.setTax(tempItemFomPmp.getInctax()+""); // invItemAttribute.setCreateBy("PMP同步");
invItem.setDefaultVendorId("000000006c60dba1016c60f839270004"); // invItemAttribute.setCreateTime(LocalDateTime.now());
invItem.setCreateBy("PMP同步"); //// if(sysUserDepart!=null){
invItem.setCreateTime(LocalDateTime.now()); //// invItemAttribute.setSysOrgCode(sysUserDepart.getDepId());
//查询当前用户部门 //// }
SysUserDepart sysUserDepart = sysUserDepartMapper.selectByUserId("b7b819e3a7fb25699ff5e10332f089f7"); // invItemAttribute.setItemId(invItem.getId());
// invItemAttribute.setItemCode(invItem.getItemCode());
//图书信息 // invItemAttribute.setAuthor(tempItemFomPmp.getAuthor());
invItemAttribute.setId(UuidUtil.get32UUIDString()); // invItemAttribute.setReader(tempItemFomPmp.getReader());
invItemAttribute.setCreateBy("PMP同步"); //
invItemAttribute.setCreateTime(LocalDateTime.now()); //
if(sysUserDepart!=null){ // //商品SKU映射
invItemAttribute.setSysOrgCode(sysUserDepart.getDepId()); // invItemSku.setId(UuidUtil.get32UUIDString());
} //// if(sysUserDepart!=null){
invItemAttribute.setItemId(invItem.getId()); //// invItemSku.setSysOrgCode(sysUserDepart.getDepId());
invItemAttribute.setItemCode(invItem.getItemCode()); //// }
invItemAttribute.setAuthor(tempItemFomPmp.getAuthor()); // invItemSku.setOrgId("2c9007626dde3f4f016deda2151f1a42");
invItemAttribute.setReader(tempItemFomPmp.getReader()); // invItemSku.setExternal("PMP");
// invItemSku.setItemSku(tempItemFomPmp.getPlucode());
// invItemSku.setItemName(invItem.getItemName());
//商品SKU映射 // invItemSku.setItemCode(invItem.getItemCode());
invItemSku.setId(UuidUtil.get32UUIDString()); // invItemSku.setItemDesc(invItem.getItemDesc());
if(sysUserDepart!=null){ // invItemSku.setStatus("A");
invItemSku.setSysOrgCode(sysUserDepart.getDepId()); // invItemSku.setCreateBy("PMP同步");
} // invItemSku.setCreateTime(LocalDateTime.now());
invItemSku.setOrgId("964daee94b604cd58e5e6bf48dd9670a"); // invItems.add(invItem);
invItemSku.setExternal("PMP"); // invItemAttributes.add(invItemAttribute);
invItemSku.setItemSku(tempItemFomPmp.getPlucode()); // invItemSkus.add(invItemSku);
invItemSku.setItemName(invItem.getItemName()); // }
invItemSku.setItemCode(invItem.getItemCode()); // System.err.println("数据封装完成");
invItemSku.setItemDesc(invItem.getItemDesc()); // invItemMapper.insertBatch(invItems);
invItemSku.setStatus("A"); // invItemSkuMapper.insertBatch(invItemSkus);
invItemSku.setCreateBy("PMP同步"); // invItemAttributeMapper.insertBatch(invItemAttributes);
invItemSku.setCreateTime(LocalDateTime.now()); // j=j+999;
// System.err.println("前"+j+"条同步完成");
} //
System.err.println("数据封装完成"); // }
invItemMapper.insertBatch(invItems); // }
invItemSkuMapper.insertBatch(invItemSkus); //
invItemAttributeMapper.insertBatch(invItemAttributes); // /**
System.err.println("前"+j+"条同步完成"); // * 将商品信息从临时表temp_item_fom_pmp同步到正式表inv_item 2683351
j=j+10000; // */
} // @Test
} // public void addInvItems(){
// int i=0;
// int j=0;
@Autowired // while (true){
private TempItemSkuFomPmpMapper tempItemSkuFomPmpMapper; // List<TempItemFomPmp> limit = tempItemFomPmpMapper.findLimit(j);
// System.err.println("查询到"+limit.size()+"条数据");
@Autowired // if(limit.size()<=0){
private TransactionController transactionController; // System.err.println("所有数据同步完成!!!");
/** // return;
* 将商品库存信息从临时表temp_item_sku_fom_pmp同步到正式库存 // }
*/ // for (TempItemFomPmp tempItemFomPmp:limit) {
@Test // InvItem plucode = invItemMapper.findByPlucode(tempItemFomPmp.getPlucode());
public void addInvItemSku(){ // if(plucode!=null){
List<TempItemSkuFomPmp> select = tempItemSkuFomPmpMapper.select(); // i++;
int i=0; // System.err.println("第"+i+"条同步完成");
for (TempItemSkuFomPmp tempItemSkuFomPmp:select) { // continue;
JSONObject jsonObject=new JSONObject(); // }
JSONObject data=new JSONObject(); // InvItem invItem=new InvItem();
data.put("inv_code","WH2"); // InvItemAttribute invItemAttribute=new InvItemAttribute();
data.put("subinv_code","KQ2"); // InvItemSku invItemSku=new InvItemSku();
data.put("locator_code","HJ"+tempItemSkuFomPmp.getRack()); //
InvItem byPlucode = invItemMapper.findByPlucode(tempItemSkuFomPmp.getPlucode()); // //商品表
data.put("item_code",byPlucode.getItemCode()); // invItem.setId(UuidUtil.get32UUIDString());
data.put("tx_type_code","PMP_SYN"); // invItem.setOrgId("2c9007626dde3f4f016deda2151f1a42");
data.put("tx_date",new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); // invItem.setStatus("SALE");
data.put("tx_quantity",tempItemSkuFomPmp.getQty()); // invItem.setProType(tempItemFomPmp.getClscode());
data.put("tx_price",tempItemSkuFomPmp.getPrice()); // invItem.setItemCode(idWorker.nextId()+"");
jsonObject.put("data",data); // invItem.setItemName(tempItemFomPmp.getTitle());
String s = transactionController.invItemInOut("201910271129039497a78b526d9a246eca0abb1025986f25cG7BHIxhVaDO6MYm", jsonObject); // invItem.setItemDesc(tempItemFomPmp.getJp());
i++; // invItem.setPystype(tempItemFomPmp.getPystype()+"");
System.err.println(i); // 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