|
|
@ -12,6 +12,7 @@ import com.demo.jsl.entity.supplier.JslSupplier; |
|
|
|
import com.demo.jsl.entity.user.JslUser; |
|
|
|
import com.demo.jsl.entity.verifi.VtbVerification; |
|
|
|
import com.demo.jsl.entity.verifi.VtbVerificationSubject; |
|
|
|
import com.demo.t202307042.CenterUserNameXlt; |
|
|
|
import com.demo.util.*; |
|
|
|
import com.demo.util.dto.DateSplitDTO; |
|
|
|
import lombok.SneakyThrows; |
|
|
@ -128,6 +129,7 @@ public class TbsServiceImpl { |
|
|
|
log.info(year + "年" + month + "月无数据"); |
|
|
|
return; |
|
|
|
} |
|
|
|
List<CenterUserNameXlt> centerUserNameList = jslContext.sql("select * from center_user_name_xlt ").getList(CenterUserNameXlt.class); |
|
|
|
List<List<XltCost>> listList = CollectionUtil.createList(allCostList, 2000); |
|
|
|
List<XltCost> costList = new ArrayList<>(); |
|
|
|
for (List<XltCost> xltCostList : listList) { |
|
|
@ -156,14 +158,14 @@ public class TbsServiceImpl { |
|
|
|
String fileName = "D:\\logs\\" + year + "_" + month + "_err_codes.log"; |
|
|
|
FileUtil.create(fileName); |
|
|
|
if (costList.size() > 0) { |
|
|
|
this.syncCostMain(xltContext, jslContext, costList, fileName, title); |
|
|
|
this.syncCostMain(xltContext, jslContext, costList, title,centerUserNameList); |
|
|
|
} |
|
|
|
xltContext.close(); |
|
|
|
jslContext.close(); |
|
|
|
} |
|
|
|
|
|
|
|
@SneakyThrows |
|
|
|
private void syncCostMain(DbContext xltContext, DbContext jslContext, List<XltCost> costList, String fileName, String title) { |
|
|
|
private void syncCostMain(DbContext xltContext, DbContext jslContext, List<XltCost> costList, String title,List<CenterUserNameXlt> centerUserNameList ) { |
|
|
|
List<JslGoodsCategory> categoryList = jslContext.sql("select id,xlt_id,code,name from goods_category").getList(JslGoodsCategory.class); |
|
|
|
String customerIds = costList.stream().map(a -> "'" + a.getCusCode() + "'").distinct().collect(Collectors.joining(",")); |
|
|
|
if (customerIds.length() < 1) { |
|
|
@ -174,7 +176,7 @@ public class TbsServiceImpl { |
|
|
|
for (int i = 0; i < costList.size(); i++) { |
|
|
|
XltCost xltCost = costList.get(i); |
|
|
|
try { |
|
|
|
buildCostItem(xltContext, jslContext, categoryList, jslSuppliers, xltCost); |
|
|
|
buildCostItem(xltContext, jslContext, categoryList, jslSuppliers, xltCost,centerUserNameList); |
|
|
|
System.out.println(title + " =>" + i + "/" + costList.size()); |
|
|
|
} catch (SQLException e) { |
|
|
|
e.printStackTrace(); |
|
|
@ -182,7 +184,8 @@ public class TbsServiceImpl { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void buildCostItem(DbContext xltContext, DbContext jslContext, List<JslGoodsCategory> categoryList, List<JslSupplier> jslSuppliers, XltCost xltCost) throws SQLException { |
|
|
|
private void buildCostItem(DbContext xltContext, DbContext jslContext, List<JslGoodsCategory> categoryList, |
|
|
|
List<JslSupplier> jslSuppliers, XltCost xltCost,List<CenterUserNameXlt> centerUserNameList) throws SQLException { |
|
|
|
JslUser jslUser = jslContext.sql("select id,code from sys_user where code = ?", xltCost.getUserCode()).getItem(JslUser.class); |
|
|
|
String userId = "0"; |
|
|
|
if (jslUser != null&&jslUser.getId()!=null) { |
|
|
@ -425,8 +428,8 @@ public class TbsServiceImpl { |
|
|
|
|
|
|
|
|
|
|
|
this.buildAndSaveCenterGoods(jslContext, supplierId,saleRegion, costApplyId, costItem, |
|
|
|
activityId, jslSubject, targetType, targetCode, targetName, levelIds, levelNames, targetId); |
|
|
|
this.buildAndSaveActivityCenter(jslContext, xltCost, supplierId,saleRegion, costApplyId, costItem, activityId, jslSubject); |
|
|
|
activityId, jslSubject, targetType, targetCode, targetName, levelIds, levelNames, targetId,centerUserNameList); |
|
|
|
this.buildAndSaveActivityCenter(jslContext, supplierId,saleRegion, costApplyId, costItem, activityId, jslSubject,centerUserNameList); |
|
|
|
|
|
|
|
//核销读取另外一个表
|
|
|
|
// if (costItem.getCheckMoney().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
@ -439,7 +442,10 @@ public class TbsServiceImpl { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void buildAndSaveCenterGoods(DbContext jslContext, Long supplierId, JslBmsRegion saleRegion,Long costApplyId, XltCostItem costItem, Long activityId, JslSubject jslSubject, String targetType, String targetCode, String targetName, String levelIds, String levelNames, Long targetId) throws SQLException { |
|
|
|
private void buildAndSaveCenterGoods(DbContext jslContext, Long supplierId, JslBmsRegion saleRegion,Long costApplyId, |
|
|
|
XltCostItem costItem, Long activityId, JslSubject jslSubject, String targetType, |
|
|
|
String targetCode, String targetName, String levelIds, String levelNames, |
|
|
|
Long targetId,List<CenterUserNameXlt> centerUserNameList) throws SQLException { |
|
|
|
JslActivityCenterGoods centerGoods = new JslActivityCenterGoods(); |
|
|
|
centerGoods.setCostApplyId(costApplyId); |
|
|
|
centerGoods.setActivityId(activityId); |
|
|
@ -452,9 +458,18 @@ public class TbsServiceImpl { |
|
|
|
centerGoods.setSupplierCode(costItem.getCusCode()); |
|
|
|
centerGoods.setSupplierName(costItem.getCusName()); |
|
|
|
|
|
|
|
// if (costItem.getCenterId().equals(xltCost.getCusId())) {
|
|
|
|
// centerGoods.setCenterId(supplierId + "");
|
|
|
|
// } else {
|
|
|
|
//设置成本中心
|
|
|
|
String xltCenterCode = costItem.getCenterCode(); |
|
|
|
for (CenterUserNameXlt nameXlt : centerUserNameList) { |
|
|
|
if(nameXlt.getCenterUserName().equals(xltCenterCode)){ |
|
|
|
centerGoods.setCenterType(nameXlt.getType()); |
|
|
|
centerGoods.setCenterId(nameXlt.getCmsCenterId()); |
|
|
|
centerGoods.setCenterName(nameXlt.getCmsCenterName()); |
|
|
|
centerGoods.setCenterCode(nameXlt.getCmsCenterCode()); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
if(centerGoods.getCenterName()==null){ |
|
|
|
if(saleRegion!=null&&!"0".equals(saleRegion.getId())){ |
|
|
|
centerGoods.setCenterType("saleRegion"); |
|
|
|
centerGoods.setCenterId(saleRegion.getId()); |
|
|
@ -463,11 +478,7 @@ public class TbsServiceImpl { |
|
|
|
}else { |
|
|
|
centerGoods.setCenterId("__"+supplierId); |
|
|
|
} |
|
|
|
//
|
|
|
|
// JslSupplier centerSuppliers = jslContext.sql("SELECT id,xlt_id,name FROM `bms_supplier` WHERE xlt_id = ?", costItem.getCenterId()
|
|
|
|
// ).getItem(JslSupplier.class);
|
|
|
|
// centerGoods.setCenterId(centerSuppliers.getId() + "");
|
|
|
|
// }
|
|
|
|
} |
|
|
|
|
|
|
|
//todo 同步核销时更新
|
|
|
|
//centerGoods.setUsedAmount(totalCheckMoney);
|
|
|
@ -504,7 +515,6 @@ public class TbsServiceImpl { |
|
|
|
/** |
|
|
|
* 保存成本中心 |
|
|
|
* @param jslContext |
|
|
|
* @param xltCost |
|
|
|
* @param supplierId |
|
|
|
* @param costApplyId |
|
|
|
* @param costItem |
|
|
@ -512,20 +522,33 @@ public class TbsServiceImpl { |
|
|
|
* @param jslSubject |
|
|
|
* @throws SQLException |
|
|
|
*/ |
|
|
|
private void buildAndSaveActivityCenter(DbContext jslContext, XltCost xltCost, Long supplierId, JslBmsRegion saleRegion, Long costApplyId, XltCostItem costItem, Long activityId, JslSubject jslSubject) throws SQLException { |
|
|
|
private void buildAndSaveActivityCenter(DbContext jslContext, Long supplierId, JslBmsRegion saleRegion, |
|
|
|
Long costApplyId, XltCostItem costItem, Long activityId, JslSubject jslSubject, |
|
|
|
List<CenterUserNameXlt> centerUserNameList) throws SQLException { |
|
|
|
JslActivityCenter activityCenter = new JslActivityCenter(); |
|
|
|
activityCenter.setCostApplyId(costApplyId); |
|
|
|
activityCenter.setActivityId(activityId); |
|
|
|
activityCenter.setSubjectId(jslSubject.getId()); |
|
|
|
activityCenter.setCenterAmount(costItem.getMoney()); |
|
|
|
activityCenter.setCenterRate(new BigDecimal("100")); |
|
|
|
activityCenter.setCenterType("customer"); |
|
|
|
activityCenter.setTenantId("001"); |
|
|
|
activityCenter.setCenterCode(costItem.getCenterCode()); |
|
|
|
activityCenter.setCenterName(costItem.getCenterName()); |
|
|
|
// if (costItem.getCenterId().equals(xltCost.getCusId())) {
|
|
|
|
// activityCenter.setCenterId(supplierId + "");
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
String xltCenterCode = costItem.getCenterCode(); |
|
|
|
boolean exist = false; |
|
|
|
for (CenterUserNameXlt nameXlt : centerUserNameList) { |
|
|
|
if(nameXlt.getCenterUserName().equals(xltCenterCode)){ |
|
|
|
activityCenter.setCenterType(nameXlt.getType()); |
|
|
|
activityCenter.setCenterId(nameXlt.getCmsCenterId()); |
|
|
|
activityCenter.setCenterName(nameXlt.getCmsCenterName()); |
|
|
|
activityCenter.setCenterCode(nameXlt.getCmsCenterCode()); |
|
|
|
exist = true; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
if(exist){ |
|
|
|
activityCenter.setCenterType("customer"); |
|
|
|
activityCenter.setTenantId("001"); |
|
|
|
activityCenter.setCenterCode(costItem.getCenterCode()); |
|
|
|
activityCenter.setCenterName(costItem.getCenterName()); |
|
|
|
if(saleRegion!=null&&!"0".equals(saleRegion.getId())){ |
|
|
|
activityCenter.setCenterType("saleRegion"); |
|
|
|
activityCenter.setCenterId(saleRegion.getId()); |
|
|
@ -534,10 +557,7 @@ public class TbsServiceImpl { |
|
|
|
}else { |
|
|
|
activityCenter.setCenterId("__"+supplierId); |
|
|
|
} |
|
|
|
// JslSupplier centerSuppliers = jslContext.sql("SELECT id,xlt_id,name FROM `bms_supplier` WHERE xlt_id = ?", costItem.getCenterId()
|
|
|
|
// ).getItem(JslSupplier.class);
|
|
|
|
// activityCenter.setCenterId(centerSuppliers.getId() + "");
|
|
|
|
// }
|
|
|
|
} |
|
|
|
|
|
|
|
//todo 同步时更新
|
|
|
|
//activityCenter.setUsedAmount(totalCheckMoney);
|
|
|
|