日期和sql优化
This commit is contained in:
@@ -272,9 +272,9 @@ public class AccountService {
|
||||
try {
|
||||
DepotHeadExample example = new DepotHeadExample();
|
||||
if (!timeStr.equals("")) {
|
||||
Date bTime = StringUtil.getDateByString(timeStr + "-01 00:00:00", null);
|
||||
Date eTime = StringUtil.getDateByString(timeStr + "-31 00:00:00", null);
|
||||
Date mTime = StringUtil.getDateByString(timeStr + "-01 00:00:00", null);
|
||||
Date bTime = StringUtil.getDateByString(Tools.firstDayOfMonth(timeStr) + BusinessConstants.DAY_FIRST_TIME, null);
|
||||
Date eTime = StringUtil.getDateByString(Tools.lastDayOfMonth(timeStr) + BusinessConstants.DAY_LAST_TIME, null);
|
||||
Date mTime = StringUtil.getDateByString(Tools.firstDayOfMonth(timeStr) + BusinessConstants.DAY_FIRST_TIME, null);
|
||||
if (type.equals("month")) {
|
||||
example.createCriteria().andAccountIdEqualTo(id).andPayTypeNotEqualTo("预付款")
|
||||
.andOperTimeGreaterThanOrEqualTo(bTime).andOperTimeLessThanOrEqualTo(eTime)
|
||||
@@ -317,9 +317,9 @@ public class AccountService {
|
||||
try {
|
||||
AccountHeadExample example = new AccountHeadExample();
|
||||
if (!timeStr.equals("")) {
|
||||
Date bTime = StringUtil.getDateByString(timeStr + "-01 00:00:00", null);
|
||||
Date eTime = StringUtil.getDateByString(timeStr + "-31 00:00:00", null);
|
||||
Date mTime = StringUtil.getDateByString(timeStr + "-01 00:00:00", null);
|
||||
Date bTime = StringUtil.getDateByString(Tools.firstDayOfMonth(timeStr) + BusinessConstants.DAY_FIRST_TIME, null);
|
||||
Date eTime = StringUtil.getDateByString(Tools.lastDayOfMonth(timeStr) + BusinessConstants.DAY_LAST_TIME, null);
|
||||
Date mTime = StringUtil.getDateByString(Tools.firstDayOfMonth(timeStr) + BusinessConstants.DAY_FIRST_TIME, null);
|
||||
if (type.equals("month")) {
|
||||
example.createCriteria().andAccountIdEqualTo(id)
|
||||
.andBillTimeGreaterThanOrEqualTo(bTime).andBillTimeLessThanOrEqualTo(eTime)
|
||||
@@ -363,9 +363,9 @@ public class AccountService {
|
||||
try {
|
||||
AccountHeadExample example = new AccountHeadExample();
|
||||
if (!timeStr.equals("")) {
|
||||
Date bTime = StringUtil.getDateByString(timeStr + "-01 00:00:00", null);
|
||||
Date eTime = StringUtil.getDateByString(timeStr + "-31 00:00:00", null);
|
||||
Date mTime = StringUtil.getDateByString(timeStr + "-01 00:00:00", null);
|
||||
Date bTime = StringUtil.getDateByString(Tools.firstDayOfMonth(timeStr) + BusinessConstants.DAY_FIRST_TIME, null);
|
||||
Date eTime = StringUtil.getDateByString(Tools.lastDayOfMonth(timeStr) + BusinessConstants.DAY_LAST_TIME, null);
|
||||
Date mTime = StringUtil.getDateByString(Tools.firstDayOfMonth(timeStr) + BusinessConstants.DAY_FIRST_TIME, null);
|
||||
if (type.equals("month")) {
|
||||
example.createCriteria().andBillTimeGreaterThanOrEqualTo(bTime).andBillTimeLessThanOrEqualTo(eTime)
|
||||
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
||||
@@ -422,9 +422,9 @@ public class AccountService {
|
||||
try {
|
||||
DepotHeadExample example = new DepotHeadExample();
|
||||
if (!timeStr.equals("")) {
|
||||
Date bTime = StringUtil.getDateByString(timeStr + "-01 00:00:00", null);
|
||||
Date eTime = StringUtil.getDateByString(timeStr + "-31 00:00:00", null);
|
||||
Date mTime = StringUtil.getDateByString(timeStr + "-01 00:00:00", null);
|
||||
Date bTime = StringUtil.getDateByString(Tools.firstDayOfMonth(timeStr) + BusinessConstants.DAY_FIRST_TIME, null);
|
||||
Date eTime = StringUtil.getDateByString(Tools.lastDayOfMonth(timeStr) + BusinessConstants.DAY_LAST_TIME, null);
|
||||
Date mTime = StringUtil.getDateByString(Tools.firstDayOfMonth(timeStr) + BusinessConstants.DAY_FIRST_TIME, null);
|
||||
if (type.equals("month")) {
|
||||
example.createCriteria().andAccountIdListLike("%" +id.toString() + "%")
|
||||
.andOperTimeGreaterThanOrEqualTo(bTime).andOperTimeLessThanOrEqualTo(eTime)
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.jsh.erp.service.log.LogService;
|
||||
import com.jsh.erp.service.orgaUserRel.OrgaUserRelService;
|
||||
import com.jsh.erp.service.user.UserService;
|
||||
import com.jsh.erp.utils.StringUtil;
|
||||
import com.jsh.erp.utils.Tools;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -88,6 +89,8 @@ public class AccountHeadService {
|
||||
List<AccountHeadVo4ListEx> list=null;
|
||||
try{
|
||||
String [] creatorArray = getCreatorArray(roleType);
|
||||
beginTime = Tools.parseDayToTime(beginTime,BusinessConstants.DAY_FIRST_TIME);
|
||||
endTime = Tools.parseDayToTime(endTime,BusinessConstants.DAY_LAST_TIME);
|
||||
list = accountHeadMapperEx.selectByConditionAccountHead(type, creatorArray, billNo, beginTime, endTime, offset, rows);
|
||||
}catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
@@ -111,6 +114,8 @@ public class AccountHeadService {
|
||||
Long result=null;
|
||||
try{
|
||||
String [] creatorArray = getCreatorArray(roleType);
|
||||
beginTime = Tools.parseDayToTime(beginTime,BusinessConstants.DAY_FIRST_TIME);
|
||||
endTime = Tools.parseDayToTime(endTime,BusinessConstants.DAY_LAST_TIME);
|
||||
result = accountHeadMapperEx.countsByAccountHead(type, creatorArray, billNo, beginTime, endTime);
|
||||
}catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.jsh.erp.service.serialNumber.SerialNumberService;
|
||||
import com.jsh.erp.service.supplier.SupplierService;
|
||||
import com.jsh.erp.service.user.UserService;
|
||||
import com.jsh.erp.utils.StringUtil;
|
||||
import com.jsh.erp.utils.Tools;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -101,6 +102,8 @@ public class DepotHeadService {
|
||||
String [] creatorArray = getCreatorArray(roleType);
|
||||
Map<Long,String> personMap = personService.getPersonMap();
|
||||
Map<Long,String> accountMap = accountService.getAccountMap();
|
||||
beginTime = Tools.parseDayToTime(beginTime,BusinessConstants.DAY_FIRST_TIME);
|
||||
endTime = Tools.parseDayToTime(endTime,BusinessConstants.DAY_LAST_TIME);
|
||||
list=depotHeadMapperEx.selectByConditionDepotHead(type, subType, creatorArray, status, number, beginTime, endTime, materialParam, depotIds, offset, rows);
|
||||
if (null != list) {
|
||||
for (DepotHeadVo4List dh : list) {
|
||||
@@ -144,6 +147,8 @@ public class DepotHeadService {
|
||||
try{
|
||||
String depotIds = depotService.findDepotStrByCurrentUser();
|
||||
String [] creatorArray = getCreatorArray(roleType);
|
||||
beginTime = Tools.parseDayToTime(beginTime,BusinessConstants.DAY_FIRST_TIME);
|
||||
endTime = Tools.parseDayToTime(endTime,BusinessConstants.DAY_LAST_TIME);
|
||||
result=depotHeadMapperEx.countsByDepotHead(type, subType, creatorArray, status, number, beginTime, endTime, materialParam, depotIds);
|
||||
}catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
|
||||
@@ -263,8 +263,8 @@ public class DepotItemService {
|
||||
public BigDecimal buyOrSale(String type, String subType, Long MId, String monthTime, String sumType) throws Exception{
|
||||
BigDecimal result= BigDecimal.ZERO;
|
||||
try{
|
||||
String beginTime = monthTime + "-01 00:00:00";
|
||||
String endTime = Tools.lastDayOfMonth(monthTime) +" 23:59:59";
|
||||
String beginTime = Tools.firstDayOfMonth(monthTime) + BusinessConstants.DAY_FIRST_TIME;
|
||||
String endTime = Tools.lastDayOfMonth(monthTime) + BusinessConstants.DAY_LAST_TIME;
|
||||
if (SUM_TYPE.equals(sumType)) {
|
||||
result= depotItemMapperEx.buyOrSaleNumber(type, subType, MId, beginTime, endTime, sumType);
|
||||
} else {
|
||||
@@ -288,8 +288,8 @@ public class DepotItemService {
|
||||
public BigDecimal inOrOutPrice(String type, String subType, String month) throws Exception{
|
||||
BigDecimal result= BigDecimal.ZERO;
|
||||
try{
|
||||
String beginTime = month + "-01 00:00:00";
|
||||
String endTime = Tools.lastDayOfMonth(month) +" 23:59:59";
|
||||
String beginTime = Tools.firstDayOfMonth(month) + BusinessConstants.DAY_FIRST_TIME;
|
||||
String endTime = Tools.lastDayOfMonth(month) + BusinessConstants.DAY_LAST_TIME;
|
||||
result = depotItemMapperEx.inOrOutPrice(type, subType, beginTime, endTime);
|
||||
}catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
|
||||
Reference in New Issue
Block a user