完善多账户和销售人员的展示

This commit is contained in:
季圣华
2021-04-26 22:29:15 +08:00
parent b35243f2f4
commit 16a42c2a95
5 changed files with 90 additions and 52 deletions

View File

@@ -48,17 +48,18 @@ public class PersonController {
/**
* 根据Id获取经手人信息
* @param personIDs
* @param personIds
* @param request
* @return
*/
@GetMapping(value = "/getPersonByIds")
public BaseResponseInfo getPersonByIds(@RequestParam("personIDs") String personIDs,
public BaseResponseInfo getPersonByIds(@RequestParam("personIds") String personIds,
HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
try {
String names = personService.getPersonByIds(personIDs);
Map<Long,String> personMap = personService.getPersonMap();
String names = personService.getPersonByMapAndIds(personMap, personIds);
map.put("names", names);
res.code = 200;
res.data = map;

View File

@@ -19,6 +19,8 @@ public class DepotHeadVo4List extends DepotHead{
private String materialsList;
private String salesManStr;
private String operTimeStr;
public String getProjectName() {
@@ -69,6 +71,14 @@ public class DepotHeadVo4List extends DepotHead{
this.materialsList = materialsList;
}
public String getSalesManStr() {
return salesManStr;
}
public void setSalesManStr(String salesManStr) {
this.salesManStr = salesManStr;
}
public String getOperTimeStr() {
return operTimeStr;
}

View File

@@ -514,6 +514,28 @@ public class AccountService {
return result;
}
public Map<Long,String> getAccountMap() throws Exception {
List<Account> accountList = getAccount();
Map<Long,String> accountMap = new HashMap<>();
for(Account account : accountList){
accountMap.put(account.getId(), account.getName());
}
return accountMap;
}
public String getAccountStrByIdAndMoney(Map<Long,String> accountMap, String accountIdList, String accountMoneyList){
StringBuffer sb = new StringBuffer();
accountIdList = accountIdList.replace("[", "").replace("]", "").replace("\"", "");
accountMoneyList = accountMoneyList.replace("[", "").replace("]", "").replace("\"", "");
List<Long> idList = StringUtil.strToLongList(accountIdList);
List<Long> moneyList = StringUtil.strToLongList(accountMoneyList);
for (int i = 0; i < idList.size(); i++) {
Long id = idList.get(i);
sb.append(accountMap.get(id) + "(" + moneyList.get(i) + "元) ");
}
return sb.toString();
}
public Map<String, Object> getStatistics(String name, String serialNo) {
Map<String, Object> map = new HashMap<>();
try {

View File

@@ -13,9 +13,11 @@ import com.jsh.erp.datasource.vo.DepotHeadVo4List;
import com.jsh.erp.datasource.vo.DepotHeadVo4StatementAccount;
import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.exception.JshException;
import com.jsh.erp.service.account.AccountService;
import com.jsh.erp.service.depotItem.DepotItemService;
import com.jsh.erp.service.log.LogService;
import com.jsh.erp.service.orgaUserRel.OrgaUserRelService;
import com.jsh.erp.service.person.PersonService;
import com.jsh.erp.service.redis.RedisService;
import com.jsh.erp.service.serialNumber.SerialNumberService;
import com.jsh.erp.service.supplier.SupplierService;
@@ -32,9 +34,7 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.*;
import static com.jsh.erp.utils.Tools.getCenternTime;
@@ -57,6 +57,10 @@ public class DepotHeadService {
@Resource
private OrgaUserRelService orgaUserRelService;
@Resource
private PersonService personService;
@Resource
private AccountService accountService;
@Resource
DepotItemMapperEx depotItemMapperEx;
@Resource
private LogService logService;
@@ -88,15 +92,18 @@ public class DepotHeadService {
public List<DepotHeadVo4List> select(String type, String subType, String roleType, String status, String number, String beginTime, String endTime,
String materialParam, String depotIds, int offset, int rows)throws Exception {
List<DepotHeadVo4List> resList = new ArrayList<DepotHeadVo4List>();
List<DepotHeadVo4List> list=null;
List<DepotHeadVo4List> list=new ArrayList<>();
try{
String [] creatorArray = getCreatorArray(roleType);
Map<Long,String> personMap = personService.getPersonMap();
Map<Long,String> accountMap = accountService.getAccountMap();
list=depotHeadMapperEx.selectByConditionDepotHead(type, subType, creatorArray, status, number, beginTime, endTime, materialParam, depotIds, offset, rows);
}catch(Exception e){
JshException.readFail(logger, e);
}
if (null != list) {
for (DepotHeadVo4List dh : list) {
if(accountMap!=null && StringUtil.isNotEmpty(dh.getAccountIdList()) && StringUtil.isNotEmpty(dh.getAccountMoneyList())) {
String accountStr = accountService.getAccountStrByIdAndMoney(accountMap, dh.getAccountIdList(), dh.getAccountMoneyList());
dh.setAccountName(accountStr);
}
if(dh.getAccountIdList() != null) {
String accountidlistStr = dh.getAccountIdList().replace("[", "").replace("]", "").replaceAll("\"", "");
dh.setAccountIdList(accountidlistStr);
@@ -105,16 +112,15 @@ public class DepotHeadService {
String accountmoneylistStr = dh.getAccountMoneyList().replace("[", "").replace("]", "").replaceAll("\"", "");
dh.setAccountMoneyList(accountmoneylistStr);
}
if(dh.getOtherMoneyList() != null) {
String otherMoneyListStr = dh.getOtherMoneyList().replace("[", "").replace("]", "").replaceAll("\"", "");
dh.setOtherMoneyList(otherMoneyListStr);
}
if(dh.getChangeAmount() != null) {
dh.setChangeAmount(dh.getChangeAmount().abs());
}
if(dh.getTotalPrice() != null) {
dh.setTotalPrice(dh.getTotalPrice().abs());
}
if(StringUtil.isNotEmpty(dh.getSalesMan())) {
dh.setSalesManStr(personService.getPersonByMapAndIds(personMap,dh.getSalesMan()));
}
if(dh.getOperTime() != null) {
dh.setOperTimeStr(getCenternTime(dh.getOperTime()));
}
@@ -122,6 +128,9 @@ public class DepotHeadService {
resList.add(dh);
}
}
}catch(Exception e){
JshException.readFail(logger, e);
}
return resList;
}

View File

@@ -23,9 +23,7 @@ import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.*;
@Service
public class PersonService {
@@ -198,22 +196,20 @@ public class PersonService {
return list==null?0:list.size();
}
public String getPersonByIds(String personIDs)throws Exception {
List<Long> ids = StringUtil.strToLongList(personIDs);
PersonExample example = new PersonExample();
example.createCriteria().andIdIn(ids).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
example.setOrderByClause("id asc");
List<Person> list =null;
try{
list=personMapper.selectByExample(example);
}catch(Exception e){
JshException.readFail(logger, e);
public Map<Long,String> getPersonMap() throws Exception {
List<Person> personList = getPerson();
Map<Long,String> personMap = new HashMap<>();
for(Person person : personList){
personMap.put(person.getId(), person.getName());
}
return personMap;
}
public String getPersonByMapAndIds(Map<Long,String> personMap, String personIds)throws Exception {
List<Long> ids = StringUtil.strToLongList(personIds);
StringBuffer sb = new StringBuffer();
if (null != list) {
for (Person person : list) {
sb.append(person.getName() + " ");
}
for(Long id: ids){
sb.append(personMap.get(id) + " ");
}
return sb.toString();
}