first commit
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
package lingtao.net.service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import lingtao.net.bean.Article;
|
||||
import lingtao.net.bean.Msg;
|
||||
import lingtao.net.dao.ArticleMapper;
|
||||
|
||||
@Service
|
||||
public class ArticleService {
|
||||
|
||||
@Autowired
|
||||
ArticleMapper articlesMapper;
|
||||
|
||||
public List<Article> getArticle(Article article) {
|
||||
return articlesMapper.getArticle(article);
|
||||
|
||||
}
|
||||
|
||||
public Msg addArticle(Article article) {
|
||||
try {
|
||||
article.setCreateDate(new Date());
|
||||
articlesMapper.insertSelective(article);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return Msg.fail("新增失败");
|
||||
}
|
||||
}
|
||||
|
||||
public Msg updateArticleById(Article article) {
|
||||
try {
|
||||
article.setUpdateDate(new Date());
|
||||
articlesMapper.updateByPrimaryKeySelective(article);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return Msg.fail("修改失败");
|
||||
}
|
||||
}
|
||||
|
||||
public Msg delArticleById(Integer id) {
|
||||
try {
|
||||
articlesMapper.deleteByPrimaryKey(id);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return Msg.fail("删除失败");
|
||||
}
|
||||
}
|
||||
|
||||
public Article articleInfo(Integer id) {
|
||||
try {
|
||||
return articlesMapper.selectByPrimaryKey(id);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package lingtao.net.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import lingtao.net.bean.Bug;
|
||||
import lingtao.net.bean.Msg;
|
||||
import lingtao.net.bean.SysUser;
|
||||
import lingtao.net.dao.BugMapper;
|
||||
|
||||
@Service
|
||||
public class BugService {
|
||||
|
||||
@Autowired
|
||||
private BugMapper bugMapper;
|
||||
|
||||
public List<Bug> getBugs(Bug bug) {
|
||||
return bugMapper.getBugs(bug);
|
||||
}
|
||||
|
||||
public Msg addBug(Bug bug, HttpSession session) {
|
||||
SysUser user = (SysUser) session.getAttribute("USER_SESSION");
|
||||
bug.setCreateBy(user.getRealname());
|
||||
int i = bugMapper.addBug(bug);
|
||||
if (i < 0) {
|
||||
return Msg.fail();
|
||||
}
|
||||
return Msg.success();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,677 @@
|
||||
package lingtao.net.service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import lingtao.net.bean.CustomerAward;
|
||||
import lingtao.net.bean.Msg;
|
||||
import lingtao.net.bean.SysUser;
|
||||
import lingtao.net.dao.CustomerAwardMapper;
|
||||
import lingtao.net.util.DateFormatUtils;
|
||||
import lingtao.net.util.ExcelUtils;
|
||||
|
||||
@Service
|
||||
public class CustomerAwardService {
|
||||
|
||||
@Autowired
|
||||
private CustomerAwardMapper customerAwardMapper;
|
||||
|
||||
public List<CustomerAward> getCustomerAward(CustomerAward customerAward) {
|
||||
customerAward.setCreateTimeEnd(new DateFormatUtils().formatEndTime(customerAward.getCreateTimeBegin()));
|
||||
customerAward.setCreateTimeBegin(new DateFormatUtils().formatBeginTime(customerAward.getCreateTimeBegin()));
|
||||
return customerAwardMapper.getCustomerAward(customerAward);
|
||||
}
|
||||
|
||||
// 批量删除
|
||||
public Msg deleteBatch(int[] ints) {
|
||||
try {
|
||||
customerAwardMapper.deleteBatch(ints);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getArardShopname() {
|
||||
return customerAwardMapper.getArardShopname();
|
||||
}
|
||||
|
||||
public Msg ajaxUploadExcel(MultipartFile file) throws Exception {
|
||||
if (file.isEmpty()) {
|
||||
throw new Exception("文件不存在!");
|
||||
}
|
||||
SysUser user = (SysUser) SecurityUtils.getSubject().getPrincipal();
|
||||
InputStream in = null;
|
||||
List<List<Object>> listob = null;
|
||||
String awardDate = "";
|
||||
List<String> matches = null;
|
||||
List<CustomerAward> list = new ArrayList<CustomerAward>(1000);
|
||||
try {
|
||||
in = file.getInputStream();
|
||||
listob = new ExcelUtils().getBankListByExcel(in, file.getOriginalFilename());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
String filename = file.getOriginalFilename();
|
||||
// 获取字符串中的日期正则
|
||||
Pattern p = Pattern.compile("(\\d{1,4}[-|\\/]\\d{1,2}[-|\\/]\\d{1,2})",
|
||||
Pattern.CASE_INSENSITIVE | Pattern.MULTILINE);
|
||||
Matcher matcher = p.matcher(listob.get(0).toString().trim());
|
||||
|
||||
if (matcher.find() && matcher.groupCount() >= 1) {
|
||||
matches = new ArrayList<String>();
|
||||
for (int i = 1; i <= matcher.groupCount(); i++) {
|
||||
String temp = matcher.group(i);
|
||||
matches.add(temp);
|
||||
}
|
||||
}
|
||||
if (matches.size() > 0) {
|
||||
awardDate = ((String) matches.get(0)).trim();
|
||||
}
|
||||
|
||||
filename = filename.substring(0, filename.indexOf("."));
|
||||
System.out.println(filename);
|
||||
for (int i = 0; i < listob.size(); i++) {
|
||||
synchronized (this) {
|
||||
CustomerAward vo = new CustomerAward();
|
||||
List<Object> lo = listob.get(i);
|
||||
if (lo.size() == 0 || lo.size() == 1) {
|
||||
System.out.println("++++++++++++++");
|
||||
continue;
|
||||
}
|
||||
String nickname = String.valueOf(lo.get(0)).trim();
|
||||
String payPercent2 = (String.valueOf(lo.get(1)).trim());
|
||||
String askNumber2 = (String.valueOf(lo.get(2)).trim());
|
||||
String customerPrice2 = (String.valueOf(lo.get(3)).trim());
|
||||
payPercent2 = payPercent2.replaceAll("%", " ");
|
||||
Double payPercent = 0.0;
|
||||
Double askNumber = 0.0;
|
||||
Double customerPrice = 0.0;
|
||||
try {
|
||||
payPercent = Double.valueOf(payPercent2);
|
||||
askNumber = Double.valueOf(askNumber2);
|
||||
customerPrice = Double.valueOf(customerPrice2);
|
||||
} catch (NumberFormatException e) {
|
||||
continue;
|
||||
}
|
||||
if (payPercent == 1) {
|
||||
payPercent = 100.0;
|
||||
}
|
||||
int award = 0;
|
||||
switch (filename) {
|
||||
case "菇凉":
|
||||
award = guliang(nickname, payPercent, askNumber, customerPrice);
|
||||
break;
|
||||
case "榆家":
|
||||
award = yujia(nickname, payPercent, askNumber, customerPrice);
|
||||
break;
|
||||
case "奥丽芙":
|
||||
award = aolifu(nickname, payPercent, askNumber, customerPrice);
|
||||
break;
|
||||
case "翊喜":
|
||||
award = yixi(nickname, payPercent, askNumber, customerPrice);
|
||||
break;
|
||||
case "航和":
|
||||
award = hanghe(nickname, payPercent, askNumber, customerPrice);
|
||||
break;
|
||||
case "卓胜":
|
||||
award = zhuosheng(nickname, payPercent, askNumber, customerPrice);
|
||||
break;
|
||||
case "欣克利":
|
||||
award = xinkeli(nickname, payPercent, askNumber, customerPrice);
|
||||
break;
|
||||
case "米笛儿":
|
||||
award = midier(nickname, payPercent, askNumber, customerPrice);
|
||||
break;
|
||||
case "阳光猫":
|
||||
award = yangguangmao(nickname, payPercent, askNumber, customerPrice);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
vo.setNickname(nickname);
|
||||
vo.setPayPercent(payPercent);
|
||||
vo.setAskNumber(askNumber);
|
||||
vo.setCustomerPrice(customerPrice);
|
||||
vo.setAward(award);
|
||||
vo.setShopname(filename);
|
||||
vo.setAwardDate(awardDate);
|
||||
vo.setCreator(user.getRealname());
|
||||
list.add(vo);
|
||||
}
|
||||
}
|
||||
if (list.size() > 0) {
|
||||
customerAwardMapper.insertForeach(list);
|
||||
}
|
||||
in.close();
|
||||
return Msg.success();
|
||||
|
||||
}
|
||||
|
||||
// 菇凉店客服日奖励
|
||||
private int guliang(String nickname, Double payPercent, Double askNumber, Double customerPrice) {
|
||||
// IF(C4>=46,"奖励档80元",IF(C4>=44,"奖励档60元",IF(C4>=43,"奖励档50元",IF(C4>=42,"奖励档40元",
|
||||
// IF(C4>=41,"奖励档30元",IF(C4>=40,"奖励档20元"))))))
|
||||
int payPercentPrice = 0;
|
||||
if (payPercent >= 46) {
|
||||
payPercentPrice = 80;
|
||||
} else if (payPercent >= 44) {
|
||||
payPercentPrice = 60;
|
||||
} else if (payPercent >= 43) {
|
||||
payPercentPrice = 50;
|
||||
} else if (payPercent >= 42) {
|
||||
payPercentPrice = 40;
|
||||
} else if (payPercent >= 41) {
|
||||
payPercentPrice = 30;
|
||||
} else if (payPercent >= 40) {
|
||||
payPercentPrice = 20;
|
||||
}
|
||||
|
||||
// IF(D4>=70,"询单人数档80元",IF(D4>=50,"询单人数档60元")))
|
||||
int askNumberPrice = 0;
|
||||
if ("平均".equals(nickname)) {
|
||||
// IF(D4>=50%,"询单人数档80元",IF(D4>=30%,"询单人数档60元")))
|
||||
if (askNumber >= 0.5) {
|
||||
askNumberPrice = 80;
|
||||
} else if (askNumber >= 0.3) {
|
||||
askNumberPrice = 60;
|
||||
}
|
||||
} else {
|
||||
if (askNumber >= 70) {
|
||||
askNumberPrice = 80;
|
||||
} else if (askNumber >= 50) {
|
||||
askNumberPrice = 60;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// =IF(E4>=240,"客单档80元",IF(E4>=220,"客单档60元",IF(E4>=200,"客单档50元",IF(E4>=190,"客单档40元",
|
||||
// IF(E4>=180,"客单档30元",IF(E4>=0,"客单档20元"))))))
|
||||
int customerPricePrice = 0;
|
||||
if (customerPrice >= 240) {
|
||||
customerPricePrice = 80;
|
||||
} else if (customerPrice >= 220) {
|
||||
customerPricePrice = 60;
|
||||
} else if (customerPrice >= 200) {
|
||||
customerPricePrice = 50;
|
||||
} else if (customerPrice >= 190) {
|
||||
customerPricePrice = 40;
|
||||
} else if (customerPrice >= 180) {
|
||||
customerPricePrice = 30;
|
||||
} else if (customerPrice >= 0) {
|
||||
customerPricePrice = 20;
|
||||
}
|
||||
|
||||
double award = Math.min(Math.min(payPercentPrice, askNumberPrice), customerPricePrice);
|
||||
|
||||
return (int) award;
|
||||
}
|
||||
|
||||
// 榆家店客服日奖励
|
||||
private int yujia(String nickname, Double payPercent, Double askNumber, Double customerPrice) {
|
||||
// IF(C4>=43,"奖励档80元",IF(C4>=42,"奖励档60元",IF(C4>=41,"奖励档50元",IF(C4>=40,"奖励档40元",
|
||||
// IF(C4>=39,"奖励档30元",IF(C4>=38,"奖励档20元"))))))
|
||||
int payPercentPrice = 0;
|
||||
if (payPercent >= 43) {
|
||||
payPercentPrice = 80;
|
||||
} else if (payPercent >= 42) {
|
||||
payPercentPrice = 60;
|
||||
} else if (payPercent >= 41) {
|
||||
payPercentPrice = 50;
|
||||
} else if (payPercent >= 40) {
|
||||
payPercentPrice = 40;
|
||||
} else if (payPercent >= 39) {
|
||||
payPercentPrice = 30;
|
||||
} else if (payPercent >= 38) {
|
||||
payPercentPrice = 20;
|
||||
}
|
||||
|
||||
// IF(D4>=70,"询单人数档80元",IF(D4>=50,"询单人数档60元")))
|
||||
int askNumberPrice = 0;
|
||||
if ("平均".equals(nickname)) {
|
||||
// IF(D4>=50%,"询单人数档80元",IF(D4>=30%,"询单人数档60元")))
|
||||
if (askNumber >= 0.5) {
|
||||
askNumberPrice = 80;
|
||||
} else if (askNumber >= 0.3) {
|
||||
askNumberPrice = 60;
|
||||
}
|
||||
} else {
|
||||
if (askNumber >= 70) {
|
||||
askNumberPrice = 80;
|
||||
} else if (askNumber >= 50) {
|
||||
askNumberPrice = 60;
|
||||
}
|
||||
}
|
||||
|
||||
// =IF(E4>=190,"客单档80元",IF(E4>=180,"客单档60元",IF(E4>=170,"客单档50元",IF(E4>=160,"客单档40元",
|
||||
// IF(E4>=150,"客单档30元",IF(E4>=0,"客单档20元"))))))
|
||||
int customerPricePrice = 0;
|
||||
if (customerPrice >= 190) {
|
||||
customerPricePrice = 80;
|
||||
} else if (customerPrice >= 180) {
|
||||
customerPricePrice = 60;
|
||||
} else if (customerPrice >= 170) {
|
||||
customerPricePrice = 50;
|
||||
} else if (customerPrice >= 160) {
|
||||
customerPricePrice = 40;
|
||||
} else if (customerPrice >= 150) {
|
||||
customerPricePrice = 30;
|
||||
} else if (customerPrice >= 0) {
|
||||
customerPricePrice = 20;
|
||||
}
|
||||
|
||||
double award = Math.min(Math.min(payPercentPrice, askNumberPrice), customerPricePrice);
|
||||
|
||||
return (int) award;
|
||||
}
|
||||
|
||||
// 奥丽芙店客服日奖励
|
||||
private int aolifu(String nickname, Double payPercent, Double askNumber, Double customerPrice) {
|
||||
// IF(C4>=43,"奖励档80元",IF(C4>=42,"奖励档60元",IF(C4>=41,"奖励档50元",IF(C4>=40,"奖励档40元",
|
||||
// IF(C4>=39,"奖励档30元",IF(C4>=38,"奖励档20元"))))))
|
||||
int payPercentPrice = 0;
|
||||
if (payPercent >= 43) {
|
||||
payPercentPrice = 80;
|
||||
} else if (payPercent >= 42) {
|
||||
payPercentPrice = 60;
|
||||
} else if (payPercent >= 41) {
|
||||
payPercentPrice = 50;
|
||||
} else if (payPercent >= 40) {
|
||||
payPercentPrice = 40;
|
||||
} else if (payPercent >= 39) {
|
||||
payPercentPrice = 30;
|
||||
} else if (payPercent >= 38) {
|
||||
payPercentPrice = 20;
|
||||
}
|
||||
|
||||
// IF(D4>=70,"询单人数档80元",IF(D4>=50,"询单人数档60元")))
|
||||
int askNumberPrice = 0;
|
||||
if ("平均".equals(nickname)) {
|
||||
// IF(D4>=50%,"询单人数档80元",IF(D4>=30%,"询单人数档60元")))
|
||||
if (askNumber >= 0.5) {
|
||||
askNumberPrice = 80;
|
||||
} else if (askNumber >= 0.3) {
|
||||
askNumberPrice = 60;
|
||||
}
|
||||
} else {
|
||||
if (askNumber >= 70) {
|
||||
askNumberPrice = 80;
|
||||
} else if (askNumber >= 50) {
|
||||
askNumberPrice = 60;
|
||||
}
|
||||
}
|
||||
|
||||
// =IF(E4>=240,"客单档80元",IF(E4>=220,"客单档60元",IF(E4>=200,"客单档50元",IF(E4>=190,"客单档40元",
|
||||
// IF(E4>=180,"客单档30元",IF(E4>=0,"客单档20元"))))))
|
||||
int customerPricePrice = 0;
|
||||
if (customerPrice >= 240) {
|
||||
customerPricePrice = 80;
|
||||
} else if (customerPrice >= 220) {
|
||||
customerPricePrice = 60;
|
||||
} else if (customerPrice >= 200) {
|
||||
customerPricePrice = 50;
|
||||
} else if (customerPrice >= 190) {
|
||||
customerPricePrice = 40;
|
||||
} else if (customerPrice >= 180) {
|
||||
customerPricePrice = 30;
|
||||
} else if (customerPrice >= 0) {
|
||||
customerPricePrice = 20;
|
||||
}
|
||||
|
||||
double award = Math.min(Math.min(payPercentPrice, askNumberPrice), customerPricePrice);
|
||||
|
||||
return (int) award;
|
||||
}
|
||||
|
||||
// 翊喜店客服日奖励
|
||||
private int yixi(String nickname, Double payPercent, Double askNumber, Double customerPrice) {
|
||||
// IF(C4>=42,"奖励档80元",IF(C4>=41,"奖励档60元",IF(C4>=40,"奖励档50元",IF(C4>=39,"奖励档40元",
|
||||
// IF(C4>=38,"奖励档30元",IF(C4>=37,"奖励档20元"))))))
|
||||
int payPercentPrice = 0;
|
||||
if (payPercent >= 42) {
|
||||
payPercentPrice = 80;
|
||||
} else if (payPercent >= 41) {
|
||||
payPercentPrice = 60;
|
||||
} else if (payPercent >= 40) {
|
||||
payPercentPrice = 50;
|
||||
} else if (payPercent >= 39) {
|
||||
payPercentPrice = 40;
|
||||
} else if (payPercent >= 38) {
|
||||
payPercentPrice = 30;
|
||||
} else if (payPercent >= 37) {
|
||||
payPercentPrice = 20;
|
||||
}
|
||||
|
||||
// IF(D4>=75,"询单人数档80元",IF(D4>=55,"询单人数档60元")))
|
||||
int askNumberPrice = 0;
|
||||
if ("平均".equals(nickname)) {
|
||||
// IF(D4>=50%,"询单人数档80元",IF(D4>=30%,"询单人数档60元")))
|
||||
if (askNumber >= 0.5) {
|
||||
askNumberPrice = 80;
|
||||
} else if (askNumber >= 0.3) {
|
||||
askNumberPrice = 60;
|
||||
}
|
||||
} else {
|
||||
if (askNumber >= 75) {
|
||||
askNumberPrice = 80;
|
||||
} else if (askNumber >= 55) {
|
||||
askNumberPrice = 60;
|
||||
}
|
||||
}
|
||||
|
||||
// =IF(E4>=190,"客单档80元",IF(E4>=180,"客单档60元",IF(E4>=170,"客单档50元",IF(E4>=160,"客单档40元",
|
||||
// IF(E4>=150,"客单档30元",IF(E4>=0,"客单档20元"))))))
|
||||
int customerPricePrice = 0;
|
||||
if (customerPrice >= 190) {
|
||||
customerPricePrice = 80;
|
||||
} else if (customerPrice >= 180) {
|
||||
customerPricePrice = 60;
|
||||
} else if (customerPrice >= 170) {
|
||||
customerPricePrice = 50;
|
||||
} else if (customerPrice >= 160) {
|
||||
customerPricePrice = 40;
|
||||
} else if (customerPrice >= 150) {
|
||||
customerPricePrice = 30;
|
||||
} else if (customerPrice >= 0) {
|
||||
customerPricePrice = 20;
|
||||
}
|
||||
|
||||
double award = Math.min(Math.min(payPercentPrice, askNumberPrice), customerPricePrice);
|
||||
|
||||
return (int) award;
|
||||
}
|
||||
|
||||
// 航和店客服日奖励
|
||||
private int hanghe(String nickname, Double payPercent, Double askNumber, Double customerPrice) {
|
||||
// IF(C4>=40,"奖励档80元",IF(C4>=38,"奖励档60元",IF(C4>=37,"奖励档50元",IF(C4>=36,"奖励档40元",
|
||||
// IF(C4>=35,"奖励档30元",IF(C4>=34,"奖励档20元"))))))
|
||||
int payPercentPrice = 0;
|
||||
if (payPercent >= 40) {
|
||||
payPercentPrice = 80;
|
||||
} else if (payPercent >= 38) {
|
||||
payPercentPrice = 60;
|
||||
} else if (payPercent >= 37) {
|
||||
payPercentPrice = 50;
|
||||
} else if (payPercent >= 36) {
|
||||
payPercentPrice = 40;
|
||||
} else if (payPercent >= 35) {
|
||||
payPercentPrice = 30;
|
||||
} else if (payPercent >= 34) {
|
||||
payPercentPrice = 20;
|
||||
}
|
||||
|
||||
// IF(D4>=80,"询单人数档80元",IF(D4>=60,"询单人数档60元")))
|
||||
int askNumberPrice = 0;
|
||||
if ("平均".equals(nickname)) {
|
||||
// IF(D4>=50%,"询单人数档80元",IF(D4>=30%,"询单人数档60元")))
|
||||
// 航和没有这个,写个大数字
|
||||
askNumberPrice = 100;
|
||||
} else {
|
||||
if (askNumber >= 80) {
|
||||
askNumberPrice = 80;
|
||||
} else if (askNumber >= 60) {
|
||||
askNumberPrice = 60;
|
||||
}
|
||||
}
|
||||
|
||||
// =IF(E4>=195,"客单档80元",IF(E4>=185,"客单档60元",IF(E4>=175,"客单档50元",IF(E4>=165,"客单档40元",
|
||||
// IF(E4>=155,"客单档30元",IF(E4>=0,"客单档20元"))))))
|
||||
int customerPricePrice = 0;
|
||||
if (customerPrice >= 195) {
|
||||
customerPricePrice = 80;
|
||||
} else if (customerPrice >= 185) {
|
||||
customerPricePrice = 60;
|
||||
} else if (customerPrice >= 175) {
|
||||
customerPricePrice = 50;
|
||||
} else if (customerPrice >= 165) {
|
||||
customerPricePrice = 40;
|
||||
} else if (customerPrice >= 155) {
|
||||
customerPricePrice = 30;
|
||||
} else if (customerPrice >= 0) {
|
||||
customerPricePrice = 20;
|
||||
}
|
||||
|
||||
double award = Math.min(Math.min(payPercentPrice, askNumberPrice), customerPricePrice);
|
||||
|
||||
return (int) award;
|
||||
}
|
||||
|
||||
// 卓胜店客服日奖励
|
||||
private int zhuosheng(String nickname, Double payPercent, Double askNumber, Double customerPrice) {
|
||||
// IF(C4>=38,"奖励档80元",IF(C4>=37,"奖励档60元",IF(C4>=36,"奖励档50元",IF(C4>=35,"奖励档40元",
|
||||
// IF(C4>=34,"奖励档30元",IF(C4>=33,"奖励档20元"))))))
|
||||
int payPercentPrice = 0;
|
||||
if (payPercent >= 38) {
|
||||
payPercentPrice = 80;
|
||||
} else if (payPercent >= 37) {
|
||||
payPercentPrice = 60;
|
||||
} else if (payPercent >= 36) {
|
||||
payPercentPrice = 50;
|
||||
} else if (payPercent >= 35) {
|
||||
payPercentPrice = 40;
|
||||
} else if (payPercent >= 34) {
|
||||
payPercentPrice = 30;
|
||||
} else if (payPercent >= 33) {
|
||||
payPercentPrice = 20;
|
||||
}
|
||||
|
||||
// IF(D4>=65,"询单人数档80元",IF(D4>=45,"询单人数档60元")))
|
||||
int askNumberPrice = 0;
|
||||
if ("平均".equals(nickname)) {
|
||||
// IF(D4>=50%,"询单人数档80元",IF(D4>=30%,"询单人数档60元")))
|
||||
if (askNumber >= 0.5) {
|
||||
askNumberPrice = 80;
|
||||
} else if (askNumber >= 0.3) {
|
||||
askNumberPrice = 60;
|
||||
}
|
||||
} else {
|
||||
if (askNumber >= 65) {
|
||||
askNumberPrice = 80;
|
||||
} else if (askNumber >= 45) {
|
||||
askNumberPrice = 60;
|
||||
}
|
||||
}
|
||||
|
||||
// IF(E4>=190,"客单档80元",IF(E4>=180,"客单档60元",IF(E4>=170,"客单档50元",IF(E4>=160,"客单档40元",
|
||||
// IF(E4>=150,"客单档30元",IF(E4>=0,"客单档20元"))))))
|
||||
int customerPricePrice = 0;
|
||||
if (customerPrice >= 190) {
|
||||
customerPricePrice = 80;
|
||||
} else if (customerPrice >= 180) {
|
||||
customerPricePrice = 60;
|
||||
} else if (customerPrice >= 170) {
|
||||
customerPricePrice = 50;
|
||||
} else if (customerPrice >= 160) {
|
||||
customerPricePrice = 40;
|
||||
} else if (customerPrice >= 150) {
|
||||
customerPricePrice = 30;
|
||||
} else if (customerPrice >= 0) {
|
||||
customerPricePrice = 20;
|
||||
}
|
||||
double award = Math.min(Math.min(payPercentPrice, askNumberPrice), customerPricePrice);
|
||||
|
||||
return (int) award;
|
||||
}
|
||||
|
||||
// 欣克利店客服日奖励
|
||||
private int xinkeli(String nickname, Double payPercent, Double askNumber, Double customerPrice) {
|
||||
// IF(C4>=37,"奖励档80元",IF(C4>=36,"奖励档60元",IF(C4>=35,"奖励档50元",IF(C4>=34,"奖励档40元",
|
||||
// IF(C4>=33,"奖励档30元",IF(C4>=32,"奖励档20元"))))))
|
||||
int payPercentPrice = 0;
|
||||
if (payPercent >= 37) {
|
||||
payPercentPrice = 80;
|
||||
} else if (payPercent >= 36) {
|
||||
payPercentPrice = 60;
|
||||
} else if (payPercent >= 35) {
|
||||
payPercentPrice = 50;
|
||||
} else if (payPercent >= 34) {
|
||||
payPercentPrice = 40;
|
||||
} else if (payPercent >= 33) {
|
||||
payPercentPrice = 30;
|
||||
} else if (payPercent >= 32) {
|
||||
payPercentPrice = 20;
|
||||
}
|
||||
|
||||
// IF(D4>=50,"询单人数档80元",IF(D4>=30,"询单人数档60元")))
|
||||
int askNumberPrice = 0;
|
||||
if ("平均".equals(nickname)) {
|
||||
// IF(D4>=50%,"询单人数档80元",IF(D4>=30%,"询单人数档60元")))
|
||||
if (askNumber >= 0.5) {
|
||||
askNumberPrice = 80;
|
||||
} else if (askNumber >= 0.3) {
|
||||
askNumberPrice = 60;
|
||||
}
|
||||
} else {
|
||||
if (askNumber >= 50) {
|
||||
askNumberPrice = 80;
|
||||
} else if (askNumber >= 30) {
|
||||
askNumberPrice = 60;
|
||||
}
|
||||
}
|
||||
|
||||
// IF(E4>=165,"客单档80元",IF(E4>=155,"客单档60元",IF(E4>=145,"客单档50元",IF(E4>=135,"客单档40元",
|
||||
// IF(E4>=125,"客单档30元",IF(E4>=0,"客单档20元"))))))
|
||||
int customerPricePrice = 0;
|
||||
if (customerPrice >= 165) {
|
||||
customerPricePrice = 80;
|
||||
} else if (customerPrice >= 155) {
|
||||
customerPricePrice = 60;
|
||||
} else if (customerPrice >= 145) {
|
||||
customerPricePrice = 50;
|
||||
} else if (customerPrice >= 135) {
|
||||
customerPricePrice = 40;
|
||||
} else if (customerPrice >= 125) {
|
||||
customerPricePrice = 30;
|
||||
} else if (customerPrice >= 0) {
|
||||
customerPricePrice = 20;
|
||||
}
|
||||
double award = Math.min(Math.min(payPercentPrice, askNumberPrice), customerPricePrice);
|
||||
|
||||
return (int) award;
|
||||
}
|
||||
|
||||
// 米笛儿店客服日奖励
|
||||
private int midier(String nickname, Double payPercent, Double askNumber, Double customerPrice) {
|
||||
// IF(C4>=35,"奖励档80元",IF(C4>=34,"奖励档60元",IF(C4>=33,"奖励档50元",IF(C4>=32,"奖励档40元",
|
||||
// IF(C4>=31,"奖励档30元",IF(C4>=30,"奖励档20元"))))))
|
||||
int payPercentPrice = 0;
|
||||
if (payPercent >= 35) {
|
||||
payPercentPrice = 80;
|
||||
} else if (payPercent >= 34) {
|
||||
payPercentPrice = 60;
|
||||
} else if (payPercent >= 33) {
|
||||
payPercentPrice = 50;
|
||||
} else if (payPercent >= 32) {
|
||||
payPercentPrice = 40;
|
||||
} else if (payPercent >= 31) {
|
||||
payPercentPrice = 30;
|
||||
} else if (payPercent >= 30) {
|
||||
payPercentPrice = 20;
|
||||
}
|
||||
|
||||
// IF(D4>=55,"询单人数档80元",IF(D4>=35,"询单人数档60元")))
|
||||
int askNumberPrice = 0;
|
||||
if ("平均".equals(nickname)) {
|
||||
// IF(D4>=50%,"询单人数档80元",IF(D4>=30%,"询单人数档60元")))
|
||||
if (askNumber >= 0.5) {
|
||||
askNumberPrice = 80;
|
||||
} else if (askNumber >= 0.3) {
|
||||
askNumberPrice = 60;
|
||||
}
|
||||
} else {
|
||||
if (askNumber >= 55) {
|
||||
askNumberPrice = 80;
|
||||
} else if (askNumber >= 35) {
|
||||
askNumberPrice = 60;
|
||||
}
|
||||
}
|
||||
|
||||
// IF(E4>=210,"客单档80元",IF(E4>=195,"客单档60元",IF(E4>=185,"客单档50元",IF(E4>=175,"客单档40元",
|
||||
// IF(E4>=165,"客单档30元",IF(E4>=0,"客单档20元"))))))
|
||||
int customerPricePrice = 0;
|
||||
if (customerPrice >= 210) {
|
||||
customerPricePrice = 80;
|
||||
} else if (customerPrice >= 195) {
|
||||
customerPricePrice = 60;
|
||||
} else if (customerPrice >= 185) {
|
||||
customerPricePrice = 50;
|
||||
} else if (customerPrice >= 175) {
|
||||
customerPricePrice = 40;
|
||||
} else if (customerPrice >= 165) {
|
||||
customerPricePrice = 30;
|
||||
} else if (customerPrice >= 0) {
|
||||
customerPricePrice = 20;
|
||||
}
|
||||
double award = Math.min(Math.min(payPercentPrice, askNumberPrice), customerPricePrice);
|
||||
|
||||
return (int) award;
|
||||
}
|
||||
|
||||
// 阳光猫店客服日奖励
|
||||
private int yangguangmao(String nickname, Double payPercent, Double askNumber, Double customerPrice) {
|
||||
// IF(C4>=40,"奖励档80元",IF(C4>=38,"奖励档60元",IF(C4>=37,"奖励档50元",IF(C4>=36,"奖励档40元",
|
||||
// IF(C4>=35,"奖励档30元",IF(C4>=34,"奖励档20元"))))))
|
||||
int payPercentPrice = 0;
|
||||
if (payPercent >= 40) {
|
||||
payPercentPrice = 80;
|
||||
} else if (payPercent >= 38) {
|
||||
payPercentPrice = 60;
|
||||
} else if (payPercent >= 37) {
|
||||
payPercentPrice = 50;
|
||||
} else if (payPercent >= 36) {
|
||||
payPercentPrice = 40;
|
||||
} else if (payPercent >= 35) {
|
||||
payPercentPrice = 30;
|
||||
} else if (payPercent >= 34) {
|
||||
payPercentPrice = 20;
|
||||
}
|
||||
|
||||
// IF(D4>=70,"询单人数档80元",IF(D4>=50,"询单人数档60元")))
|
||||
int askNumberPrice = 0;
|
||||
if ("平均".equals(nickname)) {
|
||||
// IF(D4>=50%,"询单人数档80元",IF(D4>=30%,"询单人数档60元")))
|
||||
if (askNumber >= 0.5) {
|
||||
askNumberPrice = 80;
|
||||
} else if (askNumber >= 0.3) {
|
||||
askNumberPrice = 60;
|
||||
}
|
||||
} else {
|
||||
if (askNumber >= 70) {
|
||||
askNumberPrice = 80;
|
||||
} else if (askNumber >= 50) {
|
||||
askNumberPrice = 60;
|
||||
}
|
||||
}
|
||||
|
||||
// IF(E4>=190,"客单档80元",IF(E4>=180,"客单档60元",IF(E4>=170,"客单档50元",IF(E4>=160,"客单档40元",
|
||||
// IF(E4>=150,"客单档30元",IF(E4>=0,"客单档20元"))))))
|
||||
int customerPricePrice = 0;
|
||||
if (customerPrice >= 190) {
|
||||
customerPricePrice = 80;
|
||||
} else if (customerPrice >= 180) {
|
||||
customerPricePrice = 60;
|
||||
} else if (customerPrice >= 170) {
|
||||
customerPricePrice = 50;
|
||||
} else if (customerPrice >= 160) {
|
||||
customerPricePrice = 40;
|
||||
} else if (customerPrice >= 150) {
|
||||
customerPricePrice = 30;
|
||||
} else if (customerPrice >= 0) {
|
||||
customerPricePrice = 20;
|
||||
}
|
||||
double award = Math.min(Math.min(payPercentPrice, askNumberPrice), customerPricePrice);
|
||||
|
||||
return (int) award;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
package lingtao.net.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import lingtao.net.bean.CustomerData;
|
||||
import lingtao.net.bean.Msg;
|
||||
import lingtao.net.bean.SysUser;
|
||||
import lingtao.net.dao.CustomerDataMapper;
|
||||
import lingtao.net.util.DateFormatUtils;
|
||||
|
||||
@Service
|
||||
public class CustomerDataService {
|
||||
|
||||
@Autowired
|
||||
private CustomerDataMapper customerDatamapper;
|
||||
|
||||
/**
|
||||
* 根据角色身份查询数据列表
|
||||
*/
|
||||
public List<CustomerData> getCustomerDatas(CustomerData customerData) {
|
||||
SysUser user = (SysUser) SecurityUtils.getSubject().getPrincipal();
|
||||
customerData.setCreateDateEnd(new DateFormatUtils().formatEndTime(customerData.getCreateDateBegin()));
|
||||
customerData.setCreateDateBegin(new DateFormatUtils().formatBeginTime(customerData.getCreateDateBegin()));
|
||||
// 用户所拥有的角色
|
||||
String[] roleArr = user.getRole().split(",");
|
||||
// 判断是否拥有超管身份标识
|
||||
boolean isSuper = false;
|
||||
for (int i = 0; i < roleArr.length; i++) {
|
||||
// 有‘超级管理员’身份,状态改为true
|
||||
if ("1".equals(roleArr[i]) || "777".equals(roleArr[i])) {
|
||||
isSuper = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 如果没有‘超级管理员’身份,就展示所拥有的店铺数据;如果有就不加条件,直接查询所有
|
||||
if (!isSuper) {
|
||||
// 如果有多个
|
||||
if (user.getRole().contains(",")) {
|
||||
customerData.setRoleArr(roleArr);
|
||||
} else {// 只有一个角色
|
||||
customerData.setRoleSearch(user.getRole());
|
||||
}
|
||||
}
|
||||
|
||||
return customerDatamapper.getCustomerDatas(customerData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param customerData
|
||||
*/
|
||||
public void addCustomerData(CustomerData customerData) {
|
||||
SysUser user = (SysUser) SecurityUtils.getSubject().getPrincipal();
|
||||
// 未成交数据
|
||||
customerData.setIsBuy("0");
|
||||
customerData.setUsername(user.getUsername());
|
||||
customerData.setRealname(user.getRealname());
|
||||
customerData.setCreateBy(user.getRealname());
|
||||
customerDatamapper.addCustomerData(customerData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param customerData
|
||||
*/
|
||||
public void updateCustomerDataById(CustomerData customerData) {
|
||||
SysUser user = (SysUser) SecurityUtils.getSubject().getPrincipal();
|
||||
customerData.setUpdateBy(user.getRealname());
|
||||
customerDatamapper.updateCustomerDataById(customerData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
public void deleteCustomerDataById(Integer id) {
|
||||
customerDatamapper.deleteCustomerDataById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改 店长评语
|
||||
*
|
||||
* @param id
|
||||
* @param field
|
||||
* @param value
|
||||
*/
|
||||
public void updateRemarkById(int id, String field, String value) {
|
||||
CustomerData customerData = new CustomerData();
|
||||
SysUser user = (SysUser) SecurityUtils.getSubject().getPrincipal();
|
||||
if ("commentManager".equals(field)) {
|
||||
customerData.setId(id);
|
||||
customerData.setCommentManager(value);
|
||||
customerData.setUpdateBy(user.getRealname());
|
||||
}
|
||||
customerDatamapper.updateCommentManager(customerData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改完成状态
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public Msg changeIsBuy(Integer id) {
|
||||
try {
|
||||
customerDatamapper.changeIsBuy(id);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询产品说明报价记录
|
||||
*
|
||||
* @param productExplain
|
||||
* @return
|
||||
*/
|
||||
public List<String> getProductExplain(String productExplain) {
|
||||
SysUser user = (SysUser) SecurityUtils.getSubject().getPrincipal();
|
||||
return customerDatamapper.getProductExplain(productExplain, user.getUsername());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
package lingtao.net.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import lingtao.net.bean.CustomerTrainContent;
|
||||
import lingtao.net.bean.CustomerTrainKindLabel;
|
||||
import lingtao.net.bean.CustomerTrainProType;
|
||||
import lingtao.net.bean.Msg;
|
||||
import lingtao.net.bean.SysUser;
|
||||
import lingtao.net.dao.CustomerTrainMapper;
|
||||
|
||||
@Service
|
||||
public class CustomerTrainService {
|
||||
|
||||
@Autowired
|
||||
private CustomerTrainMapper customerTrainMapper;
|
||||
|
||||
// 查询列表
|
||||
public List<CustomerTrainContent> getCustomerTrainContents(CustomerTrainContent customerTrainContent) {
|
||||
return customerTrainMapper.getCustomerTrainContents(customerTrainContent);
|
||||
}
|
||||
|
||||
// 新增
|
||||
public Msg addCustomerTrainContent(CustomerTrainContent customerTrainContent, HttpSession session) {
|
||||
SysUser user = (SysUser) session.getAttribute("USER_SESSION");
|
||||
customerTrainContent.setCreateBy(user.getRealname());
|
||||
try {
|
||||
customerTrainMapper.addCustomerTrainContent(customerTrainContent);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
System.out.println(e);
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
// 修改
|
||||
public Msg updateCustomerTrainContentById(CustomerTrainContent customerTrainContent, HttpSession session) {
|
||||
SysUser user = (SysUser) session.getAttribute("USER_SESSION");
|
||||
customerTrainContent.setUpdateBy(user.getRealname());
|
||||
try {
|
||||
customerTrainMapper.updateCustomerTrainContentById(customerTrainContent);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
// 修改排序
|
||||
public Msg updateCustomerTrainContentSort(int id, String value) {
|
||||
customerTrainMapper.updateCustomerTrainContentSort(id, Integer.valueOf(value));
|
||||
return Msg.success();
|
||||
}
|
||||
|
||||
// 删除
|
||||
public Msg deleteCustomerTrainContentById(Integer id) {
|
||||
try {
|
||||
customerTrainMapper.deleteCustomerTrainContentById(id);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
// 产品种类字典
|
||||
|
||||
/**
|
||||
*
|
||||
* @param customerTrainProType
|
||||
* @return
|
||||
*/
|
||||
// 查询
|
||||
public List<CustomerTrainProType> getCustomerTrainProTypes(CustomerTrainProType customerTrainProType) {
|
||||
return customerTrainMapper.getCustomerTrainProTypes(customerTrainProType);
|
||||
}
|
||||
|
||||
// 新增
|
||||
public Msg addCustomerTrainProType(CustomerTrainProType customerTrainProType, HttpSession session) {
|
||||
SysUser user = (SysUser) session.getAttribute("USER_SESSION");
|
||||
customerTrainProType.setCreateBy(user.getRealname());
|
||||
try {
|
||||
customerTrainMapper.addCustomerTrainProType(customerTrainProType);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
System.out.println(e);
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
// 修改
|
||||
public Msg updateCustomerTrainProTypeById(CustomerTrainProType customerTrainProType, HttpSession session) {
|
||||
SysUser user = (SysUser) session.getAttribute("USER_SESSION");
|
||||
customerTrainProType.setUpdateBy(user.getRealname());
|
||||
try {
|
||||
customerTrainMapper.updateCustomerTrainProTypeById(customerTrainProType);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
// 删除
|
||||
public Msg deleteCustomerTrainProTypeById(Integer id) {
|
||||
try {
|
||||
customerTrainMapper.deleteCustomerTrainProTypeById(id);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
// 类型字典
|
||||
/**
|
||||
*
|
||||
* @param customerTrainKindLabel
|
||||
* @return
|
||||
*/
|
||||
// 查询
|
||||
public List<CustomerTrainKindLabel> getCustomerTrainKindLabelsByProType(
|
||||
CustomerTrainKindLabel customerTrainKindLabel) {
|
||||
return customerTrainMapper.getCustomerTrainKindLabelsByProType(customerTrainKindLabel);
|
||||
}
|
||||
|
||||
// 新增
|
||||
public Msg addCustomerTrainKindLabel(CustomerTrainKindLabel customerTrainKindLabel, HttpSession session) {
|
||||
SysUser user = (SysUser) session.getAttribute("USER_SESSION");
|
||||
customerTrainKindLabel.setCreateBy(user.getRealname());
|
||||
try {
|
||||
customerTrainMapper.addCustomerTrainKindLabel(customerTrainKindLabel);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
System.out.println(e);
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
// 修改
|
||||
public Msg updateCustomerTrainKindLabelById(CustomerTrainKindLabel customerTrainKindLabel, HttpSession session) {
|
||||
SysUser user = (SysUser) session.getAttribute("USER_SESSION");
|
||||
customerTrainKindLabel.setUpdateBy(user.getRealname());
|
||||
try {
|
||||
customerTrainMapper.updateCustomerTrainKindLabelById(customerTrainKindLabel);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
// 删除
|
||||
public Msg deleteCustomerTrainKindLabelById(Integer id) {
|
||||
try {
|
||||
customerTrainMapper.deleteCustomerTrainKindLabelById(id);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package lingtao.net.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import lingtao.net.bean.ExpressFee;
|
||||
import lingtao.net.bean.Msg;
|
||||
import lingtao.net.bean.SysUser;
|
||||
import lingtao.net.dao.ExpressFeeMapper;
|
||||
|
||||
@Service
|
||||
public class ExpressFeeService {
|
||||
|
||||
@Autowired
|
||||
private ExpressFeeMapper expressFeeMapper;
|
||||
|
||||
public List<ExpressFee> getExpressFees(ExpressFee expressFee) {
|
||||
return expressFeeMapper.getExpressFees(expressFee);
|
||||
}
|
||||
|
||||
public Msg addExpressFee(ExpressFee expressFee, HttpSession session) {
|
||||
SysUser user = (SysUser) session.getAttribute("USER_SESSION");
|
||||
expressFee.setCreateBy(user.getRealname());
|
||||
try {
|
||||
expressFeeMapper.addExpressFee(expressFee);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public Msg updateExpressFeeById(ExpressFee expressFee, HttpSession session) {
|
||||
SysUser user = (SysUser) session.getAttribute("USER_SESSION");
|
||||
expressFee.setUpdateBy(user.getRealname());
|
||||
try {
|
||||
expressFeeMapper.updateExpressFeeById(expressFee);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Msg deleteExpressFeeById(Integer id) {
|
||||
try {
|
||||
expressFeeMapper.deleteExpressFeeById(id);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public List<ExpressFee> getShortAnswers() {
|
||||
return expressFeeMapper.getShortAnswers();
|
||||
}
|
||||
|
||||
public Msg updateExpressFeeById(HttpSession session, int id, String field, String value) {
|
||||
ExpressFee expressFee = new ExpressFee();
|
||||
SysUser user = (SysUser) session.getAttribute("USER_SESSION");
|
||||
expressFee.setUpdateBy(user.getRealname());
|
||||
expressFee.setId(id);
|
||||
switch (field) {
|
||||
case "province":
|
||||
expressFee.setProvince(value);
|
||||
break;
|
||||
case "firstWeightPrice":
|
||||
if (StringUtils.isEmpty(value))
|
||||
return Msg.fail("更新失败");
|
||||
expressFee.setFirstWeightPrice(Double.valueOf(value));
|
||||
break;
|
||||
case "continuedWeightPrice":
|
||||
if (StringUtils.isEmpty(value))
|
||||
return Msg.fail("更新失败");
|
||||
expressFee.setContinuedWeightPrice(Double.valueOf(value));
|
||||
break;
|
||||
case "startPrice":
|
||||
if (StringUtils.isEmpty(value))
|
||||
return Msg.fail("更新失败");
|
||||
expressFee.setStartPrice(Double.valueOf(value));
|
||||
break;
|
||||
}
|
||||
try {
|
||||
expressFeeMapper.updateExpressFeeById(expressFee);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public List<ExpressFee> getAllExpressFees(ExpressFee expressFee) {
|
||||
return expressFeeMapper.getAllExpressFees(expressFee);
|
||||
}
|
||||
|
||||
public List<ExpressFee> getHandBagExpressFees(ExpressFee expressFee) {
|
||||
return expressFeeMapper.getHandBagExpressFees(expressFee);
|
||||
}
|
||||
|
||||
public List<ExpressFee> getTaoExpressFees(ExpressFee expressFee) {
|
||||
return expressFeeMapper.getTaoExpressFees(expressFee);
|
||||
}
|
||||
|
||||
public List<ExpressFee> getOtherExpressFees(ExpressFee expressFee) {
|
||||
return expressFeeMapper.getOtherExpressFees(expressFee);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,401 @@
|
||||
package lingtao.net.service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
|
||||
import org.apache.poi.hssf.usermodel.HSSFRow;
|
||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import lingtao.net.bean.Finance;
|
||||
import lingtao.net.bean.Msg;
|
||||
import lingtao.net.bean.SysUser;
|
||||
import lingtao.net.dao.Finance2Mapper;
|
||||
import lingtao.net.util.ExcelUtils;
|
||||
|
||||
@Service
|
||||
public class Finance2Service {
|
||||
|
||||
@Autowired
|
||||
private Finance2Mapper finance2Mapper;
|
||||
|
||||
public List<Finance> getFinance(Finance finance) {
|
||||
return finance2Mapper.getFinance(finance);
|
||||
}
|
||||
|
||||
public List<String> getAllFilename(String creator) {
|
||||
return finance2Mapper.getAllFilename(creator);
|
||||
}
|
||||
|
||||
public Msg deleteDataByFilename(String filename, String realname) {
|
||||
try {
|
||||
finance2Mapper.deleteDataByFilename(filename, realname);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
public Msg ajaxUploadExcel(MultipartFile file) throws Exception {
|
||||
if (file.isEmpty()) {
|
||||
throw new Exception("文件不存在!");
|
||||
}
|
||||
SysUser user = (SysUser) SecurityUtils.getSubject().getPrincipal();
|
||||
InputStream in = null;
|
||||
List<List<Object>> listob = null;
|
||||
List<Finance> list = new ArrayList<Finance>(1000);
|
||||
try {
|
||||
in = file.getInputStream();
|
||||
listob = new ExcelUtils().getBankListByExcel(in, file.getOriginalFilename());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
String filename = file.getOriginalFilename();
|
||||
System.out.println(filename);
|
||||
for (int i = 0; i < listob.size(); i++) {
|
||||
synchronized (this) {
|
||||
Finance vo = new Finance();
|
||||
List<Object> lo = listob.get(i);
|
||||
if (lo.size() == 0 || lo.size() == 1 || lo.get(6) == "") {
|
||||
System.out.println("++++++++++++++");
|
||||
continue;
|
||||
}
|
||||
String addTime = String.valueOf(lo.get(0)).trim();
|
||||
String supplier = String.valueOf(lo.get(1)).trim();
|
||||
String shopname = String.valueOf(lo.get(2)).trim();
|
||||
String kind = String.valueOf(lo.get(3)).trim();
|
||||
String kind2 = String.valueOf(lo.get(4)).trim();
|
||||
String orderNumber = String.valueOf(lo.get(5)).trim();
|
||||
String remark = String.valueOf(lo.get(6)).trim();
|
||||
remark = remark.replace("MM", "mm").replace("CM", "mm");
|
||||
if (remark.indexOf("mm") == -1 && remark.indexOf("cm") == -1) {
|
||||
System.out.println(remark);
|
||||
System.out.println("=================");
|
||||
}
|
||||
// 判断数据是否已经存在
|
||||
|
||||
/*
|
||||
* String checkAccountNumber = finance2Mapper.checkAccountNumber(orderNumber);
|
||||
* if (StringUtils.isNotEmpty(checkAccountNumber)) { continue; }
|
||||
*/
|
||||
|
||||
// 数量
|
||||
String count = "#";
|
||||
// 拼版数
|
||||
String number = "#";
|
||||
// 所需张数
|
||||
double zhang = 0;
|
||||
try {
|
||||
// 处理备注
|
||||
String cutSizeStr = remark;
|
||||
String cutCountStr = remark;
|
||||
number = cutSize(cutSizeStr);
|
||||
count = cutCount(cutCountStr);
|
||||
if (count != "#" && number != "#") {
|
||||
if (count.contains("*")) {
|
||||
String[] countSplit = count.split("\\*");
|
||||
System.out.println(Double.valueOf(countSplit[0]));
|
||||
System.out.println(Double.valueOf(countSplit[1]));
|
||||
zhang = Math.ceil(Double.valueOf(countSplit[0]) * Double.valueOf(countSplit[1])
|
||||
/ Double.valueOf(number));
|
||||
} else {
|
||||
zhang = Math.ceil(Double.valueOf(count) / Double.valueOf(number));
|
||||
}
|
||||
}
|
||||
orderNumber = remark.substring(remark.indexOf("(") + 1, remark.indexOf(")"));
|
||||
} catch (Exception e) {
|
||||
System.out.println(remark);
|
||||
// return Msg.fail(remark);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(addTime)) {
|
||||
Date javaDate = HSSFDateUtil.getJavaDate(Double.parseDouble(addTime));
|
||||
vo.setAddTime(javaDate);
|
||||
}
|
||||
// SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||
// Date add_date = formatter.parse(addTime);// 把字符串转为日期格式
|
||||
vo.setSupplier(supplier);
|
||||
vo.setShopname(shopname);
|
||||
vo.setKind(kind);
|
||||
vo.setKind2(kind2);
|
||||
vo.setOrderNumber(orderNumber);
|
||||
vo.setFilename(filename);
|
||||
vo.setCount(count);
|
||||
vo.setNumber(number);
|
||||
vo.setZhang(String.valueOf(zhang));
|
||||
vo.setRemark(remark);
|
||||
vo.setCreator(user.getRealname());
|
||||
list.add(vo);
|
||||
// finance2Mapper.insertSelective(vo);
|
||||
}
|
||||
}
|
||||
if (list.size() == 0) {
|
||||
return Msg.fail("上传失败,请检查文件表头是否正确");
|
||||
} else if (list.size() > 0) {
|
||||
finance2Mapper.insertForeach(list);
|
||||
}
|
||||
in.close();
|
||||
return Msg.success();
|
||||
|
||||
}
|
||||
|
||||
private String cutCount(String remark) {
|
||||
remark = remark.replaceAll(" ", "").replace("x", "X").replace("×", "X").replace("(", "(").replace(")", ")");
|
||||
String countStr = "";
|
||||
String numberStr = "";
|
||||
Integer number;
|
||||
Integer count;
|
||||
int indexM = remark.indexOf("m");
|
||||
int indexZhang = remark.indexOf("张");
|
||||
int indexGe = remark.indexOf("个");
|
||||
int indexTao = remark.indexOf("套");
|
||||
int indexMei = remark.indexOf("枚");
|
||||
if (remark.indexOf("张") != -1 && indexZhang - indexM < 15) {
|
||||
if (remark.indexOf("m-") == -1) {
|
||||
countStr = remark.substring(remark.indexOf("m") + 1, remark.indexOf("张"));
|
||||
} else {
|
||||
countStr = remark.substring(remark.indexOf("m-") + 2, remark.indexOf("张"));
|
||||
}
|
||||
} else if (remark.indexOf("个") != -1 && indexGe - indexM < 15) {
|
||||
if (remark.indexOf("m-") == -1) {
|
||||
countStr = remark.substring(remark.indexOf("m") + 1, remark.indexOf("个"));
|
||||
} else {
|
||||
countStr = remark.substring(remark.indexOf("m-") + 2, remark.indexOf("个"));
|
||||
}
|
||||
} else if (remark.indexOf("套") != -1 && indexTao - indexM < 15) {
|
||||
if (remark.indexOf("m-") == -1) {
|
||||
countStr = remark.substring(remark.indexOf("m") + 1, remark.indexOf("套"));
|
||||
} else {
|
||||
countStr = remark.substring(remark.indexOf("m-") + 2, remark.indexOf("套"));
|
||||
}
|
||||
} else if (remark.indexOf("枚") != -1 && indexMei - indexM < 15) {
|
||||
if (remark.indexOf("m-") == -1) {
|
||||
countStr = remark.substring(remark.indexOf("m") + 1, remark.indexOf("枚"));
|
||||
} else {
|
||||
countStr = remark.substring(remark.indexOf("m-") + 2, remark.indexOf("枚"));
|
||||
}
|
||||
}
|
||||
// 第一个“款”的位置
|
||||
int firstK = countStr.indexOf("款");
|
||||
// 第一个“各”的位置
|
||||
int firstGe = countStr.indexOf("各");
|
||||
// 第二个“款”的位置
|
||||
int countStrSecondK = countStr.indexOf("款", firstK + 1);
|
||||
// 第3个“款”的位置
|
||||
int countStrThirdK = countStr.indexOf("款", countStrSecondK + 1);
|
||||
if (countStrSecondK > 0 && countStrThirdK > 0) {
|
||||
return "#";
|
||||
}
|
||||
// “共***张”
|
||||
if (countStr.contains("共")) {
|
||||
String[] split = countStr.split("共");
|
||||
countStr = split[1].replaceAll("[^(0-9)]", "");
|
||||
return "" + countStr;
|
||||
}
|
||||
// “合计***张”
|
||||
if (countStr.contains("合计")) {
|
||||
String[] split = countStr.split("合计");
|
||||
countStr = split[1].replaceAll("[^(0-9)]", "");
|
||||
return "" + countStr;
|
||||
}
|
||||
// “总的***张”
|
||||
if (countStr.contains("总")) {
|
||||
String[] split = countStr.split("总");
|
||||
countStr = split[1].replaceAll("[^(0-9)]", "");
|
||||
return "" + countStr;
|
||||
}
|
||||
// “***款各***张”
|
||||
if (firstGe > 0) {
|
||||
String[] split = countStr.split("各");
|
||||
numberStr = split[0];
|
||||
countStr = split[1];
|
||||
numberStr = numberStr.replaceAll("[^(0-9)]", "");
|
||||
countStr = countStr.replaceAll("[^(0-9)]", "");
|
||||
if (StringUtils.isEmpty(numberStr)) {
|
||||
return "#";
|
||||
}
|
||||
number = Integer.valueOf(numberStr);
|
||||
count = Integer.valueOf(countStr);
|
||||
if (number == 1 || count == 1) {
|
||||
return "" + number * count;
|
||||
}
|
||||
return number + "*" + count;
|
||||
}
|
||||
// **款**张
|
||||
if (firstK > 0) {
|
||||
String[] split = countStr.split("款");
|
||||
numberStr = split[0];
|
||||
countStr = split[1];
|
||||
if (countStrSecondK > 0) {
|
||||
countStr = split[2];
|
||||
}
|
||||
numberStr = numberStr.replaceAll("[^(0-9)]", "");
|
||||
countStr = countStr.replaceAll("[^(0-9)]", "");
|
||||
if (StringUtils.isEmpty(numberStr)) {
|
||||
return "#";
|
||||
}
|
||||
number = Integer.valueOf(numberStr);
|
||||
count = Integer.valueOf(countStr);
|
||||
if (number == 1 || count == 1) {
|
||||
return "" + number * count;
|
||||
}
|
||||
return number + "*" + count;
|
||||
}
|
||||
countStr = countStr.replaceAll("[^(0-9)]", "");
|
||||
return countStr;
|
||||
}
|
||||
|
||||
private String cutSize(String remark) {
|
||||
remark = remark.replaceAll(" ", "").replace("x", "X").replace("×", "X").replace("(", "(").replace(")", ")")
|
||||
.replace("专版打印", "").replace("下", "").replace("上", "").replace("专版", "").replace("-", "")
|
||||
.replace("多拍返10元", "");
|
||||
// 第一个X的位置
|
||||
int firstX = remark.indexOf("X");
|
||||
// 第二个X的位置
|
||||
int secondX = remark.indexOf("X", firstX + 1);
|
||||
int secondmm = remark.indexOf("mm", remark.indexOf("mm") + 1);
|
||||
if (secondX > 0 && secondmm > 0) {
|
||||
return "#";
|
||||
}
|
||||
// System.out.println(remark);
|
||||
String size = "";
|
||||
double length;
|
||||
double width;
|
||||
// 提取整数/小数的正则
|
||||
String regex = "([1-9]\\d*\\.?\\d+)|(0\\.\\d*[1-9])|(\\d+)";
|
||||
if (remark.indexOf("mm") == -1 && remark.indexOf("cm") != -1) {
|
||||
String l = remark.substring(remark.indexOf("X") - 3, remark.indexOf("X"));
|
||||
String w = remark.substring(remark.indexOf("X") + 1, remark.indexOf("cm"));
|
||||
// 如果l里有小数点,往前数5位
|
||||
if (l.indexOf(".") != -1) {
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
l = remark.substring(remark.indexOf("X") - 5, remark.indexOf("X"));
|
||||
Matcher matcher = pattern.matcher(l);
|
||||
while (matcher.find()) {
|
||||
l = matcher.group();
|
||||
}
|
||||
} else {
|
||||
l = l.replaceAll("[^(0-9)]", "");
|
||||
}
|
||||
size = l + "X" + w;
|
||||
String[] split = size.split("X");
|
||||
length = Double.valueOf(split[0]) * 10 + 4;
|
||||
if ("按比例".equals(split[1])) {
|
||||
width = Double.valueOf(split[0]) * 10 + 4;
|
||||
} else {
|
||||
width = Double.valueOf(split[1]) * 10 + 4;
|
||||
}
|
||||
} else {
|
||||
String l = remark.substring(remark.indexOf("X") - 3, remark.indexOf("X"));
|
||||
String w = remark.substring(remark.indexOf("X") + 1, remark.indexOf("mm"));
|
||||
// 如果l里有小数点,往前数5位
|
||||
if (l.indexOf(".") != -1) {
|
||||
if (l.indexOf(".") != -1) {
|
||||
l = remark.substring(remark.indexOf("X") - 5, remark.indexOf("X"));
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(l);
|
||||
while (matcher.find()) {
|
||||
l = matcher.group();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
l = l.replaceAll("[^(0-9)]", "");
|
||||
}
|
||||
size = l + "X" + w;
|
||||
String[] split = size.split("X");
|
||||
length = Double.valueOf(split[0]) + 4;
|
||||
if ("按比例".equals(split[1])) {
|
||||
width = Double.valueOf(split[0]) + 4;
|
||||
} else {
|
||||
width = Double.valueOf(split[1]) + 4;
|
||||
}
|
||||
}
|
||||
|
||||
double l = 390;
|
||||
double w = 272;
|
||||
if (length == l + 4) {
|
||||
return "1";
|
||||
}
|
||||
if ((length > l || width > w) && (length > w || width > l))
|
||||
return "#";
|
||||
// 一张纸 390*272 能做多少个此类尺寸的产品
|
||||
double max = Math.max(Math.floor(l / length) * Math.floor(w / width),
|
||||
Math.floor(l / width) * Math.floor(w / length));
|
||||
return String.valueOf(max);
|
||||
}
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
public void excel(HttpServletResponse response, Finance finance) throws Exception {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
List<Finance> financesList = new ArrayList<Finance>();
|
||||
SysUser user = (SysUser) SecurityUtils.getSubject().getPrincipal();
|
||||
finance.setCreator(user.getRealname());
|
||||
financesList = getFinance(finance);
|
||||
|
||||
// 创建excel文件
|
||||
HSSFWorkbook wb = new HSSFWorkbook();
|
||||
// 创建sheet页
|
||||
HSSFSheet sheet = wb.createSheet("总表");
|
||||
String filename = "";
|
||||
// 创建标题行
|
||||
HSSFRow titleRow = sheet.createRow(0);
|
||||
titleRow.createCell(0).setCellValue("日期");
|
||||
titleRow.createCell(1).setCellValue("供应商");
|
||||
titleRow.createCell(2).setCellValue("店铺");
|
||||
titleRow.createCell(3).setCellValue("大类别");
|
||||
titleRow.createCell(4).setCellValue("小类别");
|
||||
titleRow.createCell(5).setCellValue("订单号");
|
||||
titleRow.createCell(6).setCellValue("文件名");
|
||||
titleRow.createCell(7).setCellValue("数量");
|
||||
titleRow.createCell(8).setCellValue("拼版数");
|
||||
titleRow.createCell(9).setCellValue("张数");
|
||||
titleRow.createCell(10).setCellValue("导入人");
|
||||
titleRow.createCell(11).setCellValue("导入日期");
|
||||
// 遍历将数据放到excel列中
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||
for (Finance finances : financesList) {
|
||||
filename = finance.getFilename();
|
||||
HSSFRow dataRow = sheet.createRow(sheet.getLastRowNum() + 1);
|
||||
dataRow.createCell(0).setCellValue("");
|
||||
if (finances.getAddTime() != null) {
|
||||
dataRow.createCell(0).setCellValue(formatter.format(finances.getAddTime()));
|
||||
}
|
||||
dataRow.createCell(1).setCellValue(finances.getSupplier());
|
||||
dataRow.createCell(2).setCellValue(finances.getShopname());
|
||||
dataRow.createCell(3).setCellValue(finances.getKind());
|
||||
dataRow.createCell(4).setCellValue(finances.getKind2());
|
||||
dataRow.createCell(5).setCellValue(finances.getOrderNumber());
|
||||
dataRow.createCell(6).setCellValue(finances.getRemark());
|
||||
dataRow.createCell(7).setCellValue(finances.getCount());
|
||||
dataRow.createCell(8).setCellValue(finances.getNumber());
|
||||
dataRow.createCell(9).setCellValue(finances.getZhang());
|
||||
dataRow.createCell(10).setCellValue(finances.getCreator());
|
||||
dataRow.createCell(11).setCellValue(formatter.format(finances.getCreateDate()));
|
||||
}
|
||||
|
||||
// 设置下载时客户端Excel的名称
|
||||
response.setContentType("application/octet-stream;charset=utf-8");
|
||||
response.setHeader("Content-Disposition",
|
||||
"attachment;filename=" + new String(filename.getBytes(), "iso-8859-1"));// + ".xls"
|
||||
|
||||
OutputStream ouputStream = response.getOutputStream();
|
||||
wb.write(ouputStream);
|
||||
ouputStream.flush();
|
||||
ouputStream.close();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,388 @@
|
||||
package lingtao.net.service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
|
||||
import org.apache.poi.hssf.usermodel.HSSFRow;
|
||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import lingtao.net.bean.Finance;
|
||||
import lingtao.net.bean.Msg;
|
||||
import lingtao.net.bean.SysUser;
|
||||
import lingtao.net.dao.Finance3Mapper;
|
||||
import lingtao.net.util.ExcelUtils;
|
||||
|
||||
@Service
|
||||
public class Finance3Service {
|
||||
|
||||
@Autowired
|
||||
private Finance3Mapper finance3Mapper;
|
||||
|
||||
public List<Finance> getFinance(Finance finance) {
|
||||
return finance3Mapper.getFinance(finance);
|
||||
}
|
||||
|
||||
public List<String> getAllFilename(String creator) {
|
||||
return finance3Mapper.getAllFilename(creator);
|
||||
}
|
||||
|
||||
public Msg deleteDataByFilename(String filename, String realname) {
|
||||
try {
|
||||
finance3Mapper.deleteDataByFilename(filename, realname);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
public Msg ajaxUploadExcel(MultipartFile file) throws Exception {
|
||||
if (file.isEmpty()) {
|
||||
throw new Exception("文件不存在!");
|
||||
}
|
||||
SysUser user = (SysUser) SecurityUtils.getSubject().getPrincipal();
|
||||
InputStream in = null;
|
||||
List<List<Object>> listob = null;
|
||||
List<Finance> list = new ArrayList<Finance>(1000);
|
||||
try {
|
||||
in = file.getInputStream();
|
||||
listob = new ExcelUtils().getBankListByExcel(in, file.getOriginalFilename());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
String filename = file.getOriginalFilename();
|
||||
System.out.println(filename);
|
||||
for (int i = 0; i < listob.size(); i++) {
|
||||
synchronized (this) {
|
||||
Finance vo = new Finance();
|
||||
List<Object> lo = listob.get(i);
|
||||
if (lo.size() == 0 || lo.size() == 1 || lo.get(6) == "") {
|
||||
System.out.println("++++++++++++++");
|
||||
continue;
|
||||
}
|
||||
|
||||
String addTime = String.valueOf(lo.get(0)).trim();
|
||||
if(addTime.equals("日期")) {
|
||||
continue;
|
||||
}
|
||||
String supplier = String.valueOf(lo.get(1)).trim();
|
||||
String shopname = String.valueOf(lo.get(2)).trim();
|
||||
String kind = String.valueOf(lo.get(3)).trim();
|
||||
String kind2 = String.valueOf(lo.get(4)).trim();
|
||||
String orderNumber = String.valueOf(lo.get(5)).trim();
|
||||
String remark = String.valueOf(lo.get(6)).trim();
|
||||
remark = remark.replace("MM", "mm").replace("CM", "cm");
|
||||
if (remark.indexOf("mm") == -1 && remark.indexOf("cm") == -1) {
|
||||
System.out.println(remark);
|
||||
System.out.println("=================");
|
||||
}
|
||||
// 判断数据是否已经存在
|
||||
|
||||
/*
|
||||
* String checkAccountNumber = finance2Mapper.checkAccountNumber(orderNumber);
|
||||
* if (StringUtils.isNotEmpty(checkAccountNumber)) { continue; }
|
||||
*/
|
||||
|
||||
// 数量
|
||||
String count = "#";
|
||||
// 拼版数
|
||||
String number = "#";
|
||||
// 所需张数
|
||||
double zhang = 0;
|
||||
String total = "";
|
||||
try {
|
||||
// 处理备注
|
||||
remark = remark.replace(",", ",");
|
||||
number = cutSize(remark);
|
||||
count = cutCount(remark);
|
||||
if(remark.indexOf(",") > 0) {
|
||||
String[] countList = count.split(",");
|
||||
String[] numberList = number.split(",");
|
||||
for(int j = 0;j < countList.length; j++) {
|
||||
if (countList[j].equals("#") || numberList[j].equals("#")) {
|
||||
zhang = 0;
|
||||
}else {
|
||||
zhang = Math.ceil(Double.valueOf(countList[j]) / Double.valueOf(numberList[j]));
|
||||
}
|
||||
total += ","+zhang;
|
||||
}
|
||||
total = total.substring(0);
|
||||
}else {
|
||||
if (count != "#" && number != "#") {
|
||||
if (count.contains("*")) {
|
||||
String[] countSplit = count.split("\\*");
|
||||
System.out.println(Double.valueOf(countSplit[0]));
|
||||
System.out.println(Double.valueOf(countSplit[1]));
|
||||
zhang = Math.ceil(Double.valueOf(countSplit[0]) * Double.valueOf(countSplit[1])
|
||||
/ Double.valueOf(number));
|
||||
} else {
|
||||
zhang = Math.ceil(Double.valueOf(count) / Double.valueOf(number));
|
||||
}
|
||||
}
|
||||
orderNumber = remark.substring(remark.indexOf("(") + 1, remark.indexOf(")"));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println(remark);
|
||||
// return Msg.fail(remark);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(addTime)) {
|
||||
Date javaDate = HSSFDateUtil.getJavaDate(Double.parseDouble(addTime));
|
||||
vo.setAddTime(javaDate);
|
||||
}
|
||||
// SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||
// Date add_date = formatter.parse(addTime);// 把字符串转为日期格式
|
||||
vo.setSupplier(supplier);
|
||||
vo.setShopname(shopname);
|
||||
vo.setKind(kind);
|
||||
vo.setKind2(kind2);
|
||||
vo.setOrderNumber(orderNumber);
|
||||
vo.setFilename(filename);
|
||||
vo.setCount(count);
|
||||
vo.setNumber(number);
|
||||
if(total.length() > 0) {
|
||||
vo.setZhang(total);
|
||||
}else {
|
||||
vo.setZhang(String.valueOf(zhang));
|
||||
}
|
||||
vo.setRemark(remark);
|
||||
vo.setCreator(user.getRealname());
|
||||
list.add(vo);
|
||||
// finance2Mapper.insertSelective(vo);
|
||||
}
|
||||
}
|
||||
if (list.size() == 0) {
|
||||
return Msg.fail("上传失败,请检查文件表头是否正确");
|
||||
} else if (list.size() > 0) {
|
||||
finance3Mapper.insertForeach(list);
|
||||
}
|
||||
in.close();
|
||||
return Msg.success();
|
||||
|
||||
}
|
||||
|
||||
private String cutCount(String remark) {
|
||||
int number = 0, count = 0, index = 0;
|
||||
String totalCount = "";
|
||||
String counts = "";
|
||||
String[] countList = {};
|
||||
if( remark.indexOf(",") > 0) {//合包的拼版计算
|
||||
String[] total = remark.split(",");
|
||||
for(int i = 0 ;i < total.length; i++) {
|
||||
String[] lists = total[i].split("-");
|
||||
for(int j = 0; j < lists.length; j++) {
|
||||
index = lists[j].indexOf("mm");
|
||||
if(index == -1) {
|
||||
index = lists[j].indexOf("cm");
|
||||
}
|
||||
}
|
||||
|
||||
if(counts.indexOf("各") > 0) {
|
||||
countList = counts.split("款");
|
||||
number = Integer.valueOf(countList[0].replace("各", ""));
|
||||
count = Integer.valueOf(countList[1].substring(1, countList[1].length()-1));
|
||||
totalCount += "," + count * number;
|
||||
}else {
|
||||
totalCount += "," + Integer.valueOf(counts.substring(0, counts.length()-1)) * 1;
|
||||
}
|
||||
}
|
||||
totalCount = totalCount.substring(1);
|
||||
return totalCount;
|
||||
}else {//单款尺寸
|
||||
String[] list = remark.split("-");
|
||||
for(int m = 0;m < list.length; m++) {
|
||||
index = list[m].indexOf("mm");
|
||||
if(index == -1) {
|
||||
index = list[m].indexOf("cm");
|
||||
}
|
||||
if(index > 0) {
|
||||
counts = list[m+1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(counts.indexOf("各") > 0) {
|
||||
countList = counts.split("款");
|
||||
countList[1].substring(0, countList[1].length()-1);
|
||||
number = Integer.valueOf(countList[0].replace("各", ""));
|
||||
count = Integer.valueOf(countList[1].substring(1, countList[1].length()-1));
|
||||
count = count * number;
|
||||
}else {
|
||||
count = Integer.valueOf(counts.substring(0, counts.length()-1)) * 1;
|
||||
}
|
||||
|
||||
return String.valueOf(count);
|
||||
}
|
||||
}
|
||||
|
||||
private String cutSize(String remark) {
|
||||
double length = 0,width = 0;
|
||||
int sizeIndex = 0;
|
||||
String totalSize = "";
|
||||
String size = "";
|
||||
String[] sizeList = {};
|
||||
double l = 290,w = 195;
|
||||
if( remark.indexOf(",") > 0) {//合包的拼版计算
|
||||
String[] total = remark.split(",");
|
||||
for(int i = 0 ;i < total.length; i++) {
|
||||
String[] lists = total[i].split("-");
|
||||
for(int j = 0; j < lists.length; j++) {
|
||||
sizeIndex = lists[j].indexOf("mm");
|
||||
if(sizeIndex == 0) {
|
||||
sizeIndex = lists[j].indexOf("cm");
|
||||
}
|
||||
|
||||
if(sizeIndex > 0) {
|
||||
size = lists[j].replace("mm", "");
|
||||
size = size.replace("cm", "");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(size.indexOf("×") > 0 ) {
|
||||
sizeList = size.split("×");
|
||||
}else if(size.indexOf("x") > 0){
|
||||
sizeList = size.split("x");
|
||||
}
|
||||
|
||||
length = Double.valueOf(sizeList[0]);
|
||||
width = Double.valueOf(sizeList[1]);
|
||||
|
||||
//+3mm出血
|
||||
length += 3;
|
||||
width += 3;
|
||||
|
||||
if (length == l + 3 || width == l + 3) {
|
||||
totalSize = "1";
|
||||
continue;
|
||||
}else if ((length > l || width > w) && (length > w || width > l)) {
|
||||
totalSize = "#";
|
||||
continue;
|
||||
}
|
||||
|
||||
// 一张纸 能做多少个此类尺寸的产品
|
||||
double max = Math.max(Math.floor(l / length) * Math.floor(w / width),
|
||||
Math.floor(l / width) * Math.floor(w / length));
|
||||
|
||||
totalSize += "," + String.valueOf(max);
|
||||
}
|
||||
|
||||
if(totalSize.indexOf("#") != 0) {
|
||||
totalSize = totalSize.substring(1);
|
||||
}
|
||||
|
||||
return totalSize;
|
||||
}else {
|
||||
String[] list = remark.split("-");
|
||||
for(int m = 0;m < list.length; m++) {
|
||||
sizeIndex = list[m].indexOf("mm");
|
||||
if(sizeIndex == 0) {
|
||||
sizeIndex = list[m].indexOf("cm");
|
||||
}
|
||||
|
||||
if(sizeIndex > 0) {
|
||||
size = list[m].replace("mm", "");
|
||||
size = size.replace("cm", "");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(size.indexOf("×") > 0 ) {
|
||||
sizeList = size.split("×");
|
||||
}else if(size.indexOf("x") > 0){
|
||||
sizeList = size.split("x");
|
||||
}
|
||||
|
||||
length = Double.valueOf(sizeList[0]);
|
||||
width = Double.valueOf(sizeList[1]);
|
||||
//+3mm出血
|
||||
length += 3;
|
||||
width += 3;
|
||||
|
||||
if (length == l + 3 || width == l + 3) {
|
||||
return "1";
|
||||
}
|
||||
if ((length > l || width > w) && (length > w || width > l))
|
||||
return "#";
|
||||
// 一张纸 能做多少个此类尺寸的产品
|
||||
double max = Math.max(Math.floor(l / length) * Math.floor(w / width),
|
||||
Math.floor(l / width) * Math.floor(w / length));
|
||||
return String.valueOf(max);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
public void excel(HttpServletResponse response, Finance finance) throws Exception {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
List<Finance> financesList = new ArrayList<Finance>();
|
||||
SysUser user = (SysUser) SecurityUtils.getSubject().getPrincipal();
|
||||
finance.setCreator(user.getRealname());
|
||||
financesList = getFinance(finance);
|
||||
|
||||
// 创建excel文件
|
||||
HSSFWorkbook wb = new HSSFWorkbook();
|
||||
// 创建sheet页
|
||||
HSSFSheet sheet = wb.createSheet("总表");
|
||||
String filename = "";
|
||||
// 创建标题行
|
||||
HSSFRow titleRow = sheet.createRow(0);
|
||||
titleRow.createCell(0).setCellValue("日期");
|
||||
titleRow.createCell(1).setCellValue("供应商");
|
||||
titleRow.createCell(2).setCellValue("店铺");
|
||||
titleRow.createCell(3).setCellValue("大类别");
|
||||
titleRow.createCell(4).setCellValue("小类别");
|
||||
titleRow.createCell(5).setCellValue("订单号");
|
||||
titleRow.createCell(6).setCellValue("文件名");
|
||||
titleRow.createCell(7).setCellValue("数量");
|
||||
titleRow.createCell(8).setCellValue("拼版数");
|
||||
titleRow.createCell(9).setCellValue("张数");
|
||||
titleRow.createCell(10).setCellValue("导入人");
|
||||
titleRow.createCell(11).setCellValue("导入日期");
|
||||
// 遍历将数据放到excel列中
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||
for (Finance finances : financesList) {
|
||||
filename = finance.getFilename();
|
||||
HSSFRow dataRow = sheet.createRow(sheet.getLastRowNum() + 1);
|
||||
dataRow.createCell(0).setCellValue("");
|
||||
if (finances.getAddTime() != null) {
|
||||
dataRow.createCell(0).setCellValue(formatter.format(finances.getAddTime()));
|
||||
}
|
||||
dataRow.createCell(1).setCellValue(finances.getSupplier());
|
||||
dataRow.createCell(2).setCellValue(finances.getShopname());
|
||||
dataRow.createCell(3).setCellValue(finances.getKind());
|
||||
dataRow.createCell(4).setCellValue(finances.getKind2());
|
||||
dataRow.createCell(5).setCellValue(finances.getOrderNumber());
|
||||
dataRow.createCell(6).setCellValue(finances.getRemark());
|
||||
dataRow.createCell(7).setCellValue(finances.getCount());
|
||||
dataRow.createCell(8).setCellValue(finances.getNumber());
|
||||
dataRow.createCell(9).setCellValue(finances.getZhang());
|
||||
dataRow.createCell(10).setCellValue(finances.getCreator());
|
||||
dataRow.createCell(11).setCellValue(formatter.format(finances.getCreateDate()));
|
||||
}
|
||||
|
||||
// 设置下载时客户端Excel的名称
|
||||
response.setContentType("application/octet-stream;charset=utf-8");
|
||||
response.setHeader("Content-Disposition",
|
||||
"attachment;filename=" + new String(filename.getBytes(), "iso-8859-1"));// + ".xls"
|
||||
|
||||
OutputStream ouputStream = response.getOutputStream();
|
||||
wb.write(ouputStream);
|
||||
ouputStream.flush();
|
||||
ouputStream.close();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,393 @@
|
||||
package lingtao.net.service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
|
||||
import org.apache.poi.hssf.usermodel.HSSFRow;
|
||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import lingtao.net.bean.Finance;
|
||||
import lingtao.net.bean.Msg;
|
||||
import lingtao.net.bean.SysUser;
|
||||
import lingtao.net.dao.Finance3Mapper;
|
||||
import lingtao.net.util.ExcelUtils;
|
||||
|
||||
@Service
|
||||
public class Finance4Service {
|
||||
|
||||
@Autowired
|
||||
private Finance3Mapper finance3Mapper;
|
||||
|
||||
public List<Finance> getFinance(Finance finance) {
|
||||
return finance3Mapper.getFinance4(finance);
|
||||
}
|
||||
|
||||
public List<String> getAllFilename(String creator) {
|
||||
return finance3Mapper.getAllFilename4(creator);
|
||||
}
|
||||
|
||||
public Msg deleteDataByFilename(String filename, String realname) {
|
||||
try {
|
||||
finance3Mapper.deleteDataByFilename4(filename, realname);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
public Msg ajaxUploadExcel(MultipartFile file) throws Exception {
|
||||
if (file.isEmpty()) {
|
||||
throw new Exception("文件不存在!");
|
||||
}
|
||||
SysUser user = (SysUser) SecurityUtils.getSubject().getPrincipal();
|
||||
InputStream in = null;
|
||||
List<List<Object>> listob = null;
|
||||
List<Finance> list = new ArrayList<Finance>(1000);
|
||||
try {
|
||||
in = file.getInputStream();
|
||||
listob = new ExcelUtils().getBankListByExcel(in, file.getOriginalFilename());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
String filename = file.getOriginalFilename();
|
||||
System.out.println(filename);
|
||||
for (int i = 0; i < listob.size(); i++) {
|
||||
synchronized (this) {
|
||||
Finance vo = new Finance();
|
||||
List<Object> lo = listob.get(i);
|
||||
if (lo.size() == 0 || lo.size() == 1 || lo.get(6) == "") {
|
||||
System.out.println("++++++++++++++");
|
||||
continue;
|
||||
}
|
||||
|
||||
String addTime = String.valueOf(lo.get(0)).trim();
|
||||
if(addTime.equals("日期")) {
|
||||
continue;
|
||||
}
|
||||
String supplier = String.valueOf(lo.get(1)).trim();
|
||||
String shopname = String.valueOf(lo.get(2)).trim();
|
||||
String kind = String.valueOf(lo.get(4)).trim();
|
||||
String kind2 = String.valueOf(lo.get(4)).trim();
|
||||
String orderNumber = String.valueOf(lo.get(5)).trim();
|
||||
String remark = String.valueOf(lo.get(6)).trim();
|
||||
remark = remark.replace("MM", "mm").replace("CM", "cm");
|
||||
if (remark.indexOf("mm") == -1 && remark.indexOf("cm") == -1) {
|
||||
System.out.println(remark);
|
||||
System.out.println("=================");
|
||||
}
|
||||
|
||||
// 数量
|
||||
String count = "#";
|
||||
// 拼版数
|
||||
String number = "#";
|
||||
// 所需张数
|
||||
double zhang = 0;
|
||||
String total = "";
|
||||
try {
|
||||
// 处理备注
|
||||
remark = remark.replace(",", ",");
|
||||
number = cutSize(remark);
|
||||
count = cutCount(remark);
|
||||
if(remark.indexOf(",") > 0) {
|
||||
String[] countList = count.split(",");
|
||||
String[] numberList = number.split(",");
|
||||
for(int j = 0;j < countList.length; j++) {
|
||||
if (countList[j].equals("#") || numberList[j].equals("#")) {
|
||||
zhang = 0;
|
||||
}else {
|
||||
zhang = Math.ceil(Double.valueOf(countList[j]) / Double.valueOf(numberList[j]));
|
||||
}
|
||||
total += ","+zhang;
|
||||
}
|
||||
total = total.substring(1);
|
||||
}else {
|
||||
if (count != "#" && number != "#") {
|
||||
if (count.contains("*")) {
|
||||
String[] countSplit = count.split("\\*");
|
||||
System.out.println(Double.valueOf(countSplit[0]));
|
||||
System.out.println(Double.valueOf(countSplit[1]));
|
||||
zhang = Math.ceil(Double.valueOf(countSplit[0]) * Double.valueOf(countSplit[1])
|
||||
/ Double.valueOf(number));
|
||||
} else {
|
||||
zhang = Math.ceil(Double.valueOf(count) / Double.valueOf(number));
|
||||
}
|
||||
}
|
||||
orderNumber = remark.substring(remark.indexOf("(") + 1, remark.indexOf(")"));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println(remark);
|
||||
// return Msg.fail(remark);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(addTime)) {
|
||||
Date javaDate = HSSFDateUtil.getJavaDate(Double.parseDouble(addTime));
|
||||
vo.setAddTime(javaDate);
|
||||
}
|
||||
// SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||
// Date add_date = formatter.parse(addTime);// 把字符串转为日期格式
|
||||
vo.setSupplier(supplier);
|
||||
vo.setShopname(shopname);
|
||||
vo.setKind(kind);
|
||||
vo.setKind2(kind2);
|
||||
vo.setOrderNumber(orderNumber);
|
||||
vo.setFilename(filename);
|
||||
vo.setCount(count);
|
||||
vo.setNumber(number);
|
||||
if(total.length() > 0) {
|
||||
vo.setZhang(total);
|
||||
}else {
|
||||
vo.setZhang(String.valueOf(zhang));
|
||||
}
|
||||
vo.setRemark(remark);
|
||||
vo.setCreator(user.getRealname());
|
||||
list.add(vo);
|
||||
// finance2Mapper.insertSelective(vo);
|
||||
}
|
||||
}
|
||||
if (list.size() == 0) {
|
||||
return Msg.fail("上传失败,请检查文件表头是否正确");
|
||||
} else if (list.size() > 0) {
|
||||
finance3Mapper.insertForeach4(list);
|
||||
}
|
||||
in.close();
|
||||
return Msg.success();
|
||||
|
||||
}
|
||||
|
||||
private String cutCount(String remark) {
|
||||
int number = 0, count = 0, index = 0;
|
||||
String totalCount = "";
|
||||
String counts = "";
|
||||
String[] countList = {};
|
||||
if( remark.indexOf(",") > 0) {//合包的拼版计算
|
||||
String[] total = remark.split(",");
|
||||
for(int i = 0 ;i < total.length; i++) {
|
||||
String[] lists = total[i].split("-");
|
||||
for(int j = 0; j < lists.length; j++) {
|
||||
index = lists[j].indexOf("mm");
|
||||
if(index == -1) {
|
||||
index = lists[j].indexOf("cm");
|
||||
}
|
||||
|
||||
if(index > 0) {
|
||||
counts = lists[j+1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(counts.indexOf("各") > 0 && counts.indexOf("共") < 0) {
|
||||
countList = counts.split("款");
|
||||
number = Integer.valueOf(countList[0].replace("各", ""));
|
||||
count = Integer.valueOf(countList[1].substring(1, countList[1].length()-1));
|
||||
totalCount += "," + count * number;
|
||||
}else if(counts.indexOf("共") > 0){
|
||||
int coutIndex = counts.indexOf("共");
|
||||
String countValue = counts.substring(coutIndex, counts.length()-1);
|
||||
count = Integer.valueOf(countValue);
|
||||
}else {
|
||||
totalCount += "," + Integer.valueOf(counts.substring(0, counts.length()-1)) * 1;
|
||||
}
|
||||
}
|
||||
totalCount = totalCount.substring(1);
|
||||
return totalCount;
|
||||
}else {//单款尺寸
|
||||
String[] list = remark.split("-");
|
||||
for(int m = 0;m < list.length; m++) {
|
||||
index = list[m].indexOf("mm");
|
||||
if(index == -1) {
|
||||
index = list[m].indexOf("cm");
|
||||
}
|
||||
if(index > 0) {
|
||||
counts = list[m+1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(counts.indexOf("各") > 0 && counts.indexOf("共") < 0 ) {
|
||||
countList = counts.split("款");
|
||||
countList[1].substring(0, countList[1].length()-1);
|
||||
number = Integer.valueOf(countList[0].replace("各", ""));
|
||||
count = Integer.valueOf(countList[1].substring(1, countList[1].length()-1));
|
||||
count = count * number;
|
||||
}else if(counts.indexOf("共") > 0){
|
||||
int coutIndex = counts.indexOf("共");
|
||||
String countValue = counts.substring(coutIndex+1, counts.length()-1);
|
||||
count = Integer.valueOf(countValue);
|
||||
}else {
|
||||
count = Integer.valueOf(counts.substring(0, counts.length()-1)) * 1;
|
||||
}
|
||||
|
||||
return String.valueOf(count);
|
||||
}
|
||||
}
|
||||
|
||||
private String cutSize(String remark) {
|
||||
double length = 0,width = 0;
|
||||
int sizeIndex = 0;
|
||||
String totalSize = "";
|
||||
String size = "";
|
||||
String[] sizeList = {};
|
||||
double l = 430,w = 300;
|
||||
if( remark.indexOf(",") > 0) {//合包的拼版计算
|
||||
String[] total = remark.split(",");
|
||||
for(int i = 0 ;i < total.length; i++) {
|
||||
String[] lists = total[i].split("-");
|
||||
for(int j = 0; j < lists.length; j++) {
|
||||
sizeIndex = lists[j].indexOf("mm");
|
||||
if(sizeIndex == 0) {
|
||||
sizeIndex = lists[j].indexOf("cm");
|
||||
}
|
||||
|
||||
if(sizeIndex > 0) {
|
||||
size = lists[j].replace("mm", "");
|
||||
size = size.replace("cm", "");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(size.indexOf("×") > 0 ) {
|
||||
sizeList = size.split("×");
|
||||
}else if(size.indexOf("x") > 0){
|
||||
sizeList = size.split("x");
|
||||
}
|
||||
|
||||
length = Double.valueOf(sizeList[0]);
|
||||
width = Double.valueOf(sizeList[1]);
|
||||
|
||||
//+3mm出血
|
||||
length += 6;
|
||||
width += 6;
|
||||
|
||||
if (length == l + 6 || width == l + 6) {
|
||||
totalSize = "1";
|
||||
continue;
|
||||
}else if ((length > l || width > w) && (length > w || width > l)) {
|
||||
totalSize = "#";
|
||||
continue;
|
||||
}
|
||||
|
||||
// 一张纸 能做多少个此类尺寸的产品
|
||||
double max = Math.max(Math.floor(l / length) * Math.floor(w / width),
|
||||
Math.floor(l / width) * Math.floor(w / length));
|
||||
|
||||
totalSize += "," + String.valueOf(max);
|
||||
}
|
||||
|
||||
if(totalSize.indexOf("#") != 0) {
|
||||
totalSize = totalSize.substring(1);
|
||||
}
|
||||
|
||||
return totalSize;
|
||||
}else {
|
||||
String[] list = remark.split("-");
|
||||
for(int m = 0;m < list.length; m++) {
|
||||
sizeIndex = list[m].indexOf("mm");
|
||||
if(sizeIndex == 0) {
|
||||
sizeIndex = list[m].indexOf("cm");
|
||||
}
|
||||
|
||||
if(sizeIndex > 0) {
|
||||
size = list[m].replace("mm", "");
|
||||
size = size.replace("cm", "");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(size.indexOf("×") > 0 ) {
|
||||
sizeList = size.split("×");
|
||||
}else if(size.indexOf("x") > 0){
|
||||
sizeList = size.split("x");
|
||||
}
|
||||
|
||||
length = Double.valueOf(sizeList[0]);
|
||||
width = Double.valueOf(sizeList[1]);
|
||||
//+3mm出血
|
||||
length += 6;
|
||||
width += 6;
|
||||
|
||||
if (length == l + 6 || width == 2 + 6) {
|
||||
return "1";
|
||||
}else if ((length > l || width > w) && (length > w || width > l)) {
|
||||
return "#";
|
||||
}
|
||||
// 一张纸 能做多少个此类尺寸的产品
|
||||
double max = Math.max(Math.floor(l / length) * Math.floor(w / width),
|
||||
Math.floor(l / width) * Math.floor(w / length));
|
||||
return String.valueOf(max);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
public void excel(HttpServletResponse response, Finance finance) throws Exception {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
List<Finance> financesList = new ArrayList<Finance>();
|
||||
SysUser user = (SysUser) SecurityUtils.getSubject().getPrincipal();
|
||||
finance.setCreator(user.getRealname());
|
||||
financesList = getFinance(finance);
|
||||
|
||||
// 创建excel文件
|
||||
HSSFWorkbook wb = new HSSFWorkbook();
|
||||
// 创建sheet页
|
||||
HSSFSheet sheet = wb.createSheet("总表");
|
||||
String filename = "";
|
||||
// 创建标题行
|
||||
HSSFRow titleRow = sheet.createRow(0);
|
||||
titleRow.createCell(0).setCellValue("日期");
|
||||
titleRow.createCell(1).setCellValue("供应商");
|
||||
titleRow.createCell(2).setCellValue("店铺");
|
||||
titleRow.createCell(3).setCellValue("大类别");
|
||||
titleRow.createCell(4).setCellValue("小类别");
|
||||
titleRow.createCell(5).setCellValue("订单号");
|
||||
titleRow.createCell(6).setCellValue("文件名");
|
||||
titleRow.createCell(7).setCellValue("数量");
|
||||
titleRow.createCell(8).setCellValue("拼版数");
|
||||
titleRow.createCell(9).setCellValue("张数");
|
||||
titleRow.createCell(10).setCellValue("导入人");
|
||||
titleRow.createCell(11).setCellValue("导入日期");
|
||||
// 遍历将数据放到excel列中
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||
for (Finance finances : financesList) {
|
||||
filename = finance.getFilename();
|
||||
HSSFRow dataRow = sheet.createRow(sheet.getLastRowNum() + 1);
|
||||
dataRow.createCell(0).setCellValue("");
|
||||
if (finances.getAddTime() != null) {
|
||||
dataRow.createCell(0).setCellValue(formatter.format(finances.getAddTime()));
|
||||
}
|
||||
dataRow.createCell(1).setCellValue(finances.getSupplier());
|
||||
dataRow.createCell(2).setCellValue(finances.getShopname());
|
||||
dataRow.createCell(3).setCellValue(finances.getKind());
|
||||
dataRow.createCell(4).setCellValue(finances.getKind2());
|
||||
dataRow.createCell(5).setCellValue(finances.getOrderNumber());
|
||||
dataRow.createCell(6).setCellValue(finances.getRemark());
|
||||
dataRow.createCell(7).setCellValue(finances.getCount());
|
||||
dataRow.createCell(8).setCellValue(finances.getNumber());
|
||||
dataRow.createCell(9).setCellValue(finances.getZhang());
|
||||
dataRow.createCell(10).setCellValue(finances.getCreator());
|
||||
dataRow.createCell(11).setCellValue(formatter.format(finances.getCreateDate()));
|
||||
}
|
||||
|
||||
// 设置下载时客户端Excel的名称
|
||||
response.setContentType("application/octet-stream;charset=utf-8");
|
||||
response.setHeader("Content-Disposition",
|
||||
"attachment;filename=" + new String(filename.getBytes(), "iso-8859-1"));// + ".xls"
|
||||
|
||||
OutputStream ouputStream = response.getOutputStream();
|
||||
wb.write(ouputStream);
|
||||
ouputStream.flush();
|
||||
ouputStream.close();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,399 @@
|
||||
package lingtao.net.service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
|
||||
import org.apache.poi.hssf.usermodel.HSSFRow;
|
||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import lingtao.net.bean.Finance;
|
||||
import lingtao.net.bean.Msg;
|
||||
import lingtao.net.bean.SysUser;
|
||||
import lingtao.net.dao.Finance3Mapper;
|
||||
import lingtao.net.util.ExcelUtils;
|
||||
|
||||
@Service
|
||||
public class Finance5Service {
|
||||
|
||||
@Autowired
|
||||
private Finance3Mapper finance3Mapper;
|
||||
|
||||
public List<Finance> getFinance(Finance finance) {
|
||||
return finance3Mapper.getFinance5(finance);
|
||||
}
|
||||
|
||||
public List<String> getAllFilename(String creator) {
|
||||
return finance3Mapper.getAllFilename5(creator);
|
||||
}
|
||||
|
||||
public Msg deleteDataByFilename(String filename, String realname) {
|
||||
try {
|
||||
finance3Mapper.deleteDataByFilename5(filename, realname);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
public Msg ajaxUploadExcel(MultipartFile file) throws Exception {
|
||||
if (file.isEmpty()) {
|
||||
throw new Exception("文件不存在!");
|
||||
}
|
||||
SysUser user = (SysUser) SecurityUtils.getSubject().getPrincipal();
|
||||
InputStream in = null;
|
||||
List<List<Object>> listob = null;
|
||||
List<Finance> list = new ArrayList<Finance>(1000);
|
||||
try {
|
||||
in = file.getInputStream();
|
||||
listob = new ExcelUtils().getBankListByExcel(in, file.getOriginalFilename());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
String filename = file.getOriginalFilename();
|
||||
System.out.println(filename);
|
||||
for (int i = 0; i < listob.size(); i++) {
|
||||
synchronized (this) {
|
||||
Finance vo = new Finance();
|
||||
List<Object> lo = listob.get(i);
|
||||
if (lo.size() == 0 || lo.size() == 1 || lo.get(6) == "") {
|
||||
System.out.println("++++++++++++++");
|
||||
continue;
|
||||
}
|
||||
|
||||
String addTime = String.valueOf(lo.get(0)).trim();
|
||||
if(addTime.equals("日期")) {
|
||||
continue;
|
||||
}
|
||||
String supplier = String.valueOf(lo.get(1)).trim();
|
||||
String shopname = String.valueOf(lo.get(2)).trim();
|
||||
String kind = String.valueOf(lo.get(3)).trim();
|
||||
String kind2 = String.valueOf(lo.get(4)).trim();
|
||||
String orderNumber = String.valueOf(lo.get(5)).trim();
|
||||
String remark = String.valueOf(lo.get(6)).trim();
|
||||
remark = remark.replace("MM", "mm").replace("CM", "cm");
|
||||
if (remark.indexOf("mm") == -1 && remark.indexOf("cm") == -1) {
|
||||
System.out.println(remark);
|
||||
System.out.println("=================");
|
||||
}
|
||||
|
||||
// 数量
|
||||
String count = "#";
|
||||
// 拼版数
|
||||
String number = "#";
|
||||
// 所需张数
|
||||
double zhang = 0;
|
||||
String total = "";
|
||||
try {
|
||||
// 处理备注
|
||||
remark = remark.replace(",", ",");
|
||||
number = cutSize(remark);
|
||||
count = cutCount(remark);
|
||||
if(remark.indexOf(",") > 0) {
|
||||
String[] countList = count.split(",");
|
||||
String[] numberList = number.split(",");
|
||||
for(int j = 0;j < countList.length; j++) {
|
||||
if (countList[j].equals("#") || numberList[j].equals("#")) {
|
||||
zhang = 0;
|
||||
}else {
|
||||
zhang = Math.ceil(Double.valueOf(countList[j]) / Double.valueOf(numberList[j]));
|
||||
}
|
||||
total += ","+zhang;
|
||||
}
|
||||
total = total.substring(1);
|
||||
}else {
|
||||
if (count != "#" && number != "#") {
|
||||
if (count.contains("*")) {
|
||||
String[] countSplit = count.split("\\*");
|
||||
System.out.println(Double.valueOf(countSplit[0]));
|
||||
System.out.println(Double.valueOf(countSplit[1]));
|
||||
zhang = Math.ceil(Double.valueOf(countSplit[0]) * Double.valueOf(countSplit[1])
|
||||
/ Double.valueOf(number));
|
||||
} else {
|
||||
zhang = Math.ceil(Double.valueOf(count) / Double.valueOf(number));
|
||||
}
|
||||
}
|
||||
orderNumber = remark.substring(remark.indexOf("(") + 1, remark.indexOf(")"));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println(remark);
|
||||
// return Msg.fail(remark);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(addTime)) {
|
||||
Date javaDate = HSSFDateUtil.getJavaDate(Double.parseDouble(addTime));
|
||||
vo.setAddTime(javaDate);
|
||||
}
|
||||
// SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||
// Date add_date = formatter.parse(addTime);// 把字符串转为日期格式
|
||||
vo.setSupplier(supplier);
|
||||
vo.setShopname(shopname);
|
||||
vo.setKind(kind);
|
||||
vo.setKind2(kind2);
|
||||
vo.setOrderNumber(orderNumber);
|
||||
vo.setFilename(filename);
|
||||
vo.setCount(count);
|
||||
vo.setNumber(number);
|
||||
if(total.length() > 0) {
|
||||
vo.setZhang(total);
|
||||
}else {
|
||||
vo.setZhang(String.valueOf(zhang));
|
||||
}
|
||||
vo.setRemark(remark);
|
||||
vo.setCreator(user.getRealname());
|
||||
list.add(vo);
|
||||
// finance2Mapper.insertSelective(vo);
|
||||
}
|
||||
}
|
||||
if (list.size() == 0) {
|
||||
return Msg.fail("上传失败,请检查文件表头是否正确");
|
||||
} else if (list.size() > 0) {
|
||||
finance3Mapper.insertForeach5(list);
|
||||
}
|
||||
in.close();
|
||||
return Msg.success();
|
||||
|
||||
}
|
||||
|
||||
private String cutCount(String remark) {
|
||||
int number = 0, count = 0, index = 0;
|
||||
String totalCount = "";
|
||||
String counts = "";
|
||||
String[] countList = {};
|
||||
if( remark.indexOf(",") > 0) {//合包的拼版计算
|
||||
String[] total = remark.split(",");
|
||||
for(int i = 0 ;i < total.length; i++) {
|
||||
String[] lists = total[i].split("-");
|
||||
for(int j = 0; j < lists.length; j++) {
|
||||
index = lists[j].indexOf("mm");
|
||||
if(index == -1) {
|
||||
index = lists[j].indexOf("cm");
|
||||
}
|
||||
|
||||
if(index > 0) {
|
||||
counts = lists[j+1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(counts.indexOf("各") > 0 && counts.indexOf("共") < 0) {
|
||||
countList = counts.split("款");
|
||||
number = Integer.valueOf(countList[0].replace("各", ""));
|
||||
count = Integer.valueOf(countList[1].substring(1, countList[1].length()-1));
|
||||
totalCount += "," + count * number;
|
||||
}else if(counts.indexOf("共") > 0){
|
||||
int coutIndex = counts.indexOf("共");
|
||||
String countValue = counts.substring(coutIndex, counts.length()-1);
|
||||
count = Integer.valueOf(countValue);
|
||||
totalCount += "," + count;
|
||||
}else {
|
||||
totalCount += "," + Integer.valueOf(counts.substring(0, counts.length()-1)) * 1;
|
||||
}
|
||||
}
|
||||
totalCount = totalCount.substring(1);
|
||||
return totalCount;
|
||||
}else {//单款尺寸
|
||||
String[] list = remark.split("-");
|
||||
for(int m = 0;m < list.length; m++) {
|
||||
index = list[m].indexOf("mm");
|
||||
if(index == -1) {
|
||||
index = list[m].indexOf("cm");
|
||||
}
|
||||
if(index > 0) {
|
||||
counts = list[m+1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(counts.indexOf("各") > 0 && counts.indexOf("共") < 0 ) {
|
||||
countList = counts.split("款");
|
||||
countList[1].substring(0, countList[1].length()-1);
|
||||
number = Integer.valueOf(countList[0].replace("各", ""));
|
||||
count = Integer.valueOf(countList[1].substring(1, countList[1].length()-1));
|
||||
count = count * number;
|
||||
}else if(counts.indexOf("共") > 0){
|
||||
int coutIndex = counts.indexOf("共");
|
||||
String countValue = counts.substring(coutIndex+1, counts.length()-1);
|
||||
count = Integer.valueOf(countValue);
|
||||
}else {
|
||||
count = Integer.valueOf(counts.substring(0, counts.length()-1)) * 1;
|
||||
}
|
||||
|
||||
return String.valueOf(count);
|
||||
}
|
||||
}
|
||||
|
||||
private String cutSize(String remark) {
|
||||
double length = 0,width = 0;
|
||||
int sizeIndex = 0;
|
||||
String totalSize = "";
|
||||
String size = "";
|
||||
String[] sizeList = {};
|
||||
double l = 440,w = 310;
|
||||
if( remark.indexOf(",") > 0) {//合包的拼版计算
|
||||
String[] total = remark.split(",");
|
||||
for(int i = 0 ;i < total.length; i++) {
|
||||
String[] lists = total[i].split("-");
|
||||
for(int j = 0; j < lists.length; j++) {
|
||||
sizeIndex = lists[j].indexOf("mm");
|
||||
if(sizeIndex == 0) {
|
||||
sizeIndex = lists[j].indexOf("cm");
|
||||
}
|
||||
|
||||
if(sizeIndex > 0) {
|
||||
size = lists[j].replace("mm", "");
|
||||
size = size.replace("cm", "");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(size.indexOf("×") > 0 ) {
|
||||
sizeList = size.split("×");
|
||||
}else if(size.indexOf("x") > 0){
|
||||
sizeList = size.split("x");
|
||||
}
|
||||
|
||||
length = Double.valueOf(sizeList[0]);
|
||||
width = Double.valueOf(sizeList[1]);
|
||||
|
||||
//+3mm出血
|
||||
length += 6;
|
||||
width += 6;
|
||||
|
||||
if (length == l + 6 ) {
|
||||
totalSize = String.valueOf(w/width);
|
||||
continue;
|
||||
}else if(width == w + 6) {
|
||||
totalSize = String.valueOf(l/length);
|
||||
continue;
|
||||
}else if ((length > l || width > w) && (length > w || width > l)) {
|
||||
totalSize = "#";
|
||||
continue;
|
||||
}
|
||||
|
||||
// 一张纸 能做多少个此类尺寸的产品
|
||||
double max = Math.max(Math.floor(l / length) * Math.floor(w / width),
|
||||
Math.floor(l / width) * Math.floor(w / length));
|
||||
|
||||
totalSize += "," + String.valueOf(max);
|
||||
}
|
||||
|
||||
if(totalSize.indexOf("#") != 0) {
|
||||
totalSize = totalSize.substring(1);
|
||||
}
|
||||
|
||||
return totalSize;
|
||||
}else {
|
||||
String[] list = remark.split("-");
|
||||
for(int m = 0;m < list.length; m++) {
|
||||
sizeIndex = list[m].indexOf("mm");
|
||||
if(sizeIndex == 0) {
|
||||
sizeIndex = list[m].indexOf("cm");
|
||||
}
|
||||
|
||||
if(sizeIndex > 0) {
|
||||
size = list[m].replace("mm", "");
|
||||
size = size.replace("cm", "");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(size.indexOf("×") > 0 ) {
|
||||
sizeList = size.split("×");
|
||||
}else if(size.indexOf("x") > 0){
|
||||
sizeList = size.split("x");
|
||||
}
|
||||
|
||||
length = Double.valueOf(sizeList[0]);
|
||||
width = Double.valueOf(sizeList[1]);
|
||||
//+3mm出血
|
||||
length += 6;
|
||||
width += 6;
|
||||
|
||||
if (length == l + 6 ) {
|
||||
return String.valueOf(w/width);
|
||||
}else if(width == w + 6) {
|
||||
return String.valueOf(l/length);
|
||||
}else if ((length > l || width > w) && (length > w || width > l)) {
|
||||
return "#";
|
||||
}
|
||||
// 一张纸 能做多少个此类尺寸的产品
|
||||
double max = Math.max(Math.floor(l / length) * Math.floor(w / width),
|
||||
Math.floor(l / width) * Math.floor(w / length));
|
||||
return String.valueOf(max);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
public void excel(HttpServletResponse response, Finance finance) throws Exception {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
List<Finance> financesList = new ArrayList<Finance>();
|
||||
SysUser user = (SysUser) SecurityUtils.getSubject().getPrincipal();
|
||||
finance.setCreator(user.getRealname());
|
||||
financesList = getFinance(finance);
|
||||
|
||||
// 创建excel文件
|
||||
HSSFWorkbook wb = new HSSFWorkbook();
|
||||
// 创建sheet页
|
||||
HSSFSheet sheet = wb.createSheet("总表");
|
||||
String filename = "";
|
||||
// 创建标题行
|
||||
HSSFRow titleRow = sheet.createRow(0);
|
||||
titleRow.createCell(0).setCellValue("日期");
|
||||
titleRow.createCell(1).setCellValue("供应商");
|
||||
titleRow.createCell(2).setCellValue("店铺");
|
||||
titleRow.createCell(3).setCellValue("大类别");
|
||||
titleRow.createCell(4).setCellValue("小类别");
|
||||
titleRow.createCell(5).setCellValue("订单号");
|
||||
titleRow.createCell(6).setCellValue("文件名");
|
||||
titleRow.createCell(7).setCellValue("数量");
|
||||
titleRow.createCell(8).setCellValue("拼版数");
|
||||
titleRow.createCell(9).setCellValue("张数");
|
||||
titleRow.createCell(10).setCellValue("导入人");
|
||||
titleRow.createCell(11).setCellValue("导入日期");
|
||||
// 遍历将数据放到excel列中
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||
for (Finance finances : financesList) {
|
||||
filename = finance.getFilename();
|
||||
HSSFRow dataRow = sheet.createRow(sheet.getLastRowNum() + 1);
|
||||
dataRow.createCell(0).setCellValue("");
|
||||
if (finances.getAddTime() != null) {
|
||||
dataRow.createCell(0).setCellValue(formatter.format(finances.getAddTime()));
|
||||
}
|
||||
dataRow.createCell(1).setCellValue(finances.getSupplier());
|
||||
dataRow.createCell(2).setCellValue(finances.getShopname());
|
||||
dataRow.createCell(3).setCellValue(finances.getKind());
|
||||
dataRow.createCell(4).setCellValue(finances.getKind2());
|
||||
dataRow.createCell(5).setCellValue(finances.getOrderNumber());
|
||||
dataRow.createCell(6).setCellValue(finances.getRemark());
|
||||
dataRow.createCell(7).setCellValue(finances.getCount());
|
||||
dataRow.createCell(8).setCellValue(finances.getNumber());
|
||||
dataRow.createCell(9).setCellValue(finances.getZhang());
|
||||
dataRow.createCell(10).setCellValue(finances.getCreator());
|
||||
dataRow.createCell(11).setCellValue(formatter.format(finances.getCreateDate()));
|
||||
}
|
||||
|
||||
// 设置下载时客户端Excel的名称
|
||||
response.setContentType("application/octet-stream;charset=utf-8");
|
||||
response.setHeader("Content-Disposition",
|
||||
"attachment;filename=" + new String(filename.getBytes(), "iso-8859-1"));// + ".xls"
|
||||
|
||||
OutputStream ouputStream = response.getOutputStream();
|
||||
wb.write(ouputStream);
|
||||
ouputStream.flush();
|
||||
ouputStream.close();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,399 @@
|
||||
package lingtao.net.service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
|
||||
import org.apache.poi.hssf.usermodel.HSSFRow;
|
||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import lingtao.net.bean.Finance;
|
||||
import lingtao.net.bean.Msg;
|
||||
import lingtao.net.bean.SysUser;
|
||||
import lingtao.net.dao.Finance3Mapper;
|
||||
import lingtao.net.util.ExcelUtils;
|
||||
|
||||
@Service
|
||||
public class Finance6Service {
|
||||
|
||||
@Autowired
|
||||
private Finance3Mapper finance3Mapper;
|
||||
|
||||
public List<Finance> getFinance(Finance finance) {
|
||||
return finance3Mapper.getFinance6(finance);
|
||||
}
|
||||
|
||||
public List<String> getAllFilename(String creator) {
|
||||
return finance3Mapper.getAllFilename6(creator);
|
||||
}
|
||||
|
||||
public Msg deleteDataByFilename(String filename, String realname) {
|
||||
try {
|
||||
finance3Mapper.deleteDataByFilename6(filename, realname);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
public Msg ajaxUploadExcel(MultipartFile file) throws Exception {
|
||||
if (file.isEmpty()) {
|
||||
throw new Exception("文件不存在!");
|
||||
}
|
||||
SysUser user = (SysUser) SecurityUtils.getSubject().getPrincipal();
|
||||
InputStream in = null;
|
||||
List<List<Object>> listob = null;
|
||||
List<Finance> list = new ArrayList<Finance>(1000);
|
||||
try {
|
||||
in = file.getInputStream();
|
||||
listob = new ExcelUtils().getBankListByExcel(in, file.getOriginalFilename());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
String filename = file.getOriginalFilename();
|
||||
System.out.println(filename);
|
||||
for (int i = 0; i < listob.size(); i++) {
|
||||
synchronized (this) {
|
||||
Finance vo = new Finance();
|
||||
List<Object> lo = listob.get(i);
|
||||
if (lo.size() == 0 || lo.size() == 1 || lo.get(6) == "") {
|
||||
System.out.println("++++++++++++++");
|
||||
continue;
|
||||
}
|
||||
|
||||
String addTime = String.valueOf(lo.get(0)).trim();
|
||||
if(addTime.equals("日期")) {
|
||||
continue;
|
||||
}
|
||||
String supplier = String.valueOf(lo.get(1)).trim();
|
||||
String shopname = String.valueOf(lo.get(2)).trim();
|
||||
String kind = String.valueOf(lo.get(3)).trim();
|
||||
String kind2 = String.valueOf(lo.get(4)).trim();
|
||||
String orderNumber = String.valueOf(lo.get(5)).trim();
|
||||
String remark = String.valueOf(lo.get(6)).trim();
|
||||
remark = remark.replace("MM", "mm").replace("CM", "cm");
|
||||
if (remark.indexOf("mm") == -1 && remark.indexOf("cm") == -1) {
|
||||
System.out.println(remark);
|
||||
System.out.println("=================");
|
||||
}
|
||||
|
||||
// 数量
|
||||
String count = "#";
|
||||
// 拼版数
|
||||
String number = "#";
|
||||
// 所需张数
|
||||
double zhang = 0;
|
||||
String total = "";
|
||||
try {
|
||||
// 处理备注
|
||||
remark = remark.replace(",", ",");
|
||||
number = cutSize(remark);
|
||||
count = cutCount(remark);
|
||||
if(remark.indexOf(",") > 0) {
|
||||
String[] countList = count.split(",");
|
||||
String[] numberList = number.split(",");
|
||||
for(int j = 0;j < countList.length; j++) {
|
||||
if (countList[j].equals("#") || numberList[j].equals("#")) {
|
||||
zhang = 0;
|
||||
}else {
|
||||
zhang = Math.ceil(Double.valueOf(countList[j]) / Double.valueOf(numberList[j]));
|
||||
}
|
||||
total += ","+zhang;
|
||||
}
|
||||
total = total.substring(1);
|
||||
}else {
|
||||
if (count != "#" && number != "#") {
|
||||
if (count.contains("*")) {
|
||||
String[] countSplit = count.split("\\*");
|
||||
System.out.println(Double.valueOf(countSplit[0]));
|
||||
System.out.println(Double.valueOf(countSplit[1]));
|
||||
zhang = Math.ceil(Double.valueOf(countSplit[0]) * Double.valueOf(countSplit[1])
|
||||
/ Double.valueOf(number));
|
||||
} else {
|
||||
zhang = Math.ceil(Double.valueOf(count) / Double.valueOf(number));
|
||||
}
|
||||
}
|
||||
orderNumber = remark.substring(remark.indexOf("(") + 1, remark.indexOf(")"));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println(remark);
|
||||
// return Msg.fail(remark);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(addTime)) {
|
||||
Date javaDate = HSSFDateUtil.getJavaDate(Double.parseDouble(addTime));
|
||||
vo.setAddTime(javaDate);
|
||||
}
|
||||
// SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||
// Date add_date = formatter.parse(addTime);// 把字符串转为日期格式
|
||||
vo.setSupplier(supplier);
|
||||
vo.setShopname(shopname);
|
||||
vo.setKind(kind);
|
||||
vo.setKind2(kind2);
|
||||
vo.setOrderNumber(orderNumber);
|
||||
vo.setFilename(filename);
|
||||
vo.setCount(count);
|
||||
vo.setNumber(number);
|
||||
if(total.length() > 0) {
|
||||
vo.setZhang(total);
|
||||
}else {
|
||||
vo.setZhang(String.valueOf(zhang));
|
||||
}
|
||||
vo.setRemark(remark);
|
||||
vo.setCreator(user.getRealname());
|
||||
list.add(vo);
|
||||
// finance2Mapper.insertSelective(vo);
|
||||
}
|
||||
}
|
||||
if (list.size() == 0) {
|
||||
return Msg.fail("上传失败,请检查文件表头是否正确");
|
||||
} else if (list.size() > 0) {
|
||||
finance3Mapper.insertForeach6(list);
|
||||
}
|
||||
in.close();
|
||||
return Msg.success();
|
||||
|
||||
}
|
||||
|
||||
private String cutCount(String remark) {
|
||||
int number = 0, count = 0, index = 0;
|
||||
String totalCount = "";
|
||||
String counts = "";
|
||||
String[] countList = {};
|
||||
if( remark.indexOf(",") > 0) {//合包的拼版计算
|
||||
String[] total = remark.split(",");
|
||||
for(int i = 0 ;i < total.length; i++) {
|
||||
String[] lists = total[i].split("-");
|
||||
for(int j = 0; j < lists.length; j++) {
|
||||
index = lists[j].indexOf("mm");
|
||||
if(index == -1) {
|
||||
index = lists[j].indexOf("cm");
|
||||
}
|
||||
|
||||
if(index > 0) {
|
||||
counts = lists[j+1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(counts.indexOf("各") > 0 && counts.indexOf("共") < 0) {
|
||||
countList = counts.split("款");
|
||||
number = Integer.valueOf(countList[0].replace("各", ""));
|
||||
count = Integer.valueOf(countList[1].substring(1, countList[1].length()-1));
|
||||
totalCount += "," + count * number;
|
||||
}else if(counts.indexOf("共") > 0){
|
||||
int coutIndex = counts.indexOf("共");
|
||||
String countValue = counts.substring(coutIndex+1, counts.length()-1);
|
||||
count = Integer.valueOf(countValue);
|
||||
totalCount += "," + count;
|
||||
}else {
|
||||
totalCount += "," + Integer.valueOf(counts.substring(0, counts.length()-1)) * 1;
|
||||
}
|
||||
}
|
||||
totalCount = totalCount.substring(1);
|
||||
return totalCount;
|
||||
}else {//单款尺寸
|
||||
String[] list = remark.split("-");
|
||||
for(int m = 0;m < list.length; m++) {
|
||||
index = list[m].indexOf("mm");
|
||||
if(index == -1) {
|
||||
index = list[m].indexOf("cm");
|
||||
}
|
||||
if(index > 0) {
|
||||
counts = list[m+1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(counts.indexOf("各") > 0 && counts.indexOf("共") < 0 ) {
|
||||
countList = counts.split("款");
|
||||
countList[1].substring(0, countList[1].length()-1);
|
||||
number = Integer.valueOf(countList[0].replace("各", ""));
|
||||
count = Integer.valueOf(countList[1].substring(1, countList[1].length()-1));
|
||||
count = count * number;
|
||||
}else if(counts.indexOf("共") > 0){
|
||||
int coutIndex = counts.indexOf("共");
|
||||
String countValue = counts.substring(coutIndex+1, counts.length()-1);
|
||||
count = Integer.valueOf(countValue);
|
||||
}else {
|
||||
count = Integer.valueOf(counts.substring(0, counts.length()-1));
|
||||
}
|
||||
|
||||
return String.valueOf(count);
|
||||
}
|
||||
}
|
||||
|
||||
private String cutSize(String remark) {
|
||||
double length = 0,width = 0;
|
||||
int sizeIndex = 0;
|
||||
String totalSize = "";
|
||||
String size = "";
|
||||
String[] sizeList = {};
|
||||
double l = 425,w = 300;
|
||||
if( remark.indexOf(",") > 0) {//合包的拼版计算
|
||||
String[] total = remark.split(",");
|
||||
for(int i = 0 ;i < total.length; i++) {
|
||||
String[] lists = total[i].split("-");
|
||||
for(int j = 0; j < lists.length; j++) {
|
||||
sizeIndex = lists[j].indexOf("mm");
|
||||
if(sizeIndex == 0) {
|
||||
sizeIndex = lists[j].indexOf("cm");
|
||||
}
|
||||
|
||||
if(sizeIndex > 0) {
|
||||
size = lists[j].replace("mm", "");
|
||||
size = size.replace("cm", "");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(size.indexOf("×") > 0 ) {
|
||||
sizeList = size.split("×");
|
||||
}else if(size.indexOf("x") > 0){
|
||||
sizeList = size.split("x");
|
||||
}
|
||||
|
||||
length = Double.valueOf(sizeList[0]);
|
||||
width = Double.valueOf(sizeList[1]);
|
||||
|
||||
//+4mm出血
|
||||
length += 8;
|
||||
width += 8;
|
||||
|
||||
if (length == l + 8 ) {
|
||||
totalSize = String.valueOf(w/width);
|
||||
continue;
|
||||
}else if(width == w + 8) {
|
||||
totalSize = String.valueOf(l/length);
|
||||
continue;
|
||||
}else if ((length > l || width > w) && (length > w || width > l)) {
|
||||
totalSize = "#";
|
||||
continue;
|
||||
}
|
||||
|
||||
// 一张纸 能做多少个此类尺寸的产品
|
||||
double max = Math.max(Math.floor(l / length) * Math.floor(w / width),
|
||||
Math.floor(l / width) * Math.floor(w / length));
|
||||
|
||||
totalSize += "," + String.valueOf(max);
|
||||
}
|
||||
|
||||
if(totalSize.indexOf("#") != 0) {
|
||||
totalSize = totalSize.substring(1);
|
||||
}
|
||||
|
||||
return totalSize;
|
||||
}else {
|
||||
String[] list = remark.split("-");
|
||||
for(int m = 0;m < list.length; m++) {
|
||||
sizeIndex = list[m].indexOf("mm");
|
||||
if(sizeIndex == 0) {
|
||||
sizeIndex = list[m].indexOf("cm");
|
||||
}
|
||||
|
||||
if(sizeIndex > 0) {
|
||||
size = list[m].replace("mm", "");
|
||||
size = size.replace("cm", "");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(size.indexOf("×") > 0 ) {
|
||||
sizeList = size.split("×");
|
||||
}else if(size.indexOf("x") > 0){
|
||||
sizeList = size.split("x");
|
||||
}
|
||||
|
||||
length = Double.valueOf(sizeList[0]);
|
||||
width = Double.valueOf(sizeList[1]);
|
||||
//+4mm出血
|
||||
length += 8;
|
||||
width += 8;
|
||||
|
||||
if (length == l + 8 ) {
|
||||
return String.valueOf(w/width);
|
||||
}else if(width == w + 8) {
|
||||
return String.valueOf(l/length);
|
||||
}else if ((length > l || width > w) && (length > w || width > l)) {
|
||||
return "#";
|
||||
}
|
||||
// 一张纸 能做多少个此类尺寸的产品
|
||||
double max = Math.max(Math.floor(l / length) * Math.floor(w / width),
|
||||
Math.floor(l / width) * Math.floor(w / length));
|
||||
return String.valueOf(max);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
public void excel(HttpServletResponse response, Finance finance) throws Exception {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
List<Finance> financesList = new ArrayList<Finance>();
|
||||
SysUser user = (SysUser) SecurityUtils.getSubject().getPrincipal();
|
||||
finance.setCreator(user.getRealname());
|
||||
financesList = getFinance(finance);
|
||||
|
||||
// 创建excel文件
|
||||
HSSFWorkbook wb = new HSSFWorkbook();
|
||||
// 创建sheet页
|
||||
HSSFSheet sheet = wb.createSheet("总表");
|
||||
String filename = "";
|
||||
// 创建标题行
|
||||
HSSFRow titleRow = sheet.createRow(0);
|
||||
titleRow.createCell(0).setCellValue("日期");
|
||||
titleRow.createCell(1).setCellValue("供应商");
|
||||
titleRow.createCell(2).setCellValue("店铺");
|
||||
titleRow.createCell(3).setCellValue("大类别");
|
||||
titleRow.createCell(4).setCellValue("小类别");
|
||||
titleRow.createCell(5).setCellValue("订单号");
|
||||
titleRow.createCell(6).setCellValue("文件名");
|
||||
titleRow.createCell(7).setCellValue("数量");
|
||||
titleRow.createCell(8).setCellValue("拼版数");
|
||||
titleRow.createCell(9).setCellValue("张数");
|
||||
titleRow.createCell(10).setCellValue("导入人");
|
||||
titleRow.createCell(11).setCellValue("导入日期");
|
||||
// 遍历将数据放到excel列中
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||
for (Finance finances : financesList) {
|
||||
filename = finance.getFilename();
|
||||
HSSFRow dataRow = sheet.createRow(sheet.getLastRowNum() + 1);
|
||||
dataRow.createCell(0).setCellValue("");
|
||||
if (finances.getAddTime() != null) {
|
||||
dataRow.createCell(0).setCellValue(formatter.format(finances.getAddTime()));
|
||||
}
|
||||
dataRow.createCell(1).setCellValue(finances.getSupplier());
|
||||
dataRow.createCell(2).setCellValue(finances.getShopname());
|
||||
dataRow.createCell(3).setCellValue(finances.getKind());
|
||||
dataRow.createCell(4).setCellValue(finances.getKind2());
|
||||
dataRow.createCell(5).setCellValue(finances.getOrderNumber());
|
||||
dataRow.createCell(6).setCellValue(finances.getRemark());
|
||||
dataRow.createCell(7).setCellValue(finances.getCount());
|
||||
dataRow.createCell(8).setCellValue(finances.getNumber());
|
||||
dataRow.createCell(9).setCellValue(finances.getZhang());
|
||||
dataRow.createCell(10).setCellValue(finances.getCreator());
|
||||
dataRow.createCell(11).setCellValue(formatter.format(finances.getCreateDate()));
|
||||
}
|
||||
|
||||
// 设置下载时客户端Excel的名称
|
||||
response.setContentType("application/octet-stream;charset=utf-8");
|
||||
response.setHeader("Content-Disposition",
|
||||
"attachment;filename=" + new String(filename.getBytes(), "iso-8859-1"));// + ".xls"
|
||||
|
||||
OutputStream ouputStream = response.getOutputStream();
|
||||
wb.write(ouputStream);
|
||||
ouputStream.flush();
|
||||
ouputStream.close();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,399 @@
|
||||
package lingtao.net.service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
|
||||
import org.apache.poi.hssf.usermodel.HSSFRow;
|
||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import lingtao.net.bean.Finance;
|
||||
import lingtao.net.bean.Msg;
|
||||
import lingtao.net.bean.SysUser;
|
||||
import lingtao.net.dao.Finance3Mapper;
|
||||
import lingtao.net.util.ExcelUtils;
|
||||
|
||||
@Service
|
||||
public class Finance7Service {
|
||||
|
||||
@Autowired
|
||||
private Finance3Mapper finance3Mapper;
|
||||
|
||||
public List<Finance> getFinance(Finance finance) {
|
||||
return finance3Mapper.getFinance7(finance);
|
||||
}
|
||||
|
||||
public List<String> getAllFilename(String creator) {
|
||||
return finance3Mapper.getAllFilename7(creator);
|
||||
}
|
||||
|
||||
public Msg deleteDataByFilename(String filename, String realname) {
|
||||
try {
|
||||
finance3Mapper.deleteDataByFilename7(filename, realname);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
public Msg ajaxUploadExcel(MultipartFile file) throws Exception {
|
||||
if (file.isEmpty()) {
|
||||
throw new Exception("文件不存在!");
|
||||
}
|
||||
SysUser user = (SysUser) SecurityUtils.getSubject().getPrincipal();
|
||||
InputStream in = null;
|
||||
List<List<Object>> listob = null;
|
||||
List<Finance> list = new ArrayList<Finance>(1000);
|
||||
try {
|
||||
in = file.getInputStream();
|
||||
listob = new ExcelUtils().getBankListByExcel(in, file.getOriginalFilename());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
String filename = file.getOriginalFilename();
|
||||
System.out.println(filename);
|
||||
for (int i = 0; i < listob.size(); i++) {
|
||||
synchronized (this) {
|
||||
Finance vo = new Finance();
|
||||
List<Object> lo = listob.get(i);
|
||||
if (lo.size() == 0 || lo.size() == 1 || lo.get(6) == "") {
|
||||
System.out.println("++++++++++++++");
|
||||
continue;
|
||||
}
|
||||
|
||||
String addTime = String.valueOf(lo.get(0)).trim();
|
||||
if(addTime.equals("日期")) {
|
||||
continue;
|
||||
}
|
||||
String supplier = String.valueOf(lo.get(1)).trim();
|
||||
String shopname = String.valueOf(lo.get(2)).trim();
|
||||
String kind = String.valueOf(lo.get(3)).trim();
|
||||
String kind2 = String.valueOf(lo.get(4)).trim();
|
||||
String orderNumber = String.valueOf(lo.get(5)).trim();
|
||||
String remark = String.valueOf(lo.get(6)).trim();
|
||||
remark = remark.replace("MM", "mm").replace("CM", "cm");
|
||||
if (remark.indexOf("mm") == -1 && remark.indexOf("cm") == -1) {
|
||||
System.out.println(remark);
|
||||
System.out.println("=================");
|
||||
}
|
||||
|
||||
// 数量
|
||||
String count = "#";
|
||||
// 拼版数
|
||||
String number = "#";
|
||||
// 所需张数
|
||||
double zhang = 0;
|
||||
String total = "";
|
||||
try {
|
||||
// 处理备注
|
||||
remark = remark.replace(",", ",");
|
||||
number = cutSize(remark);
|
||||
count = cutCount(remark);
|
||||
if(remark.indexOf(",") > 0) {
|
||||
String[] countList = count.split(",");
|
||||
String[] numberList = number.split(",");
|
||||
for(int j = 0;j < countList.length; j++) {
|
||||
if (countList[j].equals("#") || numberList[j].equals("#")) {
|
||||
zhang = 0;
|
||||
}else {
|
||||
zhang = Math.ceil(Double.valueOf(countList[j]) / Double.valueOf(numberList[j]));
|
||||
}
|
||||
total += ","+zhang;
|
||||
}
|
||||
total = total.substring(1);
|
||||
}else {
|
||||
if (count != "#" && number != "#") {
|
||||
if (count.contains("*")) {
|
||||
String[] countSplit = count.split("\\*");
|
||||
System.out.println(Double.valueOf(countSplit[0]));
|
||||
System.out.println(Double.valueOf(countSplit[1]));
|
||||
zhang = Math.ceil(Double.valueOf(countSplit[0]) * Double.valueOf(countSplit[1])
|
||||
/ Double.valueOf(number));
|
||||
} else {
|
||||
zhang = Math.ceil(Double.valueOf(count) / Double.valueOf(number));
|
||||
}
|
||||
}
|
||||
orderNumber = remark.substring(remark.indexOf("(") + 1, remark.indexOf(")"));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println(remark);
|
||||
// return Msg.fail(remark);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(addTime)) {
|
||||
Date javaDate = HSSFDateUtil.getJavaDate(Double.parseDouble(addTime));
|
||||
vo.setAddTime(javaDate);
|
||||
}
|
||||
// SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||
// Date add_date = formatter.parse(addTime);// 把字符串转为日期格式
|
||||
vo.setSupplier(supplier);
|
||||
vo.setShopname(shopname);
|
||||
vo.setKind(kind);
|
||||
vo.setKind2(kind2);
|
||||
vo.setOrderNumber(orderNumber);
|
||||
vo.setFilename(filename);
|
||||
vo.setCount(count);
|
||||
vo.setNumber(number);
|
||||
if(total.length() > 0) {
|
||||
vo.setZhang(total);
|
||||
}else {
|
||||
vo.setZhang(String.valueOf(zhang));
|
||||
}
|
||||
vo.setRemark(remark);
|
||||
vo.setCreator(user.getRealname());
|
||||
list.add(vo);
|
||||
// finance2Mapper.insertSelective(vo);
|
||||
}
|
||||
}
|
||||
if (list.size() == 0) {
|
||||
return Msg.fail("上传失败,请检查文件表头是否正确");
|
||||
} else if (list.size() > 0) {
|
||||
finance3Mapper.insertForeach7(list);
|
||||
}
|
||||
in.close();
|
||||
return Msg.success();
|
||||
|
||||
}
|
||||
|
||||
private String cutCount(String remark) {
|
||||
int number = 0, count = 0, index = 0;
|
||||
String totalCount = "";
|
||||
String counts = "";
|
||||
String[] countList = {};
|
||||
if( remark.indexOf(",") > 0) {//合包的拼版计算
|
||||
String[] total = remark.split(",");
|
||||
for(int i = 0 ;i < total.length; i++) {
|
||||
String[] lists = total[i].split("-");
|
||||
for(int j = 0; j < lists.length; j++) {
|
||||
index = lists[j].indexOf("mm");
|
||||
if(index == -1) {
|
||||
index = lists[j].indexOf("cm");
|
||||
}
|
||||
|
||||
if(index > 0) {
|
||||
counts = lists[j+1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(counts.indexOf("各") > 0 && counts.indexOf("共") < 0) {
|
||||
countList = counts.split("款");
|
||||
number = Integer.valueOf(countList[0].replace("各", ""));
|
||||
count = Integer.valueOf(countList[1].substring(1, countList[1].length()-1));
|
||||
totalCount += "," + count * number;
|
||||
}else if(counts.indexOf("共") > 0){
|
||||
int coutIndex = counts.indexOf("共");
|
||||
String countValue = counts.substring(coutIndex+1, counts.length()-1);
|
||||
count = Integer.valueOf(countValue);
|
||||
totalCount += "," + count;
|
||||
}else {
|
||||
totalCount += "," + Integer.valueOf(counts.substring(0, counts.length()-1)) * 1;
|
||||
}
|
||||
}
|
||||
totalCount = totalCount.substring(1);
|
||||
return totalCount;
|
||||
}else {//单款尺寸
|
||||
String[] list = remark.split("-");
|
||||
for(int m = 0;m < list.length; m++) {
|
||||
index = list[m].indexOf("mm");
|
||||
if(index == -1) {
|
||||
index = list[m].indexOf("cm");
|
||||
}
|
||||
if(index > 0) {
|
||||
counts = list[m+1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(counts.indexOf("各") > 0 && counts.indexOf("共") < 0 ) {
|
||||
countList = counts.split("款");
|
||||
countList[1].substring(0, countList[1].length()-1);
|
||||
number = Integer.valueOf(countList[0].replace("各", ""));
|
||||
count = Integer.valueOf(countList[1].substring(1, countList[1].length()-1));
|
||||
count = count * number;
|
||||
}else if(counts.indexOf("共") > 0){
|
||||
int coutIndex = counts.indexOf("共");
|
||||
String countValue = counts.substring(coutIndex+1, counts.length()-1);
|
||||
count = Integer.valueOf(countValue);
|
||||
}else {
|
||||
count = Integer.valueOf(counts.substring(0, counts.length()-1));
|
||||
}
|
||||
|
||||
return String.valueOf(count);
|
||||
}
|
||||
}
|
||||
|
||||
private String cutSize(String remark) {
|
||||
double length = 0,width = 0;
|
||||
int sizeIndex = 0;
|
||||
String totalSize = "";
|
||||
String size = "";
|
||||
String[] sizeList = {};
|
||||
double l = 420,w = 280;
|
||||
if( remark.indexOf(",") > 0) {//合包的拼版计算
|
||||
String[] total = remark.split(",");
|
||||
for(int i = 0 ;i < total.length; i++) {
|
||||
String[] lists = total[i].split("-");
|
||||
for(int j = 0; j < lists.length; j++) {
|
||||
sizeIndex = lists[j].indexOf("mm");
|
||||
if(sizeIndex == 0) {
|
||||
sizeIndex = lists[j].indexOf("cm");
|
||||
}
|
||||
|
||||
if(sizeIndex > 0) {
|
||||
size = lists[j].replace("mm", "");
|
||||
size = size.replace("cm", "");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(size.indexOf("×") > 0 ) {
|
||||
sizeList = size.split("×");
|
||||
}else if(size.indexOf("x") > 0){
|
||||
sizeList = size.split("x");
|
||||
}
|
||||
|
||||
length = Double.valueOf(sizeList[0]);
|
||||
width = Double.valueOf(sizeList[1]);
|
||||
|
||||
//+2mm出血
|
||||
length += 4;
|
||||
width += 4;
|
||||
|
||||
if (length == l + 4 ) {
|
||||
totalSize = String.valueOf(w/width);
|
||||
continue;
|
||||
}else if(width == w + 4) {
|
||||
totalSize = String.valueOf(l/length);
|
||||
continue;
|
||||
}else if ((length > l || width > w) && (length > w || width > l)) {
|
||||
totalSize = "#";
|
||||
continue;
|
||||
}
|
||||
|
||||
// 一张纸 能做多少个此类尺寸的产品
|
||||
double max = Math.max(Math.floor(l / length) * Math.floor(w / width),
|
||||
Math.floor(l / width) * Math.floor(w / length));
|
||||
|
||||
totalSize += "," + String.valueOf(max);
|
||||
}
|
||||
|
||||
if(totalSize.indexOf("#") != 0) {
|
||||
totalSize = totalSize.substring(1);
|
||||
}
|
||||
|
||||
return totalSize;
|
||||
}else {
|
||||
String[] list = remark.split("-");
|
||||
for(int m = 0;m < list.length; m++) {
|
||||
sizeIndex = list[m].indexOf("mm");
|
||||
if(sizeIndex == 0) {
|
||||
sizeIndex = list[m].indexOf("cm");
|
||||
}
|
||||
|
||||
if(sizeIndex > 0) {
|
||||
size = list[m].replace("mm", "");
|
||||
size = size.replace("cm", "");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(size.indexOf("×") > 0 ) {
|
||||
sizeList = size.split("×");
|
||||
}else if(size.indexOf("x") > 0){
|
||||
sizeList = size.split("x");
|
||||
}
|
||||
|
||||
length = Double.valueOf(sizeList[0]);
|
||||
width = Double.valueOf(sizeList[1]);
|
||||
//+2mm出血
|
||||
length += 4;
|
||||
width += 4;
|
||||
|
||||
if (length == l + 4 ) {
|
||||
return String.valueOf(w/width);
|
||||
}else if(width == w + 4) {
|
||||
return String.valueOf(l/length);
|
||||
}else if ((length > l || width > w) && (length > w || width > l)) {
|
||||
return "#";
|
||||
}
|
||||
// 一张纸 能做多少个此类尺寸的产品
|
||||
double max = Math.max(Math.floor(l / length) * Math.floor(w / width),
|
||||
Math.floor(l / width) * Math.floor(w / length));
|
||||
return String.valueOf(max);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
public void excel(HttpServletResponse response, Finance finance) throws Exception {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
List<Finance> financesList = new ArrayList<Finance>();
|
||||
SysUser user = (SysUser) SecurityUtils.getSubject().getPrincipal();
|
||||
finance.setCreator(user.getRealname());
|
||||
financesList = getFinance(finance);
|
||||
|
||||
// 创建excel文件
|
||||
HSSFWorkbook wb = new HSSFWorkbook();
|
||||
// 创建sheet页
|
||||
HSSFSheet sheet = wb.createSheet("总表");
|
||||
String filename = "";
|
||||
// 创建标题行
|
||||
HSSFRow titleRow = sheet.createRow(0);
|
||||
titleRow.createCell(0).setCellValue("日期");
|
||||
titleRow.createCell(1).setCellValue("供应商");
|
||||
titleRow.createCell(2).setCellValue("店铺");
|
||||
titleRow.createCell(3).setCellValue("大类别");
|
||||
titleRow.createCell(4).setCellValue("小类别");
|
||||
titleRow.createCell(5).setCellValue("订单号");
|
||||
titleRow.createCell(6).setCellValue("文件名");
|
||||
titleRow.createCell(7).setCellValue("数量");
|
||||
titleRow.createCell(8).setCellValue("拼版数");
|
||||
titleRow.createCell(9).setCellValue("张数");
|
||||
titleRow.createCell(10).setCellValue("导入人");
|
||||
titleRow.createCell(11).setCellValue("导入日期");
|
||||
// 遍历将数据放到excel列中
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||
for (Finance finances : financesList) {
|
||||
filename = finance.getFilename();
|
||||
HSSFRow dataRow = sheet.createRow(sheet.getLastRowNum() + 1);
|
||||
dataRow.createCell(0).setCellValue("");
|
||||
if (finances.getAddTime() != null) {
|
||||
dataRow.createCell(0).setCellValue(formatter.format(finances.getAddTime()));
|
||||
}
|
||||
dataRow.createCell(1).setCellValue(finances.getSupplier());
|
||||
dataRow.createCell(2).setCellValue(finances.getShopname());
|
||||
dataRow.createCell(3).setCellValue(finances.getKind());
|
||||
dataRow.createCell(4).setCellValue(finances.getKind2());
|
||||
dataRow.createCell(5).setCellValue(finances.getOrderNumber());
|
||||
dataRow.createCell(6).setCellValue(finances.getRemark());
|
||||
dataRow.createCell(7).setCellValue(finances.getCount());
|
||||
dataRow.createCell(8).setCellValue(finances.getNumber());
|
||||
dataRow.createCell(9).setCellValue(finances.getZhang());
|
||||
dataRow.createCell(10).setCellValue(finances.getCreator());
|
||||
dataRow.createCell(11).setCellValue(formatter.format(finances.getCreateDate()));
|
||||
}
|
||||
|
||||
// 设置下载时客户端Excel的名称
|
||||
response.setContentType("application/octet-stream;charset=utf-8");
|
||||
response.setHeader("Content-Disposition",
|
||||
"attachment;filename=" + new String(filename.getBytes(), "iso-8859-1"));// + ".xls"
|
||||
|
||||
OutputStream ouputStream = response.getOutputStream();
|
||||
wb.write(ouputStream);
|
||||
ouputStream.flush();
|
||||
ouputStream.close();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
package lingtao.net.service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.poi.hssf.usermodel.HSSFRow;
|
||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import lingtao.net.bean.FinanceDifference;
|
||||
import lingtao.net.bean.Msg;
|
||||
import lingtao.net.bean.SysUser;
|
||||
import lingtao.net.dao.FinanceDifferenceMapper;
|
||||
import lingtao.net.util.ExcelUtils;
|
||||
|
||||
@Service
|
||||
public class FinanceDifferenceService {
|
||||
|
||||
@Autowired
|
||||
private FinanceDifferenceMapper differenceMapper;
|
||||
|
||||
public List<FinanceDifference> get(FinanceDifference difference) {
|
||||
return differenceMapper.get(difference);
|
||||
}
|
||||
|
||||
public Msg ajaxUploadExcel(MultipartFile file) throws Exception {
|
||||
if (file.isEmpty()) {
|
||||
throw new Exception("文件不存在!");
|
||||
}
|
||||
SysUser user = (SysUser) SecurityUtils.getSubject().getPrincipal();
|
||||
InputStream in = null;
|
||||
List<List<Object>> listob = null;
|
||||
List<FinanceDifference> list = new ArrayList<FinanceDifference>(1000);
|
||||
try {
|
||||
in = file.getInputStream();
|
||||
listob = new ExcelUtils().getBankListByExcel(in, file.getOriginalFilename());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
String openOrderNumber = "";
|
||||
String filename = file.getOriginalFilename();
|
||||
System.out.println(filename);
|
||||
for (int i = 0; i < listob.size(); i++) {
|
||||
synchronized (this) {
|
||||
FinanceDifference vo = new FinanceDifference();
|
||||
List<Object> lo = listob.get(i);
|
||||
if (lo.size() == 0 || lo.size() == 1 || lo.get(4) == "") {
|
||||
System.out.println("++++++++++++++");
|
||||
continue;
|
||||
}
|
||||
String orderNumber = String.valueOf(lo.get(0)).trim();
|
||||
String shopname = String.valueOf(lo.get(1)).trim();
|
||||
String wangwang = String.valueOf(lo.get(2)).trim();
|
||||
String payTime = String.valueOf(lo.get(3)).trim();
|
||||
String price = String.valueOf(lo.get(4)).trim();
|
||||
String remark = String.valueOf(lo.get(5)).trim();
|
||||
String taobaoStatus = String.valueOf(lo.get(6)).trim();
|
||||
SimpleDateFormat formatter = null;
|
||||
if (payTime.contains("-")) {
|
||||
formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
} else if (payTime.contains("/")) {
|
||||
formatter = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
|
||||
}
|
||||
Date pay_time = formatter.parse(payTime);// 把字符串转为日期格式
|
||||
vo.setOrderNumber(orderNumber);
|
||||
vo.setShopname(shopname);
|
||||
vo.setWangwang(wangwang);
|
||||
vo.setPayTime(pay_time);
|
||||
vo.setPrice(price);
|
||||
vo.setRemark(remark);
|
||||
vo.setTaobaoStatus(taobaoStatus);
|
||||
try {
|
||||
openOrderNumber = cutOrderNumber(remark);
|
||||
} catch (Exception e) {
|
||||
System.out.println(remark);
|
||||
}
|
||||
// openOrderNumber = remark.replaceAll("[^(0-9)]", "");
|
||||
vo.setOpenOrderNumber(openOrderNumber);
|
||||
vo.setFilename(filename);
|
||||
vo.setCreator(user.getRealname());
|
||||
list.add(vo);
|
||||
}
|
||||
}
|
||||
if (list.size() > 0) {
|
||||
differenceMapper.insertForeach(list);
|
||||
}
|
||||
in.close();
|
||||
return Msg.success();
|
||||
}
|
||||
|
||||
private String cutOrderNumber(String remark) {
|
||||
// 获取字符串中的数字
|
||||
// 这个15是指连续数字的最少个数
|
||||
Pattern p = Pattern.compile("\\d{15,}");
|
||||
Matcher m = p.matcher(remark);
|
||||
String openOrder = "";
|
||||
while (m.find()) {
|
||||
openOrder = m.group();
|
||||
}
|
||||
if (remark.contains("S_")) {
|
||||
if (remark.contains("C")) {
|
||||
return "S_C1_" + openOrder;
|
||||
} else {
|
||||
return "S_" + openOrder;
|
||||
}
|
||||
}
|
||||
return openOrder;
|
||||
}
|
||||
|
||||
public List<String> getAllFilename(String creator) {
|
||||
return differenceMapper.getAllFilename(creator);
|
||||
}
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
public void excel(HttpServletResponse response, FinanceDifference difference) throws Exception {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
List<FinanceDifference> differencesList = new ArrayList<FinanceDifference>();
|
||||
SysUser user = (SysUser) SecurityUtils.getSubject().getPrincipal();
|
||||
difference.setCreator(user.getRealname());
|
||||
differencesList = get(difference);
|
||||
|
||||
// 创建excel文件
|
||||
HSSFWorkbook wb = new HSSFWorkbook();
|
||||
// 创建sheet页
|
||||
HSSFSheet sheet = wb.createSheet("总表");
|
||||
String filename = "";
|
||||
// 创建标题行
|
||||
HSSFRow titleRow = sheet.createRow(0);
|
||||
titleRow.createCell(0).setCellValue("订单号");
|
||||
titleRow.createCell(1).setCellValue("店铺");
|
||||
titleRow.createCell(2).setCellValue("旺旺");
|
||||
titleRow.createCell(3).setCellValue("付款时间");
|
||||
titleRow.createCell(4).setCellValue("金额");
|
||||
titleRow.createCell(5).setCellValue("备注");
|
||||
titleRow.createCell(6).setCellValue("淘宝状态");
|
||||
titleRow.createCell(7).setCellValue("拆分订单");
|
||||
titleRow.createCell(8).setCellValue("导入人");
|
||||
titleRow.createCell(9).setCellValue("导入日期");
|
||||
// 遍历将数据放到excel列中
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||
for (FinanceDifference differences : differencesList) {
|
||||
filename = difference.getFilename();
|
||||
HSSFRow dataRow = sheet.createRow(sheet.getLastRowNum() + 1);
|
||||
dataRow.createCell(0).setCellValue(differences.getOrderNumber());
|
||||
dataRow.createCell(1).setCellValue(differences.getShopname());
|
||||
dataRow.createCell(3).setCellValue("");
|
||||
if (differences.getPayTime() != null) {
|
||||
dataRow.createCell(3).setCellValue(formatter.format(differences.getPayTime()));
|
||||
}
|
||||
dataRow.createCell(2).setCellValue(differences.getWangwang());
|
||||
dataRow.createCell(4).setCellValue(differences.getPrice());
|
||||
dataRow.createCell(5).setCellValue(differences.getRemark());
|
||||
dataRow.createCell(6).setCellValue(differences.getTaobaoStatus());
|
||||
dataRow.createCell(7).setCellValue(differences.getOpenOrderNumber());
|
||||
dataRow.createCell(8).setCellValue(differences.getCreator());
|
||||
dataRow.createCell(9).setCellValue(formatter.format(differences.getCreateDate()));
|
||||
}
|
||||
|
||||
// 设置下载时客户端Excel的名称
|
||||
response.setContentType("application/octet-stream;charset=utf-8");
|
||||
response.setHeader("Content-Disposition",
|
||||
"attachment;filename=" + new String(filename.getBytes(), "iso-8859-1"));// + ".xls"
|
||||
|
||||
OutputStream ouputStream = response.getOutputStream();
|
||||
wb.write(ouputStream);
|
||||
ouputStream.flush();
|
||||
ouputStream.close();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,368 @@
|
||||
package lingtao.net.service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.poi.hssf.usermodel.HSSFRow;
|
||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import lingtao.net.bean.FinanceExtract;
|
||||
import lingtao.net.bean.Msg;
|
||||
import lingtao.net.bean.SysUser;
|
||||
import lingtao.net.dao.FinanceExtractMapper;
|
||||
import lingtao.net.util.ExcelUtils;
|
||||
|
||||
@Service
|
||||
public class FinanceExtractService {
|
||||
|
||||
@Autowired
|
||||
private FinanceExtractMapper financeExtractMapper;
|
||||
|
||||
public List<FinanceExtract> getFinanceExtract(FinanceExtract financeExtract) {
|
||||
return financeExtractMapper.getFinanceExtract(financeExtract);
|
||||
}
|
||||
|
||||
public List<String> getFilename_extract(String creator) {
|
||||
return financeExtractMapper.getFilename_extract(creator);
|
||||
}
|
||||
|
||||
public Msg deleteDataByFilename(String filename, String realname) {
|
||||
try {
|
||||
financeExtractMapper.deleteDataByFilename(filename, realname);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
public Msg ajaxUploadExcel(MultipartFile file) throws Exception {
|
||||
if (file.isEmpty()) {
|
||||
throw new Exception("文件不存在!");
|
||||
}
|
||||
SysUser user = (SysUser) SecurityUtils.getSubject().getPrincipal();
|
||||
InputStream in = null;
|
||||
List<List<Object>> listob = null;
|
||||
List<FinanceExtract> list = new ArrayList<FinanceExtract>(1000);
|
||||
try {
|
||||
in = file.getInputStream();
|
||||
listob = new ExcelUtils().getBankListByExcel(in, file.getOriginalFilename());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
String filename = file.getOriginalFilename();
|
||||
System.out.println(filename);
|
||||
for (int i = 0; i < listob.size(); i++) {
|
||||
synchronized (this) {
|
||||
FinanceExtract vo = new FinanceExtract();
|
||||
List<Object> lo = listob.get(i);
|
||||
if (lo.size() == 0 || lo.get(1) == "") {
|
||||
System.out.println("++++++++++++++");
|
||||
continue;
|
||||
}
|
||||
String orderNumber = String.valueOf(lo.get(0)).trim();
|
||||
String remark = String.valueOf(lo.get(1)).trim();
|
||||
if (remark.indexOf("mm") == -1 && remark.indexOf("cm") == -1) {
|
||||
System.out.println(remark);
|
||||
System.out.println("=================");
|
||||
}
|
||||
// 尺寸
|
||||
String size = "#";
|
||||
// 长
|
||||
String length = "#";
|
||||
// 宽
|
||||
String width = "#";
|
||||
// 高
|
||||
String height = "#";
|
||||
// 数量
|
||||
String count = "#";
|
||||
try {
|
||||
// 处理备注
|
||||
String cutSizeStr = remark;
|
||||
String cutCountStr = remark;
|
||||
size = cutSize(cutSizeStr);
|
||||
if (size != "#" || !"#".equals(size)) {
|
||||
if (size.contains("+")) {
|
||||
String[] sizeSplit = size.split("\\+");
|
||||
// System.out.println(Double.valueOf(sizeSplit[0]));
|
||||
// System.out.println(Double.valueOf(sizeSplit[1]));
|
||||
length = sizeSplit[0];
|
||||
width = sizeSplit[1];
|
||||
}
|
||||
}
|
||||
count = cutCount(cutCountStr);
|
||||
orderNumber = remark.substring(remark.indexOf("(") + 1, remark.indexOf(")"));
|
||||
} catch (Exception e) {
|
||||
System.out.println(remark);
|
||||
}
|
||||
vo.setOrderNumber(orderNumber);
|
||||
vo.setFilename(filename);
|
||||
vo.setLength(length);
|
||||
vo.setWidth(width);
|
||||
vo.setHeight(height);
|
||||
vo.setCount(count);
|
||||
vo.setRemark(remark);
|
||||
vo.setCreator(user.getRealname());
|
||||
list.add(vo);
|
||||
}
|
||||
}
|
||||
if (list.size() == 0) {
|
||||
return Msg.fail("上传失败,请检查文件表头是否正确");
|
||||
} else if (list.size() > 0) {
|
||||
financeExtractMapper.insertForeach(list);
|
||||
}
|
||||
in.close();
|
||||
return Msg.success();
|
||||
|
||||
}
|
||||
|
||||
private String cutCount(String remark) {
|
||||
remark = remark.replaceAll(" ", "").replace("x", "X").replace("×", "X").replace("(", "(").replace(")", ")");
|
||||
String countStr = "";
|
||||
String numberStr = "";
|
||||
Integer number;
|
||||
Integer count;
|
||||
int indexM = remark.indexOf("m");
|
||||
int indexZhang = remark.indexOf("张");
|
||||
int indexGe = remark.indexOf("个");
|
||||
int indexTao = remark.indexOf("套");
|
||||
int indexMei = remark.indexOf("枚");
|
||||
// 印艺,尺寸是做好的,直接提取
|
||||
if (remark.contains(".pdf")) {
|
||||
String newRemarkYY = remark.substring(remark.indexOf("-切") + 2);
|
||||
countStr = newRemarkYY.substring(newRemarkYY.indexOf("-") + 1, newRemarkYY.indexOf("Z-"));
|
||||
return countStr;
|
||||
}
|
||||
if (remark.indexOf("张") != -1 && indexZhang - indexM < 15) {
|
||||
if (remark.indexOf("m-") == -1) {
|
||||
countStr = remark.substring(remark.indexOf("m") + 1, remark.indexOf("张"));
|
||||
} else {
|
||||
countStr = remark.substring(remark.indexOf("m-") + 2, remark.indexOf("张"));
|
||||
}
|
||||
} else if (remark.indexOf("个") != -1 && indexGe - indexM < 15) {
|
||||
if (remark.indexOf("m-") == -1) {
|
||||
countStr = remark.substring(remark.indexOf("m") + 1, remark.indexOf("个"));
|
||||
} else {
|
||||
countStr = remark.substring(remark.indexOf("m-") + 2, remark.indexOf("个"));
|
||||
}
|
||||
} else if (remark.indexOf("套") != -1 && indexTao - indexM < 15) {
|
||||
if (remark.indexOf("m-") == -1) {
|
||||
countStr = remark.substring(remark.indexOf("m") + 1, remark.indexOf("套"));
|
||||
} else {
|
||||
countStr = remark.substring(remark.indexOf("m-") + 2, remark.indexOf("套"));
|
||||
}
|
||||
} else if (remark.indexOf("枚") != -1 && indexMei - indexM < 15) {
|
||||
if (remark.indexOf("m-") == -1) {
|
||||
countStr = remark.substring(remark.indexOf("m") + 1, remark.indexOf("枚"));
|
||||
} else {
|
||||
countStr = remark.substring(remark.indexOf("m-") + 2, remark.indexOf("枚"));
|
||||
}
|
||||
}
|
||||
// 第一个“款”的位置
|
||||
int firstK = countStr.indexOf("款");
|
||||
// 第一个“各”的位置
|
||||
int firstGe = countStr.indexOf("各");
|
||||
// 第二个“款”的位置
|
||||
int countStrSecondK = countStr.indexOf("款", firstK + 1);
|
||||
// 第3个“款”的位置
|
||||
int countStrThirdK = countStr.indexOf("款", countStrSecondK + 1);
|
||||
if (countStrSecondK > 0 && countStrThirdK > 0) {
|
||||
return "#";
|
||||
}
|
||||
// “共***张”
|
||||
if (countStr.contains("共")) {
|
||||
String[] split = countStr.split("共");
|
||||
countStr = split[1].replaceAll("[^(0-9)]", "");
|
||||
return "" + countStr;
|
||||
}
|
||||
// “合计***张”
|
||||
if (countStr.contains("合计")) {
|
||||
String[] split = countStr.split("合计");
|
||||
countStr = split[1].replaceAll("[^(0-9)]", "");
|
||||
return "" + countStr;
|
||||
}
|
||||
// “总的***张”
|
||||
if (countStr.contains("总")) {
|
||||
String[] split = countStr.split("总");
|
||||
countStr = split[1].replaceAll("[^(0-9)]", "");
|
||||
return "" + countStr;
|
||||
}
|
||||
// “***款各***张”
|
||||
if (firstGe > 0) {
|
||||
String[] split = countStr.split("各");
|
||||
numberStr = split[0];
|
||||
countStr = split[1];
|
||||
numberStr = numberStr.replaceAll("[^(0-9)]", "");
|
||||
countStr = countStr.replaceAll("[^(0-9)]", "");
|
||||
if (StringUtils.isEmpty(numberStr)) {
|
||||
return "#";
|
||||
}
|
||||
number = Integer.valueOf(numberStr);
|
||||
count = Integer.valueOf(countStr);
|
||||
if (number == 1 || count == 1) {
|
||||
return "" + number * count;
|
||||
}
|
||||
return number + "*" + count;
|
||||
}
|
||||
// **款**张
|
||||
if (firstK > 0) {
|
||||
String[] split = countStr.split("款");
|
||||
numberStr = split[0];
|
||||
countStr = split[1];
|
||||
if (countStrSecondK > 0) {
|
||||
countStr = split[2];
|
||||
}
|
||||
numberStr = numberStr.replaceAll("[^(0-9)]", "");
|
||||
countStr = countStr.replaceAll("[^(0-9)]", "");
|
||||
if (StringUtils.isEmpty(numberStr)) {
|
||||
return "#";
|
||||
}
|
||||
number = Integer.valueOf(numberStr);
|
||||
count = Integer.valueOf(countStr);
|
||||
if (number == 1 || count == 1) {
|
||||
return "" + number * count;
|
||||
}
|
||||
return number + "*" + count;
|
||||
}
|
||||
countStr = countStr.replaceAll("[^(0-9)]", "");
|
||||
return countStr;
|
||||
}
|
||||
|
||||
private String cutSize(String remark) {
|
||||
remark = remark.replaceAll(" ", "").replace("x", "X").replace("×", "X").replace("(", "(").replace(")", ")")
|
||||
.replace("专版打印", "").replace("下", "").replace("上", "").replace("专版", "").replace("多拍返10元", "");
|
||||
// 第一个X的位置
|
||||
int firstX = remark.indexOf("X");
|
||||
// 第二个X的位置
|
||||
int secondX = remark.indexOf("X", firstX + 1);
|
||||
int secondmm = remark.indexOf("mm", remark.indexOf("mm") + 1);
|
||||
if (secondX > 0 && secondmm > 0) {
|
||||
return "#";
|
||||
}
|
||||
// System.out.println(remark);
|
||||
String size = "";
|
||||
double length;
|
||||
double width;
|
||||
String regex = "([1-9]\\d*\\.?\\d+)|(0\\.\\d*[1-9])|(\\d+)";
|
||||
// 没有mm && 有cm
|
||||
if (remark.indexOf("mm") == -1 && remark.indexOf("cm") != -1) {
|
||||
String l = remark.substring(remark.indexOf("X") - 3, remark.indexOf("X"));
|
||||
String w = remark.substring(remark.indexOf("X") + 1, remark.indexOf("cm"));
|
||||
// 如果l里有小数点,往前数5位
|
||||
if (l.indexOf(".") != -1) {
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
l = remark.substring(remark.indexOf("X") - 5, remark.indexOf("X"));
|
||||
Matcher matcher = pattern.matcher(l);
|
||||
while (matcher.find()) {
|
||||
l = matcher.group();
|
||||
}
|
||||
} else {
|
||||
l = l.replaceAll("[^(0-9)]", "");
|
||||
}
|
||||
size = l + "X" + w;
|
||||
String[] split = size.split("X");
|
||||
length = Double.valueOf(split[0]) * 10;
|
||||
if ("按比例".equals(split[1])) {
|
||||
width = Double.valueOf(split[0]) * 10;
|
||||
} else {
|
||||
width = Double.valueOf(split[1]) * 10;
|
||||
}
|
||||
size = length + "+" + width;
|
||||
} else {
|
||||
// 印艺,没有毫米
|
||||
if (remark.contains(".pdf")) {
|
||||
String newRemarkYY = remark.substring(remark.indexOf("-切") + 2);
|
||||
System.out.println(newRemarkYY);
|
||||
size = newRemarkYY.substring(0, newRemarkYY.indexOf("-"));
|
||||
} else {
|
||||
// 有毫米
|
||||
String l = remark.substring(remark.indexOf("X") - 3, remark.indexOf("X"));
|
||||
String w = remark.substring(remark.indexOf("X") + 1, remark.indexOf("mm"));
|
||||
// 如果l里有小数点,往前数5位
|
||||
if (l.indexOf(".") != -1) {
|
||||
l = remark.substring(remark.indexOf("X") - 5, remark.indexOf("X"));
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(l);
|
||||
while (matcher.find()) {
|
||||
l = matcher.group();
|
||||
}
|
||||
} else {
|
||||
l = l.replaceAll("[^(0-9)]", "");
|
||||
}
|
||||
size = l + "X" + w;
|
||||
}
|
||||
String[] split = size.split("X");
|
||||
length = Double.valueOf(split[0]);
|
||||
if ("按比例".equals(split[1])) {
|
||||
width = Double.valueOf(split[0]);
|
||||
} else {
|
||||
width = Double.valueOf(split[1]);
|
||||
}
|
||||
size = length + "+" + width;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
public void excel(HttpServletResponse response, FinanceExtract financeExtract) throws Exception {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
List<FinanceExtract> financeExtractsList = new ArrayList<FinanceExtract>();
|
||||
SysUser user = (SysUser) SecurityUtils.getSubject().getPrincipal();
|
||||
financeExtract.setCreator(user.getRealname());
|
||||
financeExtractsList = getFinanceExtract(financeExtract);
|
||||
|
||||
// 创建excel文件
|
||||
HSSFWorkbook wb = new HSSFWorkbook();
|
||||
// 创建sheet页
|
||||
HSSFSheet sheet = wb.createSheet("总表");
|
||||
String filename = "";
|
||||
// 创建标题行
|
||||
HSSFRow titleRow = sheet.createRow(0);
|
||||
titleRow.createCell(0).setCellValue("订单号");
|
||||
titleRow.createCell(1).setCellValue("文件名");
|
||||
titleRow.createCell(2).setCellValue("长");
|
||||
titleRow.createCell(3).setCellValue("宽");
|
||||
titleRow.createCell(4).setCellValue("高");
|
||||
titleRow.createCell(5).setCellValue("数量");
|
||||
titleRow.createCell(6).setCellValue("导入人");
|
||||
titleRow.createCell(7).setCellValue("导入日期");
|
||||
// 遍历将数据放到excel列中
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||
for (FinanceExtract financeExtracts : financeExtractsList) {
|
||||
filename = financeExtract.getFilename();
|
||||
HSSFRow dataRow = sheet.createRow(sheet.getLastRowNum() + 1);
|
||||
dataRow.createCell(0).setCellValue(financeExtracts.getOrderNumber());
|
||||
dataRow.createCell(1).setCellValue(financeExtracts.getRemark());
|
||||
dataRow.createCell(2).setCellValue(financeExtracts.getLength());
|
||||
dataRow.createCell(3).setCellValue(financeExtracts.getWidth());
|
||||
dataRow.createCell(4).setCellValue(financeExtracts.getHeight());
|
||||
dataRow.createCell(5).setCellValue(financeExtracts.getCount());
|
||||
dataRow.createCell(6).setCellValue(financeExtracts.getCreator());
|
||||
dataRow.createCell(7).setCellValue(formatter.format(financeExtracts.getCreateDate()));
|
||||
}
|
||||
|
||||
// 设置下载时客户端Excel的名称
|
||||
response.setContentType("application/octet-stream;charset=utf-8");
|
||||
response.setHeader("Content-Disposition",
|
||||
"attachment;filename=" + new String(filename.getBytes(), "iso-8859-1"));// + ".xls"
|
||||
|
||||
OutputStream ouputStream = response.getOutputStream();
|
||||
wb.write(ouputStream);
|
||||
ouputStream.flush();
|
||||
ouputStream.close();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,401 @@
|
||||
package lingtao.net.service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
|
||||
import org.apache.poi.hssf.usermodel.HSSFRow;
|
||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import lingtao.net.bean.Finance;
|
||||
import lingtao.net.bean.Msg;
|
||||
import lingtao.net.bean.SysUser;
|
||||
import lingtao.net.dao.FinanceMapper;
|
||||
import lingtao.net.util.ExcelUtils;
|
||||
|
||||
@Service
|
||||
public class FinanceService {
|
||||
|
||||
@Autowired
|
||||
private FinanceMapper financeMapper;
|
||||
|
||||
public List<Finance> getFinance(Finance finance) {
|
||||
return financeMapper.getFinance(finance);
|
||||
}
|
||||
|
||||
public List<String> getAllFilename(String creator) {
|
||||
return financeMapper.getAllFilename(creator);
|
||||
}
|
||||
|
||||
public Msg deleteDataByFilename(String filename, String realname) {
|
||||
try {
|
||||
financeMapper.deleteDataByFilename(filename, realname);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
public Msg ajaxUploadExcel(MultipartFile file) throws Exception {
|
||||
if (file.isEmpty()) {
|
||||
throw new Exception("文件不存在!");
|
||||
}
|
||||
SysUser user = (SysUser) SecurityUtils.getSubject().getPrincipal();
|
||||
InputStream in = null;
|
||||
List<List<Object>> listob = null;
|
||||
List<Finance> list = new ArrayList<Finance>(1000);
|
||||
try {
|
||||
in = file.getInputStream();
|
||||
listob = new ExcelUtils().getBankListByExcel(in, file.getOriginalFilename());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
String filename = file.getOriginalFilename();
|
||||
System.out.println(filename);
|
||||
for (int i = 0; i < listob.size(); i++) {
|
||||
synchronized (this) {
|
||||
Finance vo = new Finance();
|
||||
List<Object> lo = listob.get(i);
|
||||
if (lo.size() == 0 || lo.size() == 1 || lo.get(6) == "") {
|
||||
System.out.println("++++++++++++++");
|
||||
continue;
|
||||
}
|
||||
String addTime = String.valueOf(lo.get(0)).trim();
|
||||
String supplier = String.valueOf(lo.get(1)).trim();
|
||||
String shopname = String.valueOf(lo.get(2)).trim();
|
||||
String kind = String.valueOf(lo.get(3)).trim();
|
||||
String kind2 = String.valueOf(lo.get(4)).trim();
|
||||
String orderNumber = String.valueOf(lo.get(5)).trim();
|
||||
String remark = String.valueOf(lo.get(6)).trim();
|
||||
remark = remark.replace("MM", "mm").replace("CM", "mm");
|
||||
if (remark.indexOf("mm") == -1 && remark.indexOf("cm") == -1) {
|
||||
System.out.println(remark);
|
||||
System.out.println("=================");
|
||||
}
|
||||
// 判断数据是否已经存在
|
||||
|
||||
/*
|
||||
* String checkAccountNumber = financeMapper.checkAccountNumber(orderNumber); if
|
||||
* (StringUtils.isNotEmpty(checkAccountNumber)) { continue; }
|
||||
*/
|
||||
|
||||
// 数量
|
||||
String count = "#";
|
||||
// 拼版数
|
||||
String number = "#";
|
||||
// 所需张数
|
||||
double zhang = 0;
|
||||
try {
|
||||
// 处理备注
|
||||
String cutSizeStr = remark;
|
||||
String cutCountStr = remark;
|
||||
number = cutSize(cutSizeStr);
|
||||
count = cutCount(cutCountStr);
|
||||
if (count != "#" && number != "#") {
|
||||
if (count.contains("*")) {
|
||||
String[] countSplit = count.split("\\*");
|
||||
System.out.println(Double.valueOf(countSplit[0]));
|
||||
System.out.println(Double.valueOf(countSplit[1]));
|
||||
zhang = Math.ceil(Double.valueOf(countSplit[0]) * Double.valueOf(countSplit[1])
|
||||
/ Double.valueOf(number));
|
||||
} else {
|
||||
zhang = Math.ceil(Double.valueOf(count) / Double.valueOf(number));
|
||||
}
|
||||
}
|
||||
orderNumber = remark.substring(remark.indexOf("(") + 1, remark.indexOf(")"));
|
||||
} catch (Exception e) {
|
||||
System.out.println(remark);
|
||||
// return Msg.fail(remark);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(addTime)) {
|
||||
Date javaDate = HSSFDateUtil.getJavaDate(Double.parseDouble(addTime));
|
||||
vo.setAddTime(javaDate);
|
||||
}
|
||||
// SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||
// Date add_date = formatter.parse(addTime);// 把字符串转为日期格式
|
||||
vo.setSupplier(supplier);
|
||||
vo.setShopname(shopname);
|
||||
vo.setKind(kind);
|
||||
vo.setKind2(kind2);
|
||||
vo.setOrderNumber(orderNumber);
|
||||
vo.setFilename(filename);
|
||||
vo.setCount(count);
|
||||
vo.setNumber(number);
|
||||
vo.setZhang(String.valueOf(zhang));
|
||||
vo.setRemark(remark);
|
||||
vo.setCreator(user.getRealname());
|
||||
list.add(vo);
|
||||
// financeMapper.insertSelective(vo);
|
||||
}
|
||||
}
|
||||
if (list.size() == 0) {
|
||||
return Msg.fail("上传失败,请检查文件表头是否正确");
|
||||
} else if (list.size() > 0) {
|
||||
financeMapper.insertForeach(list);
|
||||
}
|
||||
in.close();
|
||||
return Msg.success();
|
||||
|
||||
}
|
||||
|
||||
private String cutCount(String remark) {
|
||||
remark = remark.replaceAll(" ", "").replace("x", "X").replace("×", "X").replace("(", "(").replace(")", ")");
|
||||
String countStr = "";
|
||||
String numberStr = "";
|
||||
Integer number;
|
||||
Integer count;
|
||||
int indexM = remark.indexOf("m");
|
||||
int indexZhang = remark.indexOf("张");
|
||||
int indexGe = remark.indexOf("个");
|
||||
int indexTao = remark.indexOf("套");
|
||||
int indexMei = remark.indexOf("枚");
|
||||
if (remark.indexOf("张") != -1 && indexZhang - indexM < 15) {
|
||||
if (remark.indexOf("m-") == -1) {
|
||||
countStr = remark.substring(remark.indexOf("m") + 1, remark.indexOf("张"));
|
||||
} else {
|
||||
countStr = remark.substring(remark.indexOf("m-") + 2, remark.indexOf("张"));
|
||||
}
|
||||
} else if (remark.indexOf("个") != -1 && indexGe - indexM < 15) {
|
||||
if (remark.indexOf("m-") == -1) {
|
||||
countStr = remark.substring(remark.indexOf("m") + 1, remark.indexOf("个"));
|
||||
} else {
|
||||
countStr = remark.substring(remark.indexOf("m-") + 2, remark.indexOf("个"));
|
||||
}
|
||||
} else if (remark.indexOf("套") != -1 && indexTao - indexM < 15) {
|
||||
if (remark.indexOf("m-") == -1) {
|
||||
countStr = remark.substring(remark.indexOf("m") + 1, remark.indexOf("套"));
|
||||
} else {
|
||||
countStr = remark.substring(remark.indexOf("m-") + 2, remark.indexOf("套"));
|
||||
}
|
||||
} else if (remark.indexOf("枚") != -1 && indexMei - indexM < 15) {
|
||||
if (remark.indexOf("m-") == -1) {
|
||||
countStr = remark.substring(remark.indexOf("m") + 1, remark.indexOf("枚"));
|
||||
} else {
|
||||
countStr = remark.substring(remark.indexOf("m-") + 2, remark.indexOf("枚"));
|
||||
}
|
||||
}
|
||||
// 第一个“款”的位置
|
||||
int firstK = countStr.indexOf("款");
|
||||
// 第一个“各”的位置
|
||||
int firstGe = countStr.indexOf("各");
|
||||
// 第二个“款”的位置
|
||||
int countStrSecondK = countStr.indexOf("款", firstK + 1);
|
||||
// 第3个“款”的位置
|
||||
int countStrThirdK = countStr.indexOf("款", countStrSecondK + 1);
|
||||
if (countStrSecondK > 0 && countStrThirdK > 0) {
|
||||
return "#";
|
||||
}
|
||||
// “共***张”
|
||||
if (countStr.contains("共")) {
|
||||
String[] split = countStr.split("共");
|
||||
countStr = split[1].replaceAll("[^(0-9)]", "");
|
||||
return "" + countStr;
|
||||
}
|
||||
// “合计***张”
|
||||
if (countStr.contains("合计")) {
|
||||
String[] split = countStr.split("合计");
|
||||
countStr = split[1].replaceAll("[^(0-9)]", "");
|
||||
return "" + countStr;
|
||||
}
|
||||
// “总的***张”
|
||||
if (countStr.contains("总")) {
|
||||
String[] split = countStr.split("总");
|
||||
countStr = split[1].replaceAll("[^(0-9)]", "");
|
||||
return "" + countStr;
|
||||
}
|
||||
// “***款各***张”
|
||||
if (firstGe > 0) {
|
||||
String[] split = countStr.split("各");
|
||||
numberStr = split[0];
|
||||
countStr = split[1];
|
||||
numberStr = numberStr.replaceAll("[^(0-9)]", "");
|
||||
countStr = countStr.replaceAll("[^(0-9)]", "");
|
||||
if (StringUtils.isEmpty(numberStr)) {
|
||||
return "#";
|
||||
}
|
||||
number = Integer.valueOf(numberStr);
|
||||
count = Integer.valueOf(countStr);
|
||||
if (number == 1 || count == 1) {
|
||||
return "" + number * count;
|
||||
}
|
||||
return number + "*" + count;
|
||||
}
|
||||
// **款**张
|
||||
if (firstK > 0) {
|
||||
String[] split = countStr.split("款");
|
||||
numberStr = split[0];
|
||||
countStr = split[1];
|
||||
if (countStrSecondK > 0) {
|
||||
countStr = split[2];
|
||||
}
|
||||
numberStr = numberStr.replaceAll("[^(0-9)]", "");
|
||||
countStr = countStr.replaceAll("[^(0-9)]", "");
|
||||
if (StringUtils.isEmpty(numberStr)) {
|
||||
return "#";
|
||||
}
|
||||
number = Integer.valueOf(numberStr);
|
||||
count = Integer.valueOf(countStr);
|
||||
if (number == 1 || count == 1) {
|
||||
return "" + number * count;
|
||||
}
|
||||
return number + "*" + count;
|
||||
}
|
||||
countStr = countStr.replaceAll("[^(0-9)]", "");
|
||||
return countStr;
|
||||
}
|
||||
|
||||
private String cutSize(String remark) {
|
||||
remark = remark.replaceAll(" ", "").replace("x", "X").replace("×", "X").replace("(", "(").replace(")", ")")
|
||||
.replace("专版打印", "").replace("下", "").replace("上", "").replace("专版", "").replace("-", "")
|
||||
.replace("多拍返10元", "");
|
||||
// 第一个X的位置
|
||||
int firstX = remark.indexOf("X");
|
||||
// 第二个X的位置
|
||||
int secondX = remark.indexOf("X", firstX + 1);
|
||||
int secondmm = remark.indexOf("mm", remark.indexOf("mm") + 1);
|
||||
if (secondX > 0 && secondmm > 0) {
|
||||
return "#";
|
||||
}
|
||||
// System.out.println(remark);
|
||||
String size = "";
|
||||
double length;
|
||||
double width;
|
||||
// 提取整数/小数的正则
|
||||
String regex = "([1-9]\\d*\\.?\\d+)|(0\\.\\d*[1-9])|(\\d+)";
|
||||
if (remark.indexOf("mm") == -1 && remark.indexOf("cm") != -1) {
|
||||
String l = remark.substring(remark.indexOf("X") - 3, remark.indexOf("X"));
|
||||
String w = remark.substring(remark.indexOf("X") + 1, remark.indexOf("cm"));
|
||||
// 如果l里有小数点,往前数5位
|
||||
if (l.indexOf(".") != -1) {
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
l = remark.substring(remark.indexOf("X") - 5, remark.indexOf("X"));
|
||||
Matcher matcher = pattern.matcher(l);
|
||||
while (matcher.find()) {
|
||||
l = matcher.group();
|
||||
}
|
||||
} else {
|
||||
l = l.replaceAll("[^(0-9)]", "");
|
||||
}
|
||||
size = l + "X" + w;
|
||||
String[] split = size.split("X");
|
||||
length = Double.valueOf(split[0]) * 10 + 4;
|
||||
if ("按比例".equals(split[1])) {
|
||||
width = Double.valueOf(split[0]) * 10 + 4;
|
||||
} else {
|
||||
width = Double.valueOf(split[1]) * 10 + 4;
|
||||
}
|
||||
} else {
|
||||
String l = remark.substring(remark.indexOf("X") - 3, remark.indexOf("X"));
|
||||
String w = remark.substring(remark.indexOf("X") + 1, remark.indexOf("mm"));
|
||||
// 如果l里有小数点,往前数5位
|
||||
if (l.indexOf(".") != -1) {
|
||||
if (l.indexOf(".") != -1) {
|
||||
l = remark.substring(remark.indexOf("X") - 5, remark.indexOf("X"));
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(l);
|
||||
while (matcher.find()) {
|
||||
l = matcher.group();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
l = l.replaceAll("[^(0-9)]", "");
|
||||
}
|
||||
size = l + "X" + w;
|
||||
String[] split = size.split("X");
|
||||
length = Double.valueOf(split[0]) + 4;
|
||||
if ("按比例".equals(split[1])) {
|
||||
width = Double.valueOf(split[0]) + 4;
|
||||
} else {
|
||||
width = Double.valueOf(split[1]) + 4;
|
||||
}
|
||||
}
|
||||
|
||||
double l = 420;
|
||||
double w = 280;
|
||||
if (length == l + 4) {
|
||||
return "1";
|
||||
}
|
||||
if ((length > l || width > w) && (length > w || width > l))
|
||||
return "#";
|
||||
// 一张纸 420*290 能做多少个此类尺寸的产品
|
||||
double max = Math.max(Math.floor(l / length) * Math.floor(w / width),
|
||||
Math.floor(l / width) * Math.floor(w / length));
|
||||
return String.valueOf(max);
|
||||
}
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
public void excel(HttpServletResponse response, Finance finance) throws Exception {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
List<Finance> financesList = new ArrayList<Finance>();
|
||||
SysUser user = (SysUser) SecurityUtils.getSubject().getPrincipal();
|
||||
finance.setCreator(user.getRealname());
|
||||
financesList = getFinance(finance);
|
||||
|
||||
// 创建excel文件
|
||||
HSSFWorkbook wb = new HSSFWorkbook();
|
||||
// 创建sheet页
|
||||
HSSFSheet sheet = wb.createSheet("总表");
|
||||
String filename = "";
|
||||
// 创建标题行
|
||||
HSSFRow titleRow = sheet.createRow(0);
|
||||
titleRow.createCell(0).setCellValue("日期");
|
||||
titleRow.createCell(1).setCellValue("供应商");
|
||||
titleRow.createCell(2).setCellValue("店铺");
|
||||
titleRow.createCell(3).setCellValue("大类别");
|
||||
titleRow.createCell(4).setCellValue("小类别");
|
||||
titleRow.createCell(5).setCellValue("订单号");
|
||||
titleRow.createCell(6).setCellValue("文件名");
|
||||
titleRow.createCell(7).setCellValue("数量");
|
||||
titleRow.createCell(8).setCellValue("拼版数");
|
||||
titleRow.createCell(9).setCellValue("张数");
|
||||
titleRow.createCell(10).setCellValue("导入人");
|
||||
titleRow.createCell(11).setCellValue("导入日期");
|
||||
// 遍历将数据放到excel列中
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||
for (Finance finances : financesList) {
|
||||
filename = finance.getFilename();
|
||||
HSSFRow dataRow = sheet.createRow(sheet.getLastRowNum() + 1);
|
||||
dataRow.createCell(0).setCellValue("");
|
||||
if (finances.getAddTime() != null) {
|
||||
dataRow.createCell(0).setCellValue(formatter.format(finances.getAddTime()));
|
||||
}
|
||||
dataRow.createCell(1).setCellValue(finances.getSupplier());
|
||||
dataRow.createCell(2).setCellValue(finances.getShopname());
|
||||
dataRow.createCell(3).setCellValue(finances.getKind());
|
||||
dataRow.createCell(4).setCellValue(finances.getKind2());
|
||||
dataRow.createCell(5).setCellValue(finances.getOrderNumber());
|
||||
dataRow.createCell(6).setCellValue(finances.getRemark());
|
||||
dataRow.createCell(7).setCellValue(finances.getCount());
|
||||
dataRow.createCell(8).setCellValue(finances.getNumber());
|
||||
dataRow.createCell(9).setCellValue(finances.getZhang());
|
||||
dataRow.createCell(10).setCellValue(finances.getCreator());
|
||||
dataRow.createCell(11).setCellValue(formatter.format(finances.getCreateDate()));
|
||||
}
|
||||
|
||||
// 设置下载时客户端Excel的名称
|
||||
response.setContentType("application/octet-stream;charset=utf-8");
|
||||
response.setHeader("Content-Disposition",
|
||||
"attachment;filename=" + new String(filename.getBytes(), "iso-8859-1"));// + ".xls"
|
||||
|
||||
OutputStream ouputStream = response.getOutputStream();
|
||||
wb.write(ouputStream);
|
||||
ouputStream.flush();
|
||||
ouputStream.close();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package lingtao.net.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import lingtao.net.bean.Information;
|
||||
import lingtao.net.bean.Msg;
|
||||
import lingtao.net.bean.SysUser;
|
||||
import lingtao.net.dao.InformationMapper;
|
||||
|
||||
@Service
|
||||
public class InformationService {
|
||||
|
||||
@Autowired
|
||||
private InformationMapper informationMapper;
|
||||
|
||||
public List<Information> getInformations(Information information) {
|
||||
return informationMapper.getInformations(information);
|
||||
}
|
||||
|
||||
public Msg addInformation(Information information, HttpSession session) {
|
||||
SysUser user = (SysUser) session.getAttribute("USER_SESSION");
|
||||
information.setCreateBy(user.getRealname());
|
||||
try {
|
||||
informationMapper.addInformation(information);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
public Msg updateInformationById(Information information, HttpSession session) {
|
||||
SysUser user = (SysUser) session.getAttribute("USER_SESSION");
|
||||
information.setUpdateBy(user.getRealname());
|
||||
try {
|
||||
informationMapper.updateInformationById(information);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Msg deleteInformationById(Integer id) {
|
||||
try {
|
||||
informationMapper.deleteInformationById(id);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public List<Information> getShortAnswers() {
|
||||
return informationMapper.getShortAnswers();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package lingtao.net.service;
|
||||
|
||||
public class InitComponent {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package lingtao.net.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import lingtao.net.bean.LoginIp;
|
||||
import lingtao.net.bean.Msg;
|
||||
import lingtao.net.bean.SysUser;
|
||||
import lingtao.net.dao.LoginIpMapper;
|
||||
|
||||
@Service
|
||||
public class LoginIpService {
|
||||
|
||||
@Autowired
|
||||
private LoginIpMapper loginIpMapper;
|
||||
|
||||
// 列表
|
||||
public List<LoginIp> getLoginIpList(LoginIp loginIp) {
|
||||
return loginIpMapper.getLoginIpList(loginIp);
|
||||
}
|
||||
|
||||
// 新增
|
||||
public void addIp(LoginIp loginIp) {
|
||||
SysUser user = (SysUser) SecurityUtils.getSubject().getPrincipal();
|
||||
loginIp.setCreateBy(user.getRealname());
|
||||
loginIpMapper.addIp(loginIp);
|
||||
}
|
||||
|
||||
// 修改
|
||||
public void updateIp(LoginIp loginIp) {
|
||||
SysUser user = (SysUser) SecurityUtils.getSubject().getPrincipal();
|
||||
loginIp.setUpdateBy(user.getRealname());
|
||||
loginIpMapper.updateIp(loginIp);
|
||||
}
|
||||
|
||||
// 删除
|
||||
public int deleteIpById(Integer id) {
|
||||
return loginIpMapper.deleteIpById(id);
|
||||
}
|
||||
|
||||
// 批量删除
|
||||
public Msg deleteBatch(int[] ints) {
|
||||
try {
|
||||
loginIpMapper.deleteBatch(ints);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
public Msg checkIP(String agreeIp) {
|
||||
LoginIp loginIp = loginIpMapper.checkIP(agreeIp);
|
||||
if (loginIp != null) {
|
||||
return Msg.fail();
|
||||
}
|
||||
return Msg.success();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package lingtao.net.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import lingtao.net.bean.LoginLog;
|
||||
import lingtao.net.dao.LoginLogMapper;
|
||||
|
||||
@Service
|
||||
public class LoginLogService {
|
||||
|
||||
@Autowired
|
||||
private LoginLogMapper loginLogMapper;
|
||||
|
||||
public List<LoginLog> getLoginLogList(LoginLog loginLog) {
|
||||
return loginLogMapper.getLoginLogList(loginLog);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package lingtao.net.service;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import lingtao.net.bean.Msg;
|
||||
import lingtao.net.bean.MyFile;
|
||||
import lingtao.net.bean.MyFileExample;
|
||||
import lingtao.net.bean.MyFileExample.Criteria;
|
||||
import lingtao.net.dao.MyFileMapper;
|
||||
|
||||
@Service
|
||||
public class MyFileService {
|
||||
|
||||
@Autowired
|
||||
MyFileMapper fileMapper;
|
||||
|
||||
// 文件上传
|
||||
public Msg fileUpload(MultipartFile file, HttpServletRequest request) {
|
||||
try {
|
||||
// 获取存放路径
|
||||
String path = request.getSession().getServletContext().getRealPath("/deptFile");
|
||||
// 判断路径是否存在
|
||||
File upfile = new File(path);
|
||||
if (!upfile.exists()) {
|
||||
upfile.mkdirs();
|
||||
}
|
||||
// 获得文件名
|
||||
String filename = file.getOriginalFilename();
|
||||
upfile = new File(path + "/" + filename);
|
||||
MyFile myFile = new MyFile();
|
||||
// 将文件移动到指定路径中
|
||||
file.transferTo(upfile);
|
||||
myFile.setFileName(filename);
|
||||
myFile.setFilePath(path);
|
||||
myFile.setCreateBy("admin");
|
||||
fileMapper.insertSelective(myFile);
|
||||
return Msg.success();
|
||||
} catch (IOException e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
// 获取所有的文件信息
|
||||
public List<MyFile> getFileList(MyFile myFile, HttpSession session) {
|
||||
return fileMapper.getFileList(myFile);
|
||||
}
|
||||
|
||||
// 根据ID删除文件
|
||||
public Msg deleteFile(Integer fileId) {
|
||||
try {
|
||||
fileMapper.deleteByPrimaryKey(fileId);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail("删除失败");
|
||||
}
|
||||
}
|
||||
|
||||
// 批量删除文件
|
||||
public Msg deleteBatch(List<Integer> del_ids) {
|
||||
MyFileExample example = new MyFileExample();
|
||||
Criteria criteria = example.createCriteria();
|
||||
criteria.andFileIdIn(del_ids);
|
||||
try {
|
||||
fileMapper.deleteByExample(example);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
// 同时删除服务器中的文件
|
||||
public boolean deleteFile(String delFileName) {
|
||||
boolean flag = false;
|
||||
File file = new File(delFileName);
|
||||
// 判断目录或文件是否存在
|
||||
if (!file.exists()) { // 不存在返回 false
|
||||
return flag;
|
||||
} else {
|
||||
flag = true;
|
||||
file.delete();
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package lingtao.net.service;
|
||||
|
||||
import lingtao.net.bean.ProductImg;
|
||||
import lingtao.net.bean.SysDictProduct;
|
||||
import lingtao.net.dao.ProductImgMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class ProductImgService {
|
||||
|
||||
@Autowired
|
||||
private ProductImgMapper productImgMapper;
|
||||
|
||||
public List<ProductImg> getProKindList(ProductImg productImg) {
|
||||
return productImgMapper.getProKindList(productImg);
|
||||
}
|
||||
|
||||
public SysDictProduct getLabel(ProductImg productImg) {
|
||||
return productImgMapper.getLabel(productImg);
|
||||
}
|
||||
|
||||
public int addImgUrl(ProductImg productImg) {
|
||||
return productImgMapper.addImgUrl(productImg);
|
||||
}
|
||||
|
||||
public int updateImgUploadRemark(ProductImg productImg) {
|
||||
return productImgMapper.updateImgUploadRemark(productImg);
|
||||
}
|
||||
|
||||
public List<SysDictProduct> findAllPro() {
|
||||
return productImgMapper.findAllPro();
|
||||
}
|
||||
|
||||
public List<SysDictProduct> getKindsByPro(String proTypeValue) {
|
||||
return productImgMapper.getKindsByPro(proTypeValue);
|
||||
}
|
||||
|
||||
public List<SysDictProduct> getKind2sByKind(String proTypeValue, String kindValue) {
|
||||
return productImgMapper.getKind2sByKind(proTypeValue, kindValue);
|
||||
}
|
||||
|
||||
public List<ProductImg> getImgsByProKind(String proTypeValue, String kindValue, String kind2Value, String craftValue) {
|
||||
return productImgMapper.getImgsByProKind(proTypeValue, kindValue, kind2Value, craftValue);
|
||||
}
|
||||
|
||||
public List<String> getVideos() {
|
||||
return productImgMapper.getVideos();
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,68 @@
|
||||
package lingtao.net.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import lingtao.net.bean.Msg;
|
||||
import lingtao.net.bean.Question;
|
||||
import lingtao.net.bean.SysUser;
|
||||
import lingtao.net.dao.QuestionMapper;
|
||||
|
||||
@Service
|
||||
public class QuestionService {
|
||||
|
||||
@Autowired
|
||||
private QuestionMapper questionMapper;
|
||||
|
||||
public List<Question> questions(Question question) {
|
||||
return questionMapper.questions(question);
|
||||
}
|
||||
|
||||
public Msg addQuestion(Question question, HttpSession session) {
|
||||
SysUser user = (SysUser) session.getAttribute("USER_SESSION");
|
||||
question.setCreateBy(user.getRealname());
|
||||
try {
|
||||
questionMapper.addQuestion(question);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
// 修改
|
||||
public Msg updateQuestionById(Question question, HttpSession session) {
|
||||
SysUser user = (SysUser) session.getAttribute("USER_SESSION");
|
||||
question.setUpdateBy(user.getRealname());
|
||||
try {
|
||||
questionMapper.updateQuestionById(question);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
public Msg deleteQuestionById(Integer id) {
|
||||
try {
|
||||
questionMapper.deleteQuestionById(id);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
public List<Question> getSingleQuestions() {
|
||||
return questionMapper.getSingleQuestions();
|
||||
}
|
||||
|
||||
public List<Question> getMultipleQuestions() {
|
||||
return questionMapper.getMultipleQuestions();
|
||||
}
|
||||
|
||||
public List<Question> getFillQuestions() {
|
||||
return questionMapper.getFillQuestions();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,535 @@
|
||||
package lingtao.net.service;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.lang.reflect.Field;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.poi.xssf.usermodel.XSSFRow;
|
||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import lingtao.net.bean.Msg;
|
||||
import lingtao.net.bean.QuoteData;
|
||||
import lingtao.net.bean.SysRole;
|
||||
import lingtao.net.bean.SysUser;
|
||||
import lingtao.net.controller.CustomerDataControlle;
|
||||
import lingtao.net.dao.QuoteDataMapper;
|
||||
import lingtao.net.dao.SysRoleMapper;
|
||||
import lingtao.net.util.DateFormatUtils;
|
||||
|
||||
@Service
|
||||
public class QuoteDataService {
|
||||
|
||||
@Autowired
|
||||
private QuoteDataMapper quoteDataMapper;
|
||||
|
||||
@Autowired
|
||||
private SysRoleMapper roleMapper;
|
||||
|
||||
@Autowired
|
||||
private SysRoleMapper sysRolemapper;
|
||||
|
||||
/**
|
||||
* 根据角色身份查询数据列表
|
||||
*/
|
||||
public List<QuoteData> quoteDatas(QuoteData quoteData) {
|
||||
quoteData.setQuoteTimeEnd(new DateFormatUtils().formatEndTime(quoteData.getQuoteTimeBegin()));
|
||||
quoteData.setQuoteTimeBegin(new DateFormatUtils().formatBeginTime(quoteData.getQuoteTimeBegin()));
|
||||
// 用户所拥有的角色
|
||||
SysUser user = (SysUser) SecurityUtils.getSubject().getPrincipal();
|
||||
String[] roleArr = user.getRole().split(",");
|
||||
// 转成list,拿掉‘组长’身份
|
||||
List<String> list = new ArrayList<String>(Arrays.asList(roleArr));
|
||||
// 判断是否拥有超管身份标识
|
||||
boolean isSuper = false;
|
||||
boolean isAllShop = false;
|
||||
for (int i = 0; i < roleArr.length; i++) {
|
||||
// 有【超级管理员】身份,状态改为true
|
||||
if ("1".equals(roleArr[i])) {
|
||||
isSuper = true;
|
||||
break;
|
||||
}
|
||||
// 有【全部店铺】身份,状态改为true
|
||||
if ("777".equals(roleArr[i])) {
|
||||
isAllShop = true;
|
||||
break;
|
||||
}
|
||||
// 如果有【店长/考试审核员/客服/组长/IP管理员/操作日志/不填旺旺】身份,去掉。不带去查询
|
||||
if ("666".equals(roleArr[i]) || "888".equals(roleArr[i]) || "999".equals(roleArr[i])
|
||||
|| "1011".equals(roleArr[i]) || "1015".equals(roleArr[i]) || "1042".equals(roleArr[i])
|
||||
|| "1049".equals(roleArr[i])) {
|
||||
list.remove(roleArr[i]);
|
||||
}
|
||||
}
|
||||
// 将list转为String[] 数组
|
||||
roleArr = list.toArray(new String[list.size()]);
|
||||
// 如果没有【超级管理员/全部店铺】身份
|
||||
if (!isSuper && !isAllShop) {
|
||||
// 再判断有没有查询条件且没有选择查找条件
|
||||
// 全部属性为空 true:没有查询条件 false:有查询条件
|
||||
boolean isNullFlag = true;
|
||||
try {
|
||||
// 前台会带用户的角色回来,上面已经获取,这里设置null不影响
|
||||
quoteData.setRole(null);
|
||||
// 判断quoteData对象是否有属性(查询条件)
|
||||
for (Field f : quoteData.getClass().getDeclaredFields()) {
|
||||
f.setAccessible(true);
|
||||
if (f.get(quoteData) != null && StringUtils.isNotBlank(f.get(quoteData).toString())) {
|
||||
// 有属性
|
||||
isNullFlag = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (IllegalArgumentException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// 如果有多个店铺角色
|
||||
if (roleArr.length > 1) {
|
||||
// 全部属性为空 即没有条件查询,默认查出所有的店铺数据
|
||||
if (isNullFlag) {
|
||||
quoteData.setRoleArr(roleArr);
|
||||
} else {// 不为空,根据店铺和条件查询数据
|
||||
quoteData.setRoleSearchArr(roleArr);
|
||||
}
|
||||
} else {// 只有一个角色
|
||||
quoteData.setRoleSearch(roleArr[0]);
|
||||
}
|
||||
}
|
||||
// 如果有【超管】,但是没有【所有店铺】,隐藏非本部店铺
|
||||
if (isSuper && !isAllShop) {
|
||||
quoteData.setIsSelfShop("0");
|
||||
}
|
||||
// 有【超管、全部店铺】直接走这
|
||||
return quoteDataMapper.quoteDatas(quoteData);
|
||||
}
|
||||
|
||||
public Msg updateById(int id, String field, String value, String username) {
|
||||
QuoteData quoteData = new QuoteData();
|
||||
SysUser user = (SysUser) SecurityUtils.getSubject().getPrincipal();
|
||||
boolean flag = new CustomerDataControlle().isSuperOrManager();
|
||||
// 如果修改的是店长评语,判断有没有【组长】身份
|
||||
if ("commentManager".equals(field)) {
|
||||
// 超管、组长身份才允许修改comment
|
||||
if (!flag) {
|
||||
return Msg.fail("只允许店长修改!");
|
||||
}
|
||||
quoteData.setCommentManager(value);
|
||||
} else if ("price".equals(field) || "buyPrice".equals(field)) {// 如果是价格/成交价格,组长和自己都能改
|
||||
if (!flag && !username.equals(user.getUsername())) {
|
||||
return Msg.fail("除店长外,不允许修改他人的数据!");
|
||||
}
|
||||
if ("price".equals(field)) {
|
||||
quoteData.setPrice(Double.valueOf(value));
|
||||
} else if ("buyPrice".equals(field)) {
|
||||
quoteData.setBuyPrice(Double.valueOf(value));
|
||||
}
|
||||
} else {
|
||||
// 只有自己的数据才能更改【客户旺旺】
|
||||
if (!username.equals(user.getUsername())) {
|
||||
return Msg.fail("只允许修改自己的数据!");
|
||||
}
|
||||
if ("wangwang".equals(field)) {
|
||||
quoteData.setWangwang(value);
|
||||
// 填写客户旺旺的时候,更改填写状态
|
||||
quoteData.setIsFillIn("1");
|
||||
} else if ("commentSelf".equals(field)) {
|
||||
quoteData.setCommentSelf(value);
|
||||
}
|
||||
}
|
||||
quoteData.setId(id);
|
||||
quoteDataMapper.updateById(quoteData);
|
||||
|
||||
return Msg.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取报价过的产品种类
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<String> getProType() {
|
||||
return quoteDataMapper.getProType();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改【是否当天成交】状态
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
|
||||
public Msg changeIsBuyToDay(Integer id) {
|
||||
try {
|
||||
quoteDataMapper.changeIsBuyToDay(id);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改【是否成交】状态
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public Msg changeIsBuy(Integer id) {
|
||||
try {
|
||||
quoteDataMapper.changeIsBuy(id);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改所属店铺以及选择状态
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public Msg updateShopnameSelect(String shopname, Integer id) {
|
||||
try {
|
||||
quoteDataMapper.updateShopnameSelect(shopname, id);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 填写成交订单号
|
||||
*
|
||||
* @param orderNumber
|
||||
* @return
|
||||
*/
|
||||
public Msg addOrderNumber(Integer id, String orderNumber) {
|
||||
try {
|
||||
quoteDataMapper.addOrderNumber(id, orderNumber);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 柱状图
|
||||
*
|
||||
* @param quoteData
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> echartZhuList(QuoteData quoteData,int isKefu) {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
List<String> sname = new ArrayList<String>();// 获取数据中有的店铺名称
|
||||
List<Double> allData = new ArrayList<Double>();// 所有数据条数
|
||||
List<Double> allNotBuy = new ArrayList<Double>();// 合计未成交
|
||||
List<Double> allBuy = new ArrayList<Double>();// 合计已成交
|
||||
List<Double> todayBuy = new ArrayList<Double>();// 合计当天已成交
|
||||
List<Double> notTodaybuy = new ArrayList<Double>();// 合计跟单后已成交
|
||||
List<Double> allBuyPrice = new ArrayList<Double>();// 所有成交金额
|
||||
List<Double> todayBuyPrice = new ArrayList<Double>();// 当天成交金额
|
||||
List<Double> notTodayBuyPrice = new ArrayList<Double>();// 跟单成交金额
|
||||
List<Double> allBuyPercentage = new ArrayList<Double>();// 成交百分比
|
||||
List<QuoteData> allDataList = new ArrayList<QuoteData>();// 所有数据
|
||||
|
||||
// 判断是否拥有超管身份标识
|
||||
boolean isNoSuper = true;
|
||||
boolean isNoAllShop = true;
|
||||
long startTime, endTime = 0;
|
||||
startTime = System.currentTimeMillis();
|
||||
quoteData.setQuoteTimeEnd(new DateFormatUtils().formatEndTime(quoteData.getQuoteTimeBegin()));
|
||||
quoteData.setQuoteTimeBegin(new DateFormatUtils().formatBeginTime(quoteData.getQuoteTimeBegin()));
|
||||
// 如果是通过‘所属店铺’查询
|
||||
// 只根据店铺查===>查出该店铺人员该店铺的报价数据
|
||||
if(isKefu != 0) {//判断是否统计客服大单信息
|
||||
List<String> realnameList = new ArrayList<String>();
|
||||
// 根据店铺搜索该店铺有的人员
|
||||
String roleSearch = "999";
|
||||
if(quoteData.getRoleSearch() != "") {
|
||||
roleSearch = roleSearch.concat(",").concat(quoteData.getRoleSearch());
|
||||
}
|
||||
realnameList = quoteDataMapper.getRealnames(roleSearch);
|
||||
// 根据人员查询数据
|
||||
for (String realname : realnameList) {
|
||||
quoteData.setShopname(quoteData.getRoleSearch());
|
||||
quoteData.setRealname(realname);
|
||||
QuoteData echartList = quoteDataMapper.getKefuEchartList(quoteData);
|
||||
// X坐标展示客服名字
|
||||
sname.add(realname);
|
||||
allDataList.add(echartList);
|
||||
}
|
||||
}else if (StringUtils.isNotEmpty(quoteData.getRoleSearch()) && StringUtils.isEmpty(quoteData.getRealname())
|
||||
&& !"1".equals(quoteData.getByProTypeLabel())) {
|
||||
// 店铺人员集合
|
||||
List<String> realnameList = new ArrayList<String>();
|
||||
// 根据店铺搜索该店铺有的人员
|
||||
realnameList = quoteDataMapper.getRealnames(quoteData.getRoleSearch());
|
||||
// 根据人员查询数据
|
||||
for (String realname : realnameList) {
|
||||
quoteData.setShopname(quoteData.getRoleSearch());
|
||||
quoteData.setRealname(realname);
|
||||
QuoteData echartList = quoteDataMapper.getEchartList(quoteData);
|
||||
// X坐标展示客服名字
|
||||
sname.add(realname);
|
||||
allDataList.add(echartList);
|
||||
}
|
||||
} else if ("1".equals(quoteData.getByProTypeLabel()) && StringUtils.isEmpty(quoteData.getRoleSearch())
|
||||
&& StringUtils.isEmpty(quoteData.getRealname())) { // 只根据产品查==>查出报价的所有产品
|
||||
// 产品
|
||||
List<String> productList = new ArrayList<String>();
|
||||
// 报价中有的产品
|
||||
productList = this.getProType();
|
||||
// 根据人员查询数据
|
||||
for (String product : productList) {
|
||||
quoteData.setProTypeLabel(product);
|
||||
QuoteData echartList = quoteDataMapper.getEchartList(quoteData);
|
||||
// X坐标展示产品
|
||||
sname.add(product);
|
||||
allDataList.add(echartList);
|
||||
}
|
||||
} else if (StringUtils.isNotEmpty(quoteData.getRoleSearch())
|
||||
&& StringUtils.isNotEmpty(quoteData.getRealname())) { // 根据店铺及人员查==>查询人员该店铺的产品报价
|
||||
// 产品
|
||||
List<String> productList = new ArrayList<String>();
|
||||
// 报价中有的产品
|
||||
productList = this.getProType();
|
||||
// 根据人员查询数据
|
||||
for (String product : productList) {
|
||||
quoteData.setProTypeLabel(product);
|
||||
quoteData.setShopname(quoteData.getRoleSearch());
|
||||
quoteData.setRealname(quoteData.getRealname());
|
||||
QuoteData echartList = quoteDataMapper.getEchartList(quoteData);
|
||||
// X坐标展示产品
|
||||
sname.add(product);
|
||||
allDataList.add(echartList);
|
||||
}
|
||||
} else if (StringUtils.isNotEmpty(quoteData.getRoleSearch()) && "1".equals(quoteData.getByProTypeLabel())
|
||||
&& StringUtils.isEmpty(quoteData.getRealname())) { // 查询店铺的产品
|
||||
// 产品
|
||||
List<String> productList = new ArrayList<String>();
|
||||
// 报价中有的产品
|
||||
productList = this.getProType();
|
||||
// 根据人员查询数据
|
||||
for (String product : productList) {
|
||||
quoteData.setShopname(quoteData.getRoleSearch());
|
||||
quoteData.setProTypeLabel(product);
|
||||
QuoteData echartList = quoteDataMapper.getEchartList(quoteData);
|
||||
// X坐标展示产品
|
||||
sname.add(product);
|
||||
allDataList.add(echartList);
|
||||
}
|
||||
} else if (StringUtils.isNotEmpty(quoteData.getRealname()) && StringUtils.isEmpty(quoteData.getRoleSearch())
|
||||
&& !"1".equals(quoteData.getByProTypeLabel())) { // 只根据名字查==>查该人员所有店铺的产品报价
|
||||
// 产品
|
||||
List<String> productList = new ArrayList<String>();
|
||||
// 报价中有的产品
|
||||
productList = this.getProType();
|
||||
// 根据人员查询数据
|
||||
for (String product : productList) {
|
||||
quoteData.setProTypeLabel(product);
|
||||
quoteData.setRealname(quoteData.getRealname());
|
||||
QuoteData echartList = quoteDataMapper.getEchartList(quoteData);
|
||||
sname.add(product);
|
||||
allDataList.add(echartList);
|
||||
}
|
||||
} else {
|
||||
// 用户所拥有的角色
|
||||
SysUser user = (SysUser) SecurityUtils.getSubject().getPrincipal();
|
||||
String[] roleArr = user.getRole().split(",");
|
||||
for (int i = 0; i < roleArr.length; i++) {
|
||||
// 有【超级管理员、全部店铺】身份,状态改为false
|
||||
if ("1".equals(roleArr[i])) {
|
||||
isNoSuper = false;
|
||||
break;
|
||||
}
|
||||
if ("777".equals(roleArr[i])) {
|
||||
isNoAllShop = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 报价数据中拥有的店铺
|
||||
// List<String> shopName = quoteDataMapper.getShopName(quoteData);
|
||||
List<String> shopName = new ArrayList<String>();
|
||||
|
||||
// 如果没有【超管、所有店铺】,直接把自己的拥有的店铺拿去查询数据,同时排除特殊角色
|
||||
if (isNoSuper && isNoAllShop) {
|
||||
// 获取【不允许被创建】的特殊角色id
|
||||
List<Integer> specialRoleIdList = roleMapper.getRoleIdsWhenIsNotRegist();
|
||||
// shopName.clear();
|
||||
for (String shopname : roleArr) {
|
||||
// 是否拥有特殊角色标识
|
||||
boolean specialFlag = false;
|
||||
for (int j = 0; j < specialRoleIdList.size(); j++) {
|
||||
// 如果用户拥有的角色属于不可被创建的特殊角色,就排除,不加到图形中统计
|
||||
if (specialRoleIdList.get(j).toString().equals(shopname)) {
|
||||
specialFlag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 不是特殊角色,就加到列表中
|
||||
if (!specialFlag) {
|
||||
shopName.add(shopname);
|
||||
}
|
||||
}
|
||||
} else {// 有【超管】或者有【所有店铺】
|
||||
// 报价数据中拥有的店铺
|
||||
shopName = quoteDataMapper.getShopName(quoteData);
|
||||
// 如果有【超管】,但是没有【所有店铺】,把非公司店铺去除掉
|
||||
if (!isNoSuper && isNoAllShop) {
|
||||
// 别的公司的店铺ID
|
||||
List<Integer> otherRoleIdList = roleMapper.getRoleIdsWhenIsNotLingTao();
|
||||
for (int i = 0; i < shopName.size(); i++) {
|
||||
// 其他公司店铺标识
|
||||
boolean otherFlag = false;
|
||||
for (int j = 0; j < otherRoleIdList.size(); j++) {
|
||||
// 如果报价中的店铺是别的公司的店铺,就排除,不加到图形中统计
|
||||
if (otherRoleIdList.get(j).toString().equals(shopName.get(i).toString())) {
|
||||
otherFlag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 是别的公司的店铺,就移除
|
||||
if (otherFlag) {
|
||||
shopName.remove(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 根据店铺查询数据
|
||||
for (String shopname : shopName) {
|
||||
quoteData.setShopname(shopname);
|
||||
QuoteData echartList = quoteDataMapper.getEchartList(quoteData);
|
||||
sname.add(shopname);
|
||||
allDataList.add(echartList);
|
||||
}
|
||||
}
|
||||
|
||||
// 排序
|
||||
Collections.sort(allDataList, new Comparator<QuoteData>() {
|
||||
@Override
|
||||
public int compare(QuoteData o1, QuoteData o2) {
|
||||
return (int) (o2.getAllData() - o1.getAllData());
|
||||
}
|
||||
});
|
||||
|
||||
for (QuoteData data : allDataList) {
|
||||
allData.add(data.getAllData());
|
||||
allBuy.add(data.getAllBuy());
|
||||
allNotBuy.add(data.getAllNotBuy());
|
||||
todayBuy.add(data.getTodayBuy());
|
||||
notTodaybuy.add(data.getNotTodayBuy());
|
||||
allBuyPrice.add(data.getAllBuyPrice());
|
||||
todayBuyPrice.add(data.getTodayBuyPrice());
|
||||
notTodayBuyPrice.add(data.getNotTodayBuyPrice());
|
||||
allBuyPercentage.add(data.getAllBuyPercentage());
|
||||
}
|
||||
map.put("sname", sname);
|
||||
map.put("one", allData);
|
||||
map.put("two", allBuy);
|
||||
map.put("three", allNotBuy);
|
||||
map.put("four", todayBuy);
|
||||
map.put("five", notTodaybuy);
|
||||
map.put("six", allBuyPrice);
|
||||
map.put("seven", todayBuyPrice);
|
||||
map.put("eight", notTodayBuyPrice);
|
||||
map.put("nine", allBuyPercentage);
|
||||
endTime = System.currentTimeMillis();
|
||||
System.out.println("getShopName使用的时间:" + (endTime - startTime));
|
||||
return map;
|
||||
}
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
public void excel(HttpServletResponse response, QuoteData quoteData) throws Exception {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
List<QuoteData> quoteDatasList = new ArrayList<QuoteData>();
|
||||
List<SysRole> allRoleNameList = sysRolemapper.getAllRoleName(null);
|
||||
|
||||
// 需要导出的数据
|
||||
quoteDatasList = quoteDatas(quoteData);
|
||||
|
||||
// 创建excel文件
|
||||
XSSFWorkbook wb = new XSSFWorkbook();
|
||||
// 创建sheet页
|
||||
XSSFSheet sheet = wb.createSheet("总表");
|
||||
// 创建excel文件
|
||||
// HSSFWorkbook wb = new HSSFWorkbook();
|
||||
// 创建sheet页
|
||||
// HSSFSheet sheet = wb.createSheet("总表");
|
||||
String filename = "客服操作数据";
|
||||
String shopname = "";
|
||||
String isToDayBuy = "未成交";
|
||||
String isBuy = "未成交";
|
||||
|
||||
// 创建标题行
|
||||
XSSFRow titleRow = sheet.createRow(0);
|
||||
// 创建标题行
|
||||
// HSSFRow titleRow = sheet.createRow(0);
|
||||
titleRow.createCell(0).setCellValue("操作人");
|
||||
titleRow.createCell(1).setCellValue("数据所属店铺");
|
||||
titleRow.createCell(2).setCellValue("客户旺旺");
|
||||
titleRow.createCell(3).setCellValue("操作");
|
||||
titleRow.createCell(4).setCellValue("金额");
|
||||
titleRow.createCell(5).setCellValue("当天成交");
|
||||
titleRow.createCell(6).setCellValue("未成交原因");
|
||||
titleRow.createCell(7).setCellValue("跟单后成交");
|
||||
titleRow.createCell(8).setCellValue("成交金额");
|
||||
titleRow.createCell(9).setCellValue("店长追踪情况汇报");
|
||||
titleRow.createCell(10).setCellValue("操作时间");
|
||||
// 遍历将数据放到excel列中
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
for (QuoteData quoteDatas : quoteDatasList) {
|
||||
shopname = "";
|
||||
isToDayBuy = "未成交";
|
||||
isBuy = "未成交";
|
||||
for (SysRole sysRole : allRoleNameList) {
|
||||
if (String.valueOf(sysRole.getRoleId()).equals(quoteDatas.getShopname())) {
|
||||
shopname = sysRole.getRoleName();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (quoteDatas.getIsBuyToDay().equals("1")) {
|
||||
isToDayBuy = "已成交";
|
||||
}
|
||||
if (quoteDatas.getIsBuy().equals("1")) {
|
||||
isBuy = "已成交";
|
||||
}
|
||||
XSSFRow dataRow = sheet.createRow(sheet.getLastRowNum() + 1);
|
||||
// HSSFRow dataRow = sheet.createRow(sheet.getLastRowNum() + 1);
|
||||
dataRow.createCell(0).setCellValue(quoteDatas.getRealname());
|
||||
dataRow.createCell(1).setCellValue(shopname);
|
||||
dataRow.createCell(2).setCellValue(quoteDatas.getWangwang());
|
||||
dataRow.createCell(3).setCellValue(quoteDatas.getRemark());
|
||||
dataRow.createCell(4).setCellValue(quoteDatas.getPrice());
|
||||
dataRow.createCell(5).setCellValue(isToDayBuy);
|
||||
dataRow.createCell(6).setCellValue(quoteDatas.getCommentSelf());
|
||||
dataRow.createCell(7).setCellValue(isBuy);
|
||||
dataRow.createCell(8).setCellValue(quoteDatas.getBuyPrice() != null ? quoteDatas.getBuyPrice() : 0);
|
||||
dataRow.createCell(9).setCellValue(quoteDatas.getCommentManager());
|
||||
dataRow.createCell(10).setCellValue(formatter.format(quoteDatas.getQuoteTime()));
|
||||
}
|
||||
|
||||
// 设置下载时客户端Excel的名称
|
||||
response.setContentType("application/octet-stream;charset=utf-8");
|
||||
response.setHeader("Content-Disposition",
|
||||
"attachment;filename=" + new String(filename.getBytes(), "iso-8859-1") + ".xls");// + ".xls"
|
||||
|
||||
OutputStream ouputStream = response.getOutputStream();
|
||||
wb.write(ouputStream);
|
||||
ouputStream.flush();
|
||||
ouputStream.close();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,247 @@
|
||||
package lingtao.net.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import lingtao.net.bean.Product;
|
||||
import lingtao.net.bean.ProductImg;
|
||||
import lingtao.net.bean.QuoteData;
|
||||
import lingtao.net.bean.QuoteLog;
|
||||
import lingtao.net.bean.SysDictProduct;
|
||||
import lingtao.net.bean.SysRole;
|
||||
import lingtao.net.bean.SysUser;
|
||||
import lingtao.net.dao.ProductImgMapper;
|
||||
import lingtao.net.dao.QuoteDataMapper;
|
||||
import lingtao.net.dao.QuoteLogMapper;
|
||||
import lingtao.net.util.DateFormatUtils;
|
||||
import lingtao.net.util.IPUtils;
|
||||
|
||||
@Service
|
||||
public class QuoteLogService {
|
||||
|
||||
@Autowired
|
||||
private QuoteLogMapper quoteLogMapper;
|
||||
|
||||
@Autowired
|
||||
private QuoteDataMapper quoteDataMapper;
|
||||
|
||||
@Autowired
|
||||
ProductImgMapper productImgMapper;
|
||||
|
||||
@Autowired
|
||||
private SysRoleService sysRoleService;
|
||||
|
||||
// 列表
|
||||
public List<QuoteLog> quoteLogs(QuoteLog quoteLog) {
|
||||
quoteLog.setQuoteTimeEnd(new DateFormatUtils().formatEndTime(quoteLog.getQuoteTimeBegin()));
|
||||
quoteLog.setQuoteTimeBegin(new DateFormatUtils().formatBeginTime(quoteLog.getQuoteTimeBegin()));
|
||||
return quoteLogMapper.quoteLogs(quoteLog);
|
||||
}
|
||||
|
||||
// 操作日志
|
||||
public String log(Product product, HttpServletRequest request, List<Product> proList) {
|
||||
long startTime, endTime = 0;
|
||||
startTime = System.currentTimeMillis();
|
||||
SysUser user = (SysUser) request.getSession().getAttribute("USER_SESSION");
|
||||
if (user == null) {
|
||||
return "登陆失效";
|
||||
}
|
||||
QuoteLog log = new QuoteLog();
|
||||
ProductImg productImg = new ProductImg();
|
||||
|
||||
// product转productImg
|
||||
BeanUtils.copyProperties(product, productImg);
|
||||
// 根据value查询label
|
||||
if ("13".equals(productImg.getProTypeValue()) || "15".equals(productImg.getProTypeValue())
|
||||
|| "4".equals(productImg.getProTypeValue())) {
|
||||
productImg.setKind2Value(null);
|
||||
}
|
||||
// 优惠券
|
||||
if ("4".equals(productImg.getProTypeValue())) {
|
||||
productImg.setKindValue("0");
|
||||
productImg.setKind2Value(product.getKind());
|
||||
}
|
||||
// 合版封套
|
||||
if ("6".equals(productImg.getProTypeValue())) {
|
||||
if (product.getLengthSize() > 0) {
|
||||
productImg.setKind2Value("0");
|
||||
}
|
||||
}
|
||||
// 根据value获取label
|
||||
SysDictProduct label = productImgMapper.getLabel(productImg);
|
||||
|
||||
if (StringUtils.isEmpty(label)) {
|
||||
return null;
|
||||
}
|
||||
String s = "";
|
||||
String remark_judge = "";
|
||||
String proTypeLabel = "";
|
||||
if ("常用种类".equals(product.getStickerKind())) {
|
||||
s += "常用种类- ";
|
||||
}
|
||||
if ("少数量".equals(product.getStickerKind())) {
|
||||
s += "少数量- ";
|
||||
}
|
||||
if ("专版打印".equals(product.getStickerKind())) {
|
||||
s += "专版打印- ";
|
||||
}
|
||||
if (!StringUtils.isEmpty(label.getProTypeLabel())) {
|
||||
if ("金属标".equals(label.getProTypeLabel()) && StringUtils.isEmpty(product.getCraftMo())) {
|
||||
s += "UV转印贴 - ";
|
||||
proTypeLabel = "UV转印贴";
|
||||
} else {
|
||||
s += label.getProTypeLabel() + " - ";
|
||||
proTypeLabel = label.getProTypeLabel();
|
||||
}
|
||||
}
|
||||
if ("少数量".equals(product.getCouponKind())) {
|
||||
s += product.getProTypeLabel() + " - ";
|
||||
}
|
||||
if (!StringUtils.isEmpty(label.getKindLabel())) {
|
||||
s += label.getKindLabel() + " - ";
|
||||
}
|
||||
if (!StringUtils.isEmpty(label.getKind2Label())) {
|
||||
s += label.getKind2Label() + " - ";
|
||||
}
|
||||
if (!StringUtils.isEmpty(product.getKind3Value())) {
|
||||
if ("0".equals(product.getKind3Value())) {
|
||||
s += "骑马钉 - ";
|
||||
}
|
||||
}
|
||||
String new_s = s;
|
||||
new_s += "客户旺旺:" + product.getWangwang() + " - ";
|
||||
// 产品 - 种类
|
||||
remark_judge = new_s;
|
||||
// 不区分专版打印或者常用,3分钟内都不要
|
||||
if (remark_judge.contains("常用种类- ") || remark_judge.contains("专版打印- ")) {
|
||||
remark_judge = remark_judge.substring(6);
|
||||
}
|
||||
// 画册P数
|
||||
if (!StringUtils.isEmpty(product.getPcount())) {
|
||||
s += product.getPcount() + "P - ";
|
||||
}
|
||||
if (!StringUtils.isEmpty(product.getSize())) {
|
||||
s += product.getSize() + " - ";
|
||||
}
|
||||
if (!StringUtils.isEmpty(product.getCraftMo())) {
|
||||
s += product.getCraftMo() + " - ";
|
||||
}
|
||||
if (!StringUtils.isEmpty(product.getCraftTang())) {
|
||||
s += product.getCraftTang() + " - ";
|
||||
}
|
||||
if (!StringUtils.isEmpty(product.getAotu())) {
|
||||
s += product.getAotu() + " - ";
|
||||
}
|
||||
if (!StringUtils.isEmpty(product.getYinbai())) {
|
||||
s += product.getYinbai() + " - ";
|
||||
}
|
||||
if (!StringUtils.isEmpty(product.getCraftSheng())) {
|
||||
s += product.getCraftSheng() + " - ";
|
||||
}
|
||||
if (!StringUtils.isEmpty(product.getCraftShua())) {
|
||||
s += product.getCraftShua() + " - ";
|
||||
}
|
||||
if (!StringUtils.isEmpty(product.getCraftBu())) {
|
||||
s += product.getCraftBu() + " - ";
|
||||
}
|
||||
if (!StringUtils.isEmpty(product.getCraftJiao())) {
|
||||
s += product.getCraftJiao() + " - ";
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(product.getCraft())) {
|
||||
String[] craft = product.getCraft();
|
||||
for (int i = 0; i < craft.length; i++) {
|
||||
if (StringUtils.isEmpty(craft[i]))
|
||||
continue;
|
||||
s += craft[i] + " - ";
|
||||
}
|
||||
}
|
||||
if (!StringUtils.isEmpty(product.getNumber())) {
|
||||
s += product.getNumber() + "款 - ";
|
||||
}
|
||||
|
||||
if ("16".equals(product.getProTypeValue())) {
|
||||
s += product.getCount() + "本 " + proList.get(0).getPrice() + "元 ";
|
||||
} else {
|
||||
s += product.getCount() + "个 " + proList.get(0).getPrice() + "元 ";
|
||||
}
|
||||
|
||||
log.setRemark(s);
|
||||
log.setRealname(user.getRealname());
|
||||
log.setUsername(user.getUsername());
|
||||
log.setQuoteIp(IPUtils.getIpAddr(request));// 获取ip
|
||||
log.setBrower(IPUtils.getBrowserName(request));// 获取浏览器名称
|
||||
log.setOs(IPUtils.getOsName(request)); // 获取操作系统名称
|
||||
log.setPrice(proList.get(0).getPrice());
|
||||
List<SysRole> allRoleNames = sysRoleService.getAllRoleName(null);
|
||||
String roleName = "";
|
||||
String[] split = user.getRole().split(",");
|
||||
for (SysRole sysRole : allRoleNames) {
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
if (split[i].equals(String.valueOf(sysRole.getRoleId()))) {
|
||||
roleName += sysRole.getRoleName() + "、";
|
||||
}
|
||||
}
|
||||
}
|
||||
log.setShopname(roleName);
|
||||
quoteLogMapper.insertSelective(log);
|
||||
|
||||
endTime = System.currentTimeMillis();
|
||||
System.out.println("【insertSelective】使用的时间:" + (endTime - startTime));
|
||||
|
||||
long startTime2, endTime2 = 0;
|
||||
startTime2 = System.currentTimeMillis();
|
||||
boolean flag = false;
|
||||
// 查询3分钟内自己报的数据
|
||||
List<String> remarkJudgeData = quoteDataMapper.getQuoteDataByMinutes(user.getUsername());
|
||||
endTime2 = System.currentTimeMillis();
|
||||
System.out.println("【getQuoteDataByMinutes】使用的时间:" + (endTime2 - startTime2));
|
||||
for (String remarkJudge : remarkJudgeData) {
|
||||
if (remarkJudge.equals(remark_judge)) {
|
||||
// 如果3分钟内报过相同数据
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 插入数据(给客服数据新增用的)
|
||||
String role = user.getRole();
|
||||
// 客服报的且3分钟内没有同一个客户报的数据才插入
|
||||
if (role.contains("999,") && !flag) {
|
||||
QuoteData quoteData = new QuoteData();
|
||||
quoteData.setUsername(user.getUsername());
|
||||
quoteData.setRealname(user.getRealname());
|
||||
quoteData.setPrice(proList.get(0).getPrice());
|
||||
quoteData.setRole(user.getRole());
|
||||
// 默认都是没选择店铺
|
||||
quoteData.setIsSelect("0");
|
||||
// role = role.replace("999,", "").replace(",1049", "").replace(",1011", "");
|
||||
// 规则:第一位客服,第二位主店铺
|
||||
String shopname = role.substring(role.indexOf(",") + 1);
|
||||
if (shopname.indexOf(",") != -1) {
|
||||
shopname = shopname.substring(0, shopname.indexOf(","));
|
||||
}
|
||||
System.out.println(shopname);
|
||||
quoteData.setShopname(shopname);
|
||||
quoteData.setIsSelect("1");
|
||||
// 除去【客服】只有一个店铺,所属店铺就是剩下这个店铺 切 选择状态改为已选择
|
||||
// if (!role.contains(",")) {
|
||||
// }
|
||||
quoteData.setIsBuy("0");
|
||||
quoteData.setIsBuyToDay("0");
|
||||
quoteData.setRemark(s);
|
||||
quoteData.setRemarkJudge(remark_judge);
|
||||
// 默认都是填写旺旺号
|
||||
quoteData.setIsFillIn("1");
|
||||
quoteData.setWangwang(product.getWangwang().trim());
|
||||
quoteData.setProTypeLabel(proTypeLabel);
|
||||
quoteDataMapper.addQuoteData(quoteData);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package lingtao.net.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import lingtao.net.bean.Msg;
|
||||
import lingtao.net.bean.SysDictSearchPro;
|
||||
import lingtao.net.bean.SysUser;
|
||||
import lingtao.net.dao.SysDictSearchProMapper;
|
||||
|
||||
@Service
|
||||
public class SysDictSearchProService {
|
||||
|
||||
@Autowired
|
||||
SysDictSearchProMapper searchProMapper;
|
||||
|
||||
// 查询
|
||||
public List<SysDictSearchPro> keyWordsList(SysDictSearchPro searchPro) {
|
||||
return searchProMapper.keyWordsList(searchPro);
|
||||
}
|
||||
|
||||
// 新增
|
||||
public Msg addSearchPro(SysDictSearchPro searchPro, HttpSession session) {
|
||||
SysUser user = (SysUser) session.getAttribute("USER_SESSION");
|
||||
searchPro.setCreator(user.getRealname());
|
||||
try {
|
||||
searchProMapper.insertSelective(searchPro);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
// 修改关键字
|
||||
public Msg updateKeyWordById(HttpSession session, int id, String value, String field) {
|
||||
SysUser user = (SysUser) session.getAttribute("USER_SESSION");
|
||||
SysDictSearchPro searchPro = new SysDictSearchPro();
|
||||
searchPro.setId(id);
|
||||
if ("url".equals(field)) {
|
||||
searchPro.setUrl(value);
|
||||
} else {
|
||||
searchPro.setLikeProTypeLabel(value);
|
||||
}
|
||||
searchPro.setUpdater(user.getRealname());
|
||||
try {
|
||||
searchProMapper.updateKeyWordById(searchPro);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
// 改变状态
|
||||
public Msg changeKeyWordStatus(Integer id) {
|
||||
try {
|
||||
searchProMapper.changeKeyWordStatus(id);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package lingtao.net.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import lingtao.net.bean.SysPermission;
|
||||
import lingtao.net.dao.SysPermissionMapper;
|
||||
|
||||
@Service
|
||||
public class SysPermissionService {
|
||||
|
||||
@Autowired
|
||||
SysPermissionMapper sysPermissionMapper;
|
||||
|
||||
public List<SysPermission> getAll() {
|
||||
return sysPermissionMapper.getAll();
|
||||
}
|
||||
|
||||
public List<SysPermission> getParentPers() {
|
||||
return sysPermissionMapper.getParentPers();
|
||||
}
|
||||
|
||||
public List<SysPermission> getPersByUserId(Integer userId) {
|
||||
return sysPermissionMapper.getPersByUserId(userId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package lingtao.net.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import lingtao.net.bean.Msg;
|
||||
import lingtao.net.bean.SysRole;
|
||||
import lingtao.net.bean.SysUser;
|
||||
import lingtao.net.dao.SysRoleMapper;
|
||||
|
||||
@Service
|
||||
public class SysRoleService {
|
||||
|
||||
@Autowired
|
||||
private SysRoleMapper sysRolemapper;
|
||||
|
||||
// 角色列表
|
||||
public List<SysRole> getRoles(SysRole role) {
|
||||
return sysRolemapper.getRoles(role);
|
||||
}
|
||||
|
||||
// 新增
|
||||
public Msg addRole(SysRole role, HttpSession session) {
|
||||
SysUser user = (SysUser) session.getAttribute("USER_SESSION");
|
||||
try {
|
||||
role.setCreateBy(user.getRealname());
|
||||
sysRolemapper.insertSelective(role);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
// 修改
|
||||
public Msg updateRoleById(SysRole role) {
|
||||
try {
|
||||
sysRolemapper.updateByPrimaryKeySelective(role);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
// 改变用户状态
|
||||
public Msg changeRoleStatus(String roleId) {
|
||||
try {
|
||||
sysRolemapper.changeRoleStatus(roleId);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
// 根据角色id查询角色拥有的权限
|
||||
public List<Integer> getPerIdsByRoleId(Integer id) {
|
||||
return sysRolemapper.getPerIdsByRoleId(id);
|
||||
}
|
||||
|
||||
// 删除角色已有的权限
|
||||
public void deleteRolePermissions(Integer roleId) {
|
||||
sysRolemapper.deleteRolePermissions(roleId);
|
||||
|
||||
}
|
||||
|
||||
// 给角色授权
|
||||
public void addRolePermissions(Integer roleId, String[] split) {
|
||||
sysRolemapper.addRolePermissions(roleId, split);
|
||||
|
||||
}
|
||||
|
||||
// 查询允许被注册的角色
|
||||
public List<SysRole> getAllRoleName(String isRegist) {
|
||||
return sysRolemapper.getAllRoleName(isRegist);
|
||||
}
|
||||
|
||||
// 查询出用户所拥有的且允许被创建的角色
|
||||
public List<SysRole> getRolesByUserId(Integer userId) {
|
||||
return sysRolemapper.getRolesByUserId(userId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,269 @@
|
||||
package lingtao.net.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import lingtao.net.bean.Msg;
|
||||
import lingtao.net.bean.SysUser;
|
||||
import lingtao.net.dao.SysUserMapper;
|
||||
import lingtao.net.util.MD5Util;
|
||||
|
||||
@Service
|
||||
public class SysUserService {
|
||||
|
||||
@Autowired
|
||||
private SysUserMapper userMapper;
|
||||
|
||||
// 注册
|
||||
public Msg register(SysUser user) {
|
||||
user.setPassword(new MD5Util().md5(user.getPassword(), "lingtao"));
|
||||
user.setCreateDate(new Date());
|
||||
// 注册的用户都是未激活状态
|
||||
user.setUserStatus("0");
|
||||
// 注册的用户都是系统功能隐藏状态
|
||||
user.setSysStatus("0");
|
||||
// 注册的用户不需要判断IP
|
||||
user.setNeedIp("1");
|
||||
String roleId = user.getRole();
|
||||
if (StringUtils.isEmpty(roleId))
|
||||
return null;
|
||||
// 给用户赋予角色
|
||||
user.setRole("999," + roleId);
|
||||
// user.setRole("999");
|
||||
// Integer[] ids = {999};
|
||||
int count = userMapper.insertSelective(user);
|
||||
// 根据角色的id把角色的权限给用户
|
||||
Integer[] ids = { 999, Integer.valueOf(roleId) };
|
||||
// 新增用户后会自动回补id
|
||||
Integer userId = user.getUserId();
|
||||
userMapper.addUserRoles(userId, ids);
|
||||
if (count < 0) {
|
||||
return Msg.fail();
|
||||
}
|
||||
return Msg.success();
|
||||
}
|
||||
|
||||
public List<SysUser> getUsers(SysUser user) {
|
||||
// 用户所拥有的角色
|
||||
String[] roleArr = user.getRole().split(",");
|
||||
// 转成list,拿掉‘组长’身份
|
||||
List<String> list = new ArrayList<String>(Arrays.asList(roleArr));
|
||||
// 判断是否拥有超管身份标识
|
||||
boolean isSuper = false;
|
||||
for (int i = 0; i < roleArr.length; i++) {
|
||||
// 有‘超级管理员’身份,状态改为true
|
||||
if ("1".equals(roleArr[i])) {
|
||||
isSuper = true;
|
||||
break;
|
||||
}
|
||||
|
||||
// 如果有【店长/考试审核员/客服/组长/IP管理员/操作日志/不填旺旺】身份,去掉。不带去查询
|
||||
if ("666".equals(roleArr[i]) || "888".equals(roleArr[i]) || "999".equals(roleArr[i])
|
||||
|| "1011".equals(roleArr[i]) || "1015".equals(roleArr[i]) || "1042".equals(roleArr[i])
|
||||
|| "1049".equals(roleArr[i])) {
|
||||
list.remove(roleArr[i]);
|
||||
}
|
||||
}
|
||||
// 将list转为String[] 数组
|
||||
roleArr = list.toArray(new String[list.size()]);
|
||||
|
||||
// 如果没有‘超级管理员’身份,只能看到负责的部门的用户;如果有可以看到所有用户
|
||||
if (!isSuper) {
|
||||
// 如果是通过‘用户角色’查询
|
||||
if (StringUtils.isNotEmpty(user.getRoleSearch())) {
|
||||
// 清除自己拥有的角色,防止查询出所有的部门数据
|
||||
roleArr = null;
|
||||
}
|
||||
// 如果有多个
|
||||
if (user.getRole().contains(",")) {
|
||||
user.setRoleArr(roleArr);
|
||||
} else {// 只有一个角色
|
||||
user.setRoleSearch(user.getRole());
|
||||
}
|
||||
}
|
||||
|
||||
return userMapper.getUsers(user);
|
||||
}
|
||||
|
||||
// 检查用户名是否存在
|
||||
public Msg checkUsername(String username) {
|
||||
SysUser user = userMapper.getUserByUsername(username);
|
||||
if (user != null) {
|
||||
return Msg.fail();
|
||||
}
|
||||
return Msg.success();
|
||||
}
|
||||
|
||||
// 新增
|
||||
public Msg addUser(SysUser user) {
|
||||
user.setPassword(new MD5Util().md5(user.getPassword(), "lingtao"));
|
||||
user.setCreateDate(new Date());
|
||||
try {
|
||||
userMapper.insertSelective(user);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
// 修改
|
||||
public Msg updateUserById(SysUser user) {
|
||||
if (!"********".equals(user.getPassword())) { // 如果改过密码
|
||||
user.setPassword(new MD5Util().md5(user.getPassword(), "lingtao"));
|
||||
} else {
|
||||
user.setPassword(null);
|
||||
}
|
||||
// 如果有【店长】身份,更改的角色前面添加【客服】
|
||||
SysUser user2 = (SysUser) SecurityUtils.getSubject().getPrincipal();
|
||||
boolean flag = false;
|
||||
String[] role = user2.getRole().split(",");
|
||||
for (int i = 0; i < role.length; i++) {
|
||||
if ("666".equals(role[i])) {
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (flag) {
|
||||
user.setRole("999," + user.getRole());
|
||||
}
|
||||
user.setUpdateDate(new Date());
|
||||
try {
|
||||
userMapper.updateByPrimaryKeySelective(user);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
// 删除用户
|
||||
public Msg deleteUserById(Integer userId) {
|
||||
try {
|
||||
userMapper.deleteByPrimaryKey(userId);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail("主外键关联,删除失败!");
|
||||
}
|
||||
}
|
||||
|
||||
// 改变用户状态
|
||||
public Msg changeUserStatus(Integer userId) {
|
||||
try {
|
||||
userMapper.changeUserStatus(userId);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
public void addUserRoles(Integer userId, Integer[] ids) {
|
||||
userMapper.addUserRoles(userId, ids);
|
||||
}
|
||||
|
||||
public void deleteUserRoles(Integer userId) {
|
||||
userMapper.deleteUserRoles(userId);
|
||||
}
|
||||
|
||||
public Msg updatePassword(SysUser user) {
|
||||
user.setPassword(new MD5Util().md5(user.getPassword(), "lingtao"));
|
||||
int i = userMapper.updateByPrimaryKeySelective(user);
|
||||
if (i > 0) {
|
||||
return Msg.success();
|
||||
}
|
||||
return Msg.fail();
|
||||
}
|
||||
|
||||
public Msg addBirthDay(SysUser user) {
|
||||
SysUser sysUser = (SysUser) SecurityUtils.getSubject().getPrincipal();
|
||||
user.setUserId(sysUser.getUserId());
|
||||
user.setIsBirthDay(0);
|
||||
int i = userMapper.updateByPrimaryKeySelective(user);
|
||||
if (i > 0) {
|
||||
return Msg.success();
|
||||
}
|
||||
return Msg.fail();
|
||||
}
|
||||
|
||||
// 改变用户生日状态
|
||||
public Msg changeIsBirthDay(Integer userId) {
|
||||
try {
|
||||
userMapper.changeIsBirthDay(userId);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
public Msg changeNeedIp() {
|
||||
try {
|
||||
userMapper.changeNeedIp();
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
// 改变用户系统状态(管理员调整)
|
||||
public Msg changeSysStatus(Integer userId) {
|
||||
try {
|
||||
userMapper.changeSysStatus(userId);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
// 改变用户系统状态(看完视频)
|
||||
public Msg videoOverToChangeSysStatus(Integer userId) {
|
||||
try {
|
||||
userMapper.videoOverToChangeSysStatus(userId);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
// 改变用户系统状态(答题通过)
|
||||
public Msg examOverToChangeSysStatus(Integer userId) {
|
||||
try {
|
||||
userMapper.examOverToChangeSysStatus(userId);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
// 改变阅读更新日志状态
|
||||
public Msg changeReadLogStatus(Integer userId) {
|
||||
try {
|
||||
userMapper.changeReadLogStatus(userId);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
public SysUser getUserInfo(Integer userId) {
|
||||
try {
|
||||
return userMapper.getUserInfo(userId);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 客服数据 -- 根据搜索的店铺获取人员
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<SysUser> getRealnamesByShopname(String shopname) {
|
||||
return userMapper.getRealnamesByShopname(shopname);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package lingtao.net.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import lingtao.net.bean.Msg;
|
||||
import lingtao.net.bean.SysUser;
|
||||
import lingtao.net.bean.UpdateLog;
|
||||
import lingtao.net.dao.UpdateLogMapper;
|
||||
|
||||
@Service
|
||||
public class UpdateLogService {
|
||||
|
||||
@Autowired
|
||||
private UpdateLogMapper updateLogMapper;
|
||||
|
||||
public List<UpdateLog> getUpdateLogs(UpdateLog updateLog) {
|
||||
|
||||
return updateLogMapper.getUpdateLogs(updateLog);
|
||||
}
|
||||
|
||||
public Msg addLog(UpdateLog updateLog, HttpSession session) {
|
||||
SysUser user = (SysUser) session.getAttribute("USER_SESSION");
|
||||
updateLog.setCreateBy(user.getRealname());
|
||||
try {
|
||||
updateLogMapper.addLog(updateLog);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
public Msg updateLogById(UpdateLog updateLog, HttpSession session) {
|
||||
try {
|
||||
updateLogMapper.updateLogById(updateLog);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
public Msg deleteLogById(Integer id) {
|
||||
try {
|
||||
updateLogMapper.deleteLogById(id);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
public Msg changeReadLogStatus() {
|
||||
try {
|
||||
updateLogMapper.changeReadLogStatus();
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package lingtao.net.service.price;
|
||||
|
||||
public interface ClothingTagService {
|
||||
|
||||
void inster();
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package lingtao.net.service.price;
|
||||
|
||||
import lingtao.net.enums.ProductEnum;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
|
||||
public interface ProductService<T> {
|
||||
|
||||
/**
|
||||
* 计算价格
|
||||
*/
|
||||
void getProduct(T t);
|
||||
|
||||
ProductEnum getEnum();
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package lingtao.net.service.price;
|
||||
|
||||
public interface SelfAdhesiveStickerService {
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package lingtao.net.service.price.impl;
|
||||
|
||||
import lingtao.net.entity.ClothingTag;
|
||||
import lingtao.net.enums.ProductEnum;
|
||||
import lingtao.net.service.price.ClothingTagService;
|
||||
import lingtao.net.service.price.ProductService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
@Service
|
||||
public class ClothingTagServiceImpl implements ProductService<ClothingTag>, ClothingTagService {
|
||||
|
||||
@Override
|
||||
public void getProduct(ClothingTag clothingTag) {
|
||||
System.out.println("===========clothingTag");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProductEnum getEnum() {
|
||||
return ProductEnum.clothing_Tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inster() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package lingtao.net.service.price.impl;
|
||||
|
||||
import lingtao.net.enums.ProductEnum;
|
||||
import lingtao.net.service.price.ProductService;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class ProductContent implements ApplicationContextAware {
|
||||
|
||||
@Autowired(required = false)
|
||||
Map<ProductEnum, ProductService> productServiceMap;
|
||||
|
||||
public ProductService getService(ProductEnum productEnum) {
|
||||
return productServiceMap.get(productEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
Map<String, ProductService> map = applicationContext.getBeansOfType(ProductService.class);
|
||||
productServiceMap = new HashMap<>();
|
||||
map.forEach((key, value) -> {
|
||||
productServiceMap.put(value.getEnum(), value);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package lingtao.net.service.price.impl;
|
||||
|
||||
import lingtao.net.entity.SelfAdhesiveSticker;
|
||||
import lingtao.net.enums.ProductEnum;
|
||||
import lingtao.net.service.price.ProductService;
|
||||
import lingtao.net.service.price.SelfAdhesiveStickerService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class SelfAdhesiveStickerServiceImpl implements ProductService<SelfAdhesiveSticker>, SelfAdhesiveStickerService {
|
||||
@Override
|
||||
public void getProduct(SelfAdhesiveSticker selfAdhesiveSticker) {
|
||||
System.out.println("===========SelfAdhesiveSticker");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProductEnum getEnum() {
|
||||
return ProductEnum.self_adhesive_sticker;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user