账单生成(每月1号凌晨1点生成上个月账单)
This commit is contained in:
parent
d7581651e6
commit
2a29aade77
|
|
@ -14,5 +14,4 @@ public interface FactoryListDao extends BaseDao<FactoryList, String>{
|
||||||
|
|
||||||
//获取鱼缸厂下所有属电子厂
|
//获取鱼缸厂下所有属电子厂
|
||||||
public Map<String,String> getFactoryByVenderCode(String venderCode);
|
public Map<String,String> getFactoryByVenderCode(String venderCode);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,4 +40,6 @@ public class FactoryListDaoImpl extends HibernateBaseDao<FactoryList, String> im
|
||||||
return returnMap;
|
return returnMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,87 @@
|
||||||
|
package com.ifish.job;
|
||||||
|
|
||||||
|
import com.ifish.entity.FactoryList;
|
||||||
|
import com.ifish.entity.PayBill;
|
||||||
|
import com.ifish.entity.id.PayBillId;
|
||||||
|
import com.ifish.enums.BooleanEnum;
|
||||||
|
import com.ifish.service.FactoryService;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Lazy;
|
||||||
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: yan.y
|
||||||
|
* @Description:
|
||||||
|
* @Date: Created in 18:34 2019-01-23
|
||||||
|
* @Modified by:
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@EnableScheduling
|
||||||
|
@Lazy(false)
|
||||||
|
public class PayBillJob {
|
||||||
|
|
||||||
|
private static Logger log = LoggerFactory.getLogger(PayBillJob.class);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private FactoryService factoryService;
|
||||||
|
|
||||||
|
@Scheduled(cron= "0 0 1 1 * ?")
|
||||||
|
public void addPayBillJob(){
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
String billMonth = calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) < 10 ? ("0" + calendar.get(Calendar.MONTH)) : calendar.get(Calendar.MONTH));
|
||||||
|
log.info("addPayBill begin ...");
|
||||||
|
List<FactoryList> factoryList = factoryService.getFactoryList();
|
||||||
|
for (FactoryList list : factoryList) {
|
||||||
|
PayBill payBill = new PayBill();
|
||||||
|
String factoryCode = list.getFactoryCode();
|
||||||
|
String isTax = list.getIsTax();
|
||||||
|
int number = factoryService.getDeviceCountByFactory(factoryCode);
|
||||||
|
payBill.setFactoryList(list);
|
||||||
|
payBill.setIsTax(isTax);
|
||||||
|
payBill.setPayStatus("0");
|
||||||
|
payBill.setAuthorizeNumber(number);
|
||||||
|
PayBillId payBillId = new PayBillId();
|
||||||
|
payBillId.setBillMonth(billMonth);
|
||||||
|
payBillId.setFactoryCode(factoryCode);
|
||||||
|
payBill.setPayBillId(payBillId);
|
||||||
|
payBill.setPayDate(new Date());
|
||||||
|
payBill.setCreateTime(new Date());
|
||||||
|
//支付金额
|
||||||
|
Integer money = 0;
|
||||||
|
//数量小于1000,每个收费15元
|
||||||
|
if (number < 1000) {
|
||||||
|
money = number * 15;
|
||||||
|
} //数量1000~5000,每个收费12元
|
||||||
|
else if (number >= 1000 && number < 5000) {
|
||||||
|
money = number * 12;
|
||||||
|
} //数量5000~10000,每个收费10元
|
||||||
|
else if (number >= 5000 && number < 10000) {
|
||||||
|
money = number * 10;
|
||||||
|
} //数量大于10000,每个收费8元
|
||||||
|
else if (number >= 10000) {
|
||||||
|
money = number * 8;
|
||||||
|
}
|
||||||
|
//数量超过1000的且需要收税的每个收税一元
|
||||||
|
if (number >= 1000 && isTax.equals(BooleanEnum.YES.getKey())) {
|
||||||
|
payBill.setPayMoney(money + number);
|
||||||
|
} else {
|
||||||
|
payBill.setPayMoney(money);
|
||||||
|
}
|
||||||
|
if (number > 0) {
|
||||||
|
factoryService.savePayBill(payBill);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
log.info("addPayBill end ...");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,9 +1,12 @@
|
||||||
package com.ifish.service;
|
package com.ifish.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import com.ifish.entity.FactoryList;
|
||||||
import com.ifish.entity.HardwareType;
|
import com.ifish.entity.HardwareType;
|
||||||
|
import com.ifish.entity.PayBill;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import com.ifish.entity.Device;
|
import com.ifish.entity.Device;
|
||||||
|
|
@ -31,4 +34,12 @@ public interface FactoryService {
|
||||||
|
|
||||||
Pagination<Device> getDeviceByPageNew(SearchFilter searchFilter,Set<HardwareType> hardwareTypeSet);
|
Pagination<Device> getDeviceByPageNew(SearchFilter searchFilter,Set<HardwareType> hardwareTypeSet);
|
||||||
|
|
||||||
|
//获取厂家下的设备总数量
|
||||||
|
int getDeviceCountByFactory(String factoryCode);
|
||||||
|
|
||||||
|
FactoryList get(String id);
|
||||||
|
|
||||||
|
List<FactoryList> getFactoryList();
|
||||||
|
|
||||||
|
void savePayBill(PayBill payBill);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
package com.ifish.serviceImpl;
|
package com.ifish.serviceImpl;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import com.ifish.dao.PayBillDao;
|
||||||
import com.ifish.entity.*;
|
import com.ifish.entity.*;
|
||||||
import jxl.Cell;
|
import jxl.Cell;
|
||||||
import jxl.Sheet;
|
import jxl.Sheet;
|
||||||
|
|
@ -44,12 +46,40 @@ public class FactoryServiceImpl implements FactoryService {
|
||||||
private FactoryListDao factoryListDao;
|
private FactoryListDao factoryListDao;
|
||||||
@Autowired
|
@Autowired
|
||||||
private OperateRecordDao operateRecordDao;
|
private OperateRecordDao operateRecordDao;
|
||||||
|
@Autowired
|
||||||
|
private PayBillDao payBillDao;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> getFactoryByVenderCode(String venderCode) {
|
public Map<String, String> getFactoryByVenderCode(String venderCode) {
|
||||||
return factoryListDao.getFactoryByVenderCode(venderCode);
|
return factoryListDao.getFactoryByVenderCode(venderCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getDeviceCountByFactory(String factoryCode) {
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
String year = String.valueOf(calendar.get(Calendar.YEAR));
|
||||||
|
String month = (calendar.get(Calendar.MONTH) < 10 ? "0" + calendar.get(Calendar.MONTH) : calendar.get(Calendar.MONTH)) + "";
|
||||||
|
int count = this.deviceDao.getNumber("SELECT count(1) from tbl_device td where td.factory_code = '"+ factoryCode +"' and str_to_date(td.authorize_time,'%Y-%m')='" + year + "-" + month + "-00'");
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FactoryList get(String id) {
|
||||||
|
return this.factoryListDao.get(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void savePayBill(PayBill payBill) {
|
||||||
|
payBillDao.save(payBill);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<FactoryList> getFactoryList() {
|
||||||
|
List<Criterion> queryList = new ArrayList<Criterion>();
|
||||||
|
List<FactoryList> factoryLists = this.factoryListDao.findByProperty(queryList.toArray(new Criterion[queryList.size()]));
|
||||||
|
return factoryLists;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void uploadExcel(String ip,String factoryCode,String brandCode,MultipartFile fileUpload) {
|
public void uploadExcel(String ip,String factoryCode,String brandCode,MultipartFile fileUpload) {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
<!-- @Controller注解的使用前提配置 -->
|
<!-- @Controller注解的使用前提配置 -->
|
||||||
<mvc:annotation-driven />
|
<mvc:annotation-driven />
|
||||||
<!-- 扫描指定包 -->
|
<!-- 扫描指定包 -->
|
||||||
<context:component-scan base-package="com.ifish.ueditor.action,com.ifish.action,com.ifish.exception" />
|
<context:component-scan base-package="com.ifish.ueditor.action,com.ifish.action,com.ifish.exception,com.ifish.job" />
|
||||||
<!-- 静态资源访问,资源缓存一年 -->
|
<!-- 静态资源访问,资源缓存一年 -->
|
||||||
<mvc:resources mapping="/ueditor/**" location="/ueditor/" cache-period="1500" />
|
<mvc:resources mapping="/ueditor/**" location="/ueditor/" cache-period="1500" />
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue