计费模块重构,可以在线配置SQl,更灵活面对不同计费方式
parent
376aaecbe2
commit
d59a91ad68
|
@ -3,14 +3,18 @@ package org.jeecgframework.web.system.sms.util.task;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import org.jeecgframework.core.util.StringUtil;
|
import com.zzjee.ba.entity.BaCostEntity;
|
||||||
|
import com.zzjee.wm.entity.*;
|
||||||
|
import com.zzjee.wm.page.WmCusCostHPage;
|
||||||
|
import com.zzjee.wm.service.WmCusCostHServiceI;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.jeecgframework.core.common.exception.BusinessException;
|
||||||
|
import org.jeecgframework.core.common.hibernate.qbc.CriteriaQuery;
|
||||||
|
import org.jeecgframework.core.util.*;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.apache.poi.hdf.extractor.NewOleFile;
|
import org.apache.poi.hdf.extractor.NewOleFile;
|
||||||
import org.jeecgframework.core.util.DBTypeUtil;
|
|
||||||
import org.jeecgframework.core.util.DateUtils;
|
|
||||||
import org.jeecgframework.core.util.ResourceUtil;
|
|
||||||
import org.jeecgframework.web.system.service.SystemService;
|
import org.jeecgframework.web.system.service.SystemService;
|
||||||
import org.jeecgframework.web.system.sms.entity.TSSmsEntity;
|
import org.jeecgframework.web.system.sms.entity.TSSmsEntity;
|
||||||
import org.jeecgframework.web.system.sms.service.TSSmsServiceI;
|
import org.jeecgframework.web.system.sms.service.TSSmsServiceI;
|
||||||
|
@ -20,15 +24,6 @@ import com.zzjee.md.entity.MdBinEntity;
|
||||||
import com.zzjee.md.entity.MdCusEntity;
|
import com.zzjee.md.entity.MdCusEntity;
|
||||||
import com.zzjee.md.entity.MdGoodsEntity;
|
import com.zzjee.md.entity.MdGoodsEntity;
|
||||||
import com.zzjee.md.entity.MvGoodsEntity;
|
import com.zzjee.md.entity.MvGoodsEntity;
|
||||||
import com.zzjee.wm.entity.WmDayCostConfEntity;
|
|
||||||
import com.zzjee.wm.entity.WmDayCostEntity;
|
|
||||||
import com.zzjee.wm.entity.WmImNoticeIEntity;
|
|
||||||
import com.zzjee.wm.entity.WmInQmIEntity;
|
|
||||||
import com.zzjee.wm.entity.WmOmNoticeIEntity;
|
|
||||||
import com.zzjee.wm.entity.WmOmQmIEntity;
|
|
||||||
import com.zzjee.wm.entity.WmToDownGoodsEntity;
|
|
||||||
import com.zzjee.wm.entity.WmToMoveGoodsEntity;
|
|
||||||
import com.zzjee.wm.entity.WmToUpGoodsEntity;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ClassName:SmsSendTask 所有信息的发送定时任务类
|
* @ClassName:SmsSendTask 所有信息的发送定时任务类
|
||||||
|
@ -42,7 +37,8 @@ public class CostTask {
|
||||||
private TSSmsServiceI tSSmsService;
|
private TSSmsServiceI tSSmsService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private SystemService systemService;
|
private SystemService systemService;
|
||||||
|
@Autowired
|
||||||
|
private WmCusCostHServiceI wmCusCostHService;
|
||||||
/* @Scheduled(cron="0 0 01 * * ?") */
|
/* @Scheduled(cron="0 0 01 * * ?") */
|
||||||
public void run() {
|
public void run() {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
|
@ -55,7 +51,7 @@ public class CostTask {
|
||||||
.info("===================計費定时任务开始===================");
|
.info("===================計費定时任务开始===================");
|
||||||
WmDayCostConfEntity t = new WmDayCostConfEntity();
|
WmDayCostConfEntity t = new WmDayCostConfEntity();
|
||||||
|
|
||||||
this.costcount(datestr, "N", t);//每天自动计算
|
this.costcountv2(datestr, "N", t);//每天自动计算
|
||||||
org.jeecgframework.core.util.LogUtil
|
org.jeecgframework.core.util.LogUtil
|
||||||
.info("===================計費定时任务结束===================");
|
.info("===================計費定时任务结束===================");
|
||||||
long end = System.currentTimeMillis();
|
long end = System.currentTimeMillis();
|
||||||
|
@ -89,10 +85,109 @@ public class CostTask {
|
||||||
|
|
||||||
//先删除
|
//先删除
|
||||||
tsql = "delete from wm_day_cost where cost_sta ='已生成' and to_days(cost_data) = to_days(?)";
|
tsql = "delete from wm_day_cost where cost_sta ='已生成' and to_days(cost_data) = to_days(?)";
|
||||||
|
|
||||||
systemService.executeSql(tsql, t.getCostDate());
|
systemService.executeSql(tsql, t.getCostDate());
|
||||||
org.jeecgframework.core.util.LogUtil
|
org.jeecgframework.core.util.LogUtil
|
||||||
.info("===================V2数据删除成功===================");
|
.info("===================V2数据删除成功===================");
|
||||||
|
CriteriaQuery cq = new CriteriaQuery(WmCusCostHEntity.class);
|
||||||
|
cq.add();
|
||||||
|
List<WmCusCostHEntity> list=this.wmCusCostHService.getListByCriteriaQuery(cq, false);
|
||||||
|
Double cost_jg = 0.0000;
|
||||||
|
Double cost_sl = 0.0000;
|
||||||
|
Double cost_bhs = 0.0000;
|
||||||
|
Double cost_hs = 0.0000;
|
||||||
|
Double dayCostYj = 0.0000;
|
||||||
|
Double dayCostBhs = 0.0000;
|
||||||
|
Double dayCostSe = 0.0000;
|
||||||
|
Double dayCostHsj = 0.0000;
|
||||||
|
Double costSlo = 0.0000;
|
||||||
|
String ori = null;
|
||||||
|
String costSl = null;
|
||||||
|
String countunit = null;
|
||||||
|
if(list!=null&&list.size()>0){
|
||||||
|
for(WmCusCostHEntity entity:list){
|
||||||
|
try{
|
||||||
|
Object id0 = entity.getId();
|
||||||
|
String hql0 = "from WmCusCostIEntity where 1 = 1 AND cUS_COST_ID = ? ";
|
||||||
|
List<WmCusCostIEntity> wmCusCostIEntityList = systemService.findHql(hql0,id0);
|
||||||
|
String cusCode = entity.getCusCode();
|
||||||
|
String cusName = "";
|
||||||
|
try{
|
||||||
|
MdCusEntity mdcus1 = systemService.findUniqueByProperty(MdCusEntity.class, "keHuBianMa", cusCode);
|
||||||
|
cusName = mdcus1.getZhongWenQch();
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
for (WmCusCostIEntity wmCusCostIEntity : wmCusCostIEntityList) {
|
||||||
|
//执行计算
|
||||||
|
String dataSql = wmCusCostIEntity.getDataSql();
|
||||||
|
dataSql = StringUtils.replace(dataSql, "{cusCode}", cusCode);
|
||||||
|
List<Map<String, Object>> resulthq = systemService
|
||||||
|
.findForJdbc(dataSql, t.getCostDate());
|
||||||
|
//计算费用
|
||||||
|
for (int i = 0; i < resulthq.size(); i++) {
|
||||||
|
try{
|
||||||
|
ori = null;
|
||||||
|
costSl = null;
|
||||||
|
cost_jg = 0.0000;
|
||||||
|
cost_sl = 0.0000;
|
||||||
|
cost_bhs = 0.0000;
|
||||||
|
cost_hs = 0.0000;
|
||||||
|
dayCostYj = 0.0000;
|
||||||
|
dayCostBhs = 0.0000;
|
||||||
|
dayCostSe = 0.0000;
|
||||||
|
dayCostHsj = 0.0000;
|
||||||
|
cost_jg = Double.parseDouble(wmCusCostIEntity.getCostJg());
|
||||||
|
cost_sl = Double.parseDouble(wmCusCostIEntity.getCostSl());
|
||||||
|
cost_bhs = Double.parseDouble(wmCusCostIEntity.getCostBhs());
|
||||||
|
cost_hs = Double.parseDouble(wmCusCostIEntity.getCostHs());
|
||||||
|
ori = resulthq.get(i).get("order_id").toString() + "/" + resulthq.get(i).get("goods_id").toString();
|
||||||
|
countunit = resulthq.get(i).get("count_unit").toString();
|
||||||
|
costSlo = Double.parseDouble(resulthq.get(i).get("goods_count").toString());
|
||||||
|
costSl = costSlo.toString();
|
||||||
|
WmDayCostEntity WmDayCost = new WmDayCostEntity();
|
||||||
|
WmDayCost.setCostJs("N");
|
||||||
|
WmDayCost.setCreateBy("system");
|
||||||
|
WmDayCost.setCreateDate(DateUtils.getDate());
|
||||||
|
WmDayCost.setCostCode(wmCusCostIEntity.getCostCode());
|
||||||
|
try{
|
||||||
|
BaCostEntity bacost = systemService.findUniqueByProperty(BaCostEntity.class, "costCode", wmCusCostIEntity.getCostCode());
|
||||||
|
WmDayCost.setCostName(bacost.getCostName());
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
WmDayCost.setCostData(t.getCostDate());
|
||||||
|
WmDayCost.setCostOri(ori);
|
||||||
|
WmDayCost.setCostSl(costSl);
|
||||||
|
WmDayCost.setCostSta("已生成");
|
||||||
|
WmDayCost.setCusCode(cusCode);
|
||||||
|
WmDayCost.setCusName(cusName);
|
||||||
|
WmDayCost.setCostUnit(countunit);
|
||||||
|
dayCostYj = cost_jg * costSlo;
|
||||||
|
dayCostBhs = cost_bhs * costSlo;
|
||||||
|
dayCostHsj = cost_hs * costSlo;
|
||||||
|
dayCostSe = dayCostHsj - dayCostBhs;
|
||||||
|
DecimalFormat df = new DecimalFormat("#.00");
|
||||||
|
WmDayCost.setDayCostYj(df.format(dayCostYj));
|
||||||
|
WmDayCost.setDayCostBhs(df.format(dayCostBhs));
|
||||||
|
WmDayCost.setDayCostSe(df.format(dayCostSe));
|
||||||
|
WmDayCost.setDayCostHsj(df.format(dayCostHsj));
|
||||||
|
systemService.save(WmDayCost);
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}catch(Exception e){
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue