新增 管理品牌跟单员,新增产品资料复制功能
This commit is contained in:
parent
1d67e968e9
commit
5984d5a9d7
|
|
@ -4,6 +4,7 @@ import cn.hangtag.framework.common.exception.ServiceException;
|
|||
import cn.hangtag.framework.common.exception.enums.GlobalErrorCodeConstants;
|
||||
import cn.hangtag.framework.common.pojo.PageResult;
|
||||
import cn.hangtag.framework.common.util.FuncUtil;
|
||||
import cn.hangtag.framework.common.util.cache.CacheUtils;
|
||||
import cn.hangtag.framework.common.util.object.BeanUtils;
|
||||
import cn.hangtag.framework.common.util.validation.AssertUtil;
|
||||
import cn.hangtag.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
|
@ -50,7 +51,9 @@ import cn.hangtag.module.oms.service.product.ProductPriceService;
|
|||
import cn.hangtag.module.oms.service.productinfo.ProductInfoService;
|
||||
import cn.hangtag.module.oms.service.salecontract.SaleContractService;
|
||||
import cn.hangtag.module.oms.service.saleordersku.SaleOrderSkuService;
|
||||
import cn.hangtag.module.system.dal.dataobject.brand.UserBrandDO;
|
||||
import cn.hangtag.module.system.dal.dataobject.user.AdminUserDO;
|
||||
import cn.hangtag.module.system.dal.mysql.brand.UserBrandMapper;
|
||||
import cn.hangtag.module.system.mq.message.mail.MailSendMessage;
|
||||
import cn.hangtag.module.system.service.mail.MailSendService;
|
||||
import cn.hangtag.module.system.service.user.AdminUserService;
|
||||
|
|
@ -125,6 +128,8 @@ public class SaleOrderServiceImpl implements SaleOrderService {
|
|||
@Resource
|
||||
private CustomerMapper customerMapper;
|
||||
@Resource
|
||||
private UserBrandMapper userBrandMapper;
|
||||
@Resource
|
||||
private ProductPriceService productPriceService;
|
||||
|
||||
@Resource
|
||||
|
|
@ -196,7 +201,7 @@ public class SaleOrderServiceImpl implements SaleOrderService {
|
|||
private void validateSaleOrderStatus(Long id) {
|
||||
SaleOrderDO saleOrderDO = saleOrderMapper.selectById(id);
|
||||
if (saleOrderDO == null) {
|
||||
if(BillStatusEnum.AUDIT.getValue().equals(saleOrderDO.getBillStatus())){
|
||||
if (BillStatusEnum.AUDIT.getValue().equals(saleOrderDO.getBillStatus())) {
|
||||
throw exception(SALE_ORDER_NOT_DELETE);
|
||||
}
|
||||
}
|
||||
|
|
@ -220,9 +225,9 @@ public class SaleOrderServiceImpl implements SaleOrderService {
|
|||
List<SaleOrderEntryDO> entrys = saleOrderEntryMapper.selectListByParentId(parentId);
|
||||
for (cn.hangtag.module.oms.dal.dataobject.saleorderentry.SaleOrderEntryDO entry : entrys) {
|
||||
BigDecimal price = entry.getPrice();
|
||||
if(price==null){
|
||||
if (price == null) {
|
||||
ProductPriceDO productPrice = productPriceService.getProductPriceByProductId(entry.getParentId());
|
||||
if(productPrice!=null){
|
||||
if (productPrice != null) {
|
||||
entry.setPrice(productPrice.getPrice());
|
||||
}
|
||||
}
|
||||
|
|
@ -236,13 +241,13 @@ public class SaleOrderServiceImpl implements SaleOrderService {
|
|||
|
||||
LambdaQueryWrapper<SaleOrderDO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(SaleOrderDO::getBillStatus, BillStatusEnum.SUBMIT.getValue());
|
||||
if(customerId!=null){
|
||||
if (customerId != null) {
|
||||
lambdaQueryWrapper.eq(SaleOrderDO::getCustomerId, customerId);
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<SaleOrderDO> lambdaQueryWrapper1 = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper1.eq(SaleOrderDO::getBillStatus, BillStatusEnum.AUDIT.getValue());
|
||||
if(customerId!=null){
|
||||
if (customerId != null) {
|
||||
lambdaQueryWrapper1.eq(SaleOrderDO::getCustomerId, customerId);
|
||||
}
|
||||
|
||||
|
|
@ -262,67 +267,69 @@ public class SaleOrderServiceImpl implements SaleOrderService {
|
|||
counts.put(BillStatusEnum.YPLAN.getValue(), 0L);
|
||||
return counts;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateSaleOrderBillStatus(List<Long> ids, String status){
|
||||
updateSaleOrderBillStatus(ids,status,null);
|
||||
public void updateSaleOrderBillStatus(List<Long> ids, String status) {
|
||||
updateSaleOrderBillStatus(ids, status, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateSaleOrderBillStatus(List<Long> ids, String status,Map<String,Object> params){
|
||||
public void updateSaleOrderBillStatus(List<Long> ids, String status, Map<String, Object> params) {
|
||||
List<SaleOrderDO> saleOrders = saleOrderMapper.selectList(SaleOrderDO::getId, ids);
|
||||
switch (status){
|
||||
switch (status) {
|
||||
case "invalid": //作废
|
||||
for (SaleOrderDO saleOrder : saleOrders) {
|
||||
if(!BillStatusEnum.AUDIT.getValue().equals(saleOrder.getBillStatus())){
|
||||
if (!BillStatusEnum.AUDIT.getValue().equals(saleOrder.getBillStatus())) {
|
||||
saleOrder.setBillStatus(BillStatusEnum.INVALID.getValue());
|
||||
saleOrder.setOrderStatus(SaleOrderStatusEnum.YXD.getValue());
|
||||
saleOrderMapper.updateById(saleOrder);
|
||||
}else{
|
||||
if(StringUtils.equalsAny(saleOrder.getBillStatus(),BillStatusEnum.AUDIT.getValue(),BillStatusEnum.YPLAN.getValue())){
|
||||
throw new ServiceException(001,"订单状态已审核/已排产,不允许作废!");
|
||||
}else{
|
||||
throw new ServiceException(001,"只允许提交驳回订单!");
|
||||
} else {
|
||||
if (StringUtils.equalsAny(saleOrder.getBillStatus(), BillStatusEnum.AUDIT.getValue(), BillStatusEnum.YPLAN.getValue())) {
|
||||
throw new ServiceException(001, "订单状态已审核/已排产,不允许作废!");
|
||||
} else {
|
||||
throw new ServiceException(001, "只允许提交驳回订单!");
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "reject": //驳回
|
||||
for (SaleOrderDO saleOrder : saleOrders) {
|
||||
if(!BillStatusEnum.AUDIT.getValue().equals(saleOrder.getBillStatus()) && (params!=null && params.size()>0)){
|
||||
if (!BillStatusEnum.AUDIT.getValue().equals(saleOrder.getBillStatus()) && (params != null && params.size() > 0)) {
|
||||
saleOrder.setBillStatus(BillStatusEnum.REJECT.getValue());
|
||||
saleOrder.setOrderStatus(SaleOrderStatusEnum.YXD.getValue());
|
||||
saleOrder.setRejectReason((String)params.get("rejectReason"));
|
||||
saleOrder.setRejectReason((String) params.get("rejectReason"));
|
||||
saleOrderMapper.updateById(saleOrder);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "submit": //提交
|
||||
for (SaleOrderDO saleOrder : saleOrders) {
|
||||
if(BillStatusEnum.REJECT.getValue().equals(saleOrder.getBillStatus())){
|
||||
if (BillStatusEnum.REJECT.getValue().equals(saleOrder.getBillStatus())) {
|
||||
saleOrder.setBillStatus(BillStatusEnum.SUBMIT.getValue());
|
||||
saleOrder.setOrderStatus(SaleOrderStatusEnum.SCZ.getValue());
|
||||
saleOrderMapper.updateById(saleOrder);
|
||||
}else {
|
||||
if(BillStatusEnum.INVALID.getValue().equals(saleOrder.getBillStatus())){
|
||||
throw new ServiceException(001,"订单状态已作废,不允许提交!");
|
||||
}else{
|
||||
throw new ServiceException(001,"只允许提交驳回订单!");
|
||||
} else {
|
||||
if (BillStatusEnum.INVALID.getValue().equals(saleOrder.getBillStatus())) {
|
||||
throw new ServiceException(001, "订单状态已作废,不允许提交!");
|
||||
} else {
|
||||
throw new ServiceException(001, "只允许提交驳回订单!");
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "audit": //审核
|
||||
for (SaleOrderDO saleOrder : saleOrders) {
|
||||
if(BillStatusEnum.SUBMIT.getValue().equals(saleOrder.getBillStatus())){
|
||||
if (BillStatusEnum.SUBMIT.getValue().equals(saleOrder.getBillStatus())) {
|
||||
|
||||
List<SaleOrderEntryDO> entrys = getSaleOrderEntryListByParentId(saleOrder.getId());
|
||||
if(entrys==null||entrys.isEmpty()){
|
||||
throw new ServiceException(001,"产品明细为空");
|
||||
if (entrys == null || entrys.isEmpty()) {
|
||||
throw new ServiceException(001, "产品明细为空");
|
||||
}
|
||||
for (SaleOrderEntryDO entry : entrys) {
|
||||
BigDecimal price = entry.getPrice();
|
||||
if(price==null){
|
||||
if (price == null) {
|
||||
throw new ServiceException(ErrorCodeConstants.SALE_ORDER_ENTRY_PRICE_NOT_NULL);
|
||||
}
|
||||
}
|
||||
|
|
@ -339,65 +346,65 @@ public class SaleOrderServiceImpl implements SaleOrderService {
|
|||
for (SaleOrderEntryDO entry : entrys) {
|
||||
Long parentId = entry.getParentId();
|
||||
BigDecimal price = entry.getPrice();
|
||||
generateProductPrice(parentId,price);
|
||||
generateProductPrice(parentId, price);
|
||||
}
|
||||
|
||||
//生成销售合约
|
||||
Long saleContractId = generateSaleContract(saleOrder,entrys);
|
||||
Long saleContractId = generateSaleContract(saleOrder, entrys);
|
||||
|
||||
String htmlContent = generateHtmlContent(saleContractId);
|
||||
|
||||
//docker生成路径
|
||||
String pathUrl = System.getProperty("user.dir") + "/pdffile";
|
||||
String fileName = StrUtil.format(pathUrl+"/SaleContract_{}", saleOrder.getBillno());
|
||||
String fileName = StrUtil.format(pathUrl + "/SaleContract_{}", saleOrder.getBillno());
|
||||
//主宿机生成路径
|
||||
String fileName2 = StrUtil.format(pdfPath+"/SaleContract_{}", saleOrder.getBillno());
|
||||
String fileName2 = StrUtil.format(pdfPath + "/SaleContract_{}", saleOrder.getBillno());
|
||||
|
||||
String templatePath = fileName + ".html";
|
||||
String pdfPath = fileName + ".pdf";
|
||||
String templatePath2 = fileName2 + ".html";
|
||||
String pdfPath2 = fileName2 + ".pdf";
|
||||
|
||||
FileUtil.writeString(htmlContent,templatePath, "UTF-8");
|
||||
FileUtil.writeString(htmlContent, templatePath, "UTF-8");
|
||||
|
||||
log.info("已生成HTML文件:"+templatePath);
|
||||
log.info("已生成HTML文件:" + templatePath);
|
||||
//请求wkapp
|
||||
JSONObject params2 = new JSONObject();
|
||||
params2.put("input_html_path","file://"+templatePath2);
|
||||
params2.put("output_pdf_path",pdfPath2);
|
||||
log.info("请求wkapp接口url:"+wkappUrl+"/exehtmltopdf");
|
||||
params2.put("input_html_path", "file://" + templatePath2);
|
||||
params2.put("output_pdf_path", pdfPath2);
|
||||
log.info("请求wkapp接口url:" + wkappUrl + "/exehtmltopdf");
|
||||
String result = HttpUtil.post(wkappUrl + "/exehtmltopdf", params2, 5 * 60 * 1000);
|
||||
log.info("请求wkapp接口返回结果:"+result);
|
||||
log.info("请求wkapp接口返回结果:" + result);
|
||||
|
||||
//发送消息
|
||||
String emails = saleOrder.getEmails();
|
||||
if(StringUtils.isNotBlank(emails)){
|
||||
if (StringUtils.isNotBlank(emails)) {
|
||||
MailSendMessage message = new MailSendMessage();
|
||||
message.setAccountId(1L);
|
||||
message.setMail(emails);
|
||||
message.setTitle("OMS订单系统");
|
||||
message.setContent("您好,您的订单:"+saleOrder.getBillno()+",已审核通过!");
|
||||
message.setContent("您好,您的订单:" + saleOrder.getBillno() + ",已审核通过!");
|
||||
mailSendService.doSendMail(message);
|
||||
}
|
||||
|
||||
String orderFollowerUser = saleOrder.getOrderFollowerUser();
|
||||
if(StringUtils.isNotBlank(orderFollowerUser)){
|
||||
if (StringUtils.isNotBlank(orderFollowerUser)) {
|
||||
AdminUserDO user = adminUserService.getUser(Long.valueOf(orderFollowerUser));
|
||||
String email = user.getEmail();
|
||||
MailSendMessage message = new MailSendMessage();
|
||||
message.setAccountId(1L);
|
||||
message.setMail(email);
|
||||
message.setTitle("OMS订单系统");
|
||||
message.setContent("您好,订单:"+saleOrder.getBillno()+",已审核通过!");
|
||||
mailSendService.doSendMail(message,new File(pdfPath));
|
||||
message.setContent("您好,订单:" + saleOrder.getBillno() + ",已审核通过!");
|
||||
mailSendService.doSendMail(message, new File(pdfPath));
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "unaudit": //审核
|
||||
for (SaleOrderDO saleOrder : saleOrders) {
|
||||
if(!BillStatusEnum.AUDIT.getValue().equals(saleOrder.getBillStatus())) {
|
||||
throw new ServiceException(001,"订单状态不等于已审核状态,不允许反审核!");
|
||||
if (!BillStatusEnum.AUDIT.getValue().equals(saleOrder.getBillStatus())) {
|
||||
throw new ServiceException(001, "订单状态不等于已审核状态,不允许反审核!");
|
||||
}
|
||||
saleOrder.setBillStatus(BillStatusEnum.SUBMIT.getValue());
|
||||
saleOrder.setOrderStatus(SaleOrderStatusEnum.YXD.getValue());
|
||||
|
|
@ -411,13 +418,14 @@ public class SaleOrderServiceImpl implements SaleOrderService {
|
|||
/**
|
||||
* 生成产品单价记录
|
||||
*/
|
||||
private void generateProductPrice(Long productId,BigDecimal price){
|
||||
private void generateProductPrice(Long productId, BigDecimal price) {
|
||||
ProductPriceSaveReqVO saveReqVO = new ProductPriceSaveReqVO();
|
||||
saveReqVO.setProductId(productId);
|
||||
saveReqVO.setPrice(price);
|
||||
productPriceService.createProductPrice(saveReqVO);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void generateProduceOrder(List<Long> ids) {
|
||||
|
|
@ -454,19 +462,19 @@ public class SaleOrderServiceImpl implements SaleOrderService {
|
|||
Double specSizeHeight = productInfo.getSpecSizeHeight();
|
||||
String specMaterial = productInfo.getSpecMaterial();
|
||||
StringBuffer str = new StringBuffer();
|
||||
str.append(String.format("货名:%s\r\n",productInfo.getName()));
|
||||
str.append(String.format("规格:%s × %s \r\n",specSizeWidth,specSizeHeight));
|
||||
str.append(String.format("纸质:%s \r\n",specMaterial));
|
||||
str.append(String.format("货名:%s\r\n", productInfo.getName()));
|
||||
str.append(String.format("规格:%s × %s \r\n", specSizeWidth, specSizeHeight));
|
||||
str.append(String.format("纸质:%s \r\n", specMaterial));
|
||||
saveReqVO.setDetails(str.toString());
|
||||
Long produceOrderId = produceOrderService.createProduceOrder(saveReqVO);
|
||||
}
|
||||
|
||||
//更新销售订单已完成
|
||||
//if(produceOrderId!=null){
|
||||
SaleOrderDO saleOrderDO = new SaleOrderDO();
|
||||
saleOrderDO.setId(saleOrder.getId());
|
||||
saleOrderDO.setOrderStatus(SaleOrderStatusEnum.YWC.getValue());
|
||||
saleOrderMapper.updateById(saleOrderDO);
|
||||
SaleOrderDO saleOrderDO = new SaleOrderDO();
|
||||
saleOrderDO.setId(saleOrder.getId());
|
||||
saleOrderDO.setOrderStatus(SaleOrderStatusEnum.YWC.getValue());
|
||||
saleOrderMapper.updateById(saleOrderDO);
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
|
@ -478,12 +486,12 @@ public class SaleOrderServiceImpl implements SaleOrderService {
|
|||
return templateEngine.process("pdf_template", context);
|
||||
}
|
||||
|
||||
private String generateHtmlContent(SaleContractDO saleContract,List<SaleContractEntryDO> saleContractEntrys) {
|
||||
Context context = generateHtmlContents(saleContract,saleContractEntrys);
|
||||
private String generateHtmlContent(SaleContractDO saleContract, List<SaleContractEntryDO> saleContractEntrys) {
|
||||
Context context = generateHtmlContents(saleContract, saleContractEntrys);
|
||||
return templateEngine.process("pdf_template", context);
|
||||
}
|
||||
|
||||
private Context generateHtmlContents(SaleContractDO saleContract,List<SaleContractEntryDO> saleContractEntrys){
|
||||
private Context generateHtmlContents(SaleContractDO saleContract, List<SaleContractEntryDO> saleContractEntrys) {
|
||||
CustomerDO customer = customerService.getCustomer(saleContract.getCustomerId());
|
||||
Context context = new Context();
|
||||
context.setVariable("title", "销售合约");
|
||||
|
|
@ -500,7 +508,7 @@ public class SaleOrderServiceImpl implements SaleOrderService {
|
|||
context.setVariable("clerk", saleContract.getClerk());
|
||||
context.setVariable("saleOrderNo", saleContract.getCustomerBuyNo());
|
||||
context.setVariable("totalAmount", saleContract.getAmount());
|
||||
context.setVariable("zhTotalAmount", "合共人民币"+NumberChineseFormatterUtils.convertToChinese(saleContract.getAmount())+"整");
|
||||
context.setVariable("zhTotalAmount", "合共人民币" + NumberChineseFormatterUtils.convertToChinese(saleContract.getAmount()) + "整");
|
||||
|
||||
for (int i = 0; i < saleContractEntrys.size(); i++) {
|
||||
SaleContractEntryDO saleContractEntryDO = saleContractEntrys.get(i);
|
||||
|
|
@ -512,24 +520,24 @@ public class SaleOrderServiceImpl implements SaleOrderService {
|
|||
Double specSizeHeight = productInfo.getSpecSizeHeight();
|
||||
Double specSizeWidth = productInfo.getSpecSizeWidth();
|
||||
Double specSizeThk = productInfo.getSpecSizeThk();
|
||||
String spec = specSizeWidth.doubleValue()+ " * " + specSizeHeight.doubleValue() + " " + specSizeThk.doubleValue();
|
||||
int j = i+1;
|
||||
context.setVariable("item"+j, j+"");
|
||||
context.setVariable("explain"+j, code);
|
||||
context.setVariable("qty"+j, saleContractEntryDO.getQty());
|
||||
context.setVariable("price"+j, saleContractEntryDO.getPrice());
|
||||
context.setVariable("discount"+j, saleContractEntryDO.getDiscount());
|
||||
context.setVariable("amount"+j, saleContractEntryDO.getAmount());
|
||||
context.setVariable("deliverydate"+j, DateUtil.date(saleContractEntryDO.getDeliveryDate()).toDateStr());
|
||||
context.setVariable("explain"+j+"1", name);
|
||||
context.setVariable("explain"+j+"2", details);
|
||||
context.setVariable("explain"+j+"3", spec);
|
||||
String spec = specSizeWidth.doubleValue() + " * " + specSizeHeight.doubleValue() + " " + specSizeThk.doubleValue();
|
||||
int j = i + 1;
|
||||
context.setVariable("item" + j, j + "");
|
||||
context.setVariable("explain" + j, code);
|
||||
context.setVariable("qty" + j, saleContractEntryDO.getQty());
|
||||
context.setVariable("price" + j, saleContractEntryDO.getPrice());
|
||||
context.setVariable("discount" + j, saleContractEntryDO.getDiscount());
|
||||
context.setVariable("amount" + j, saleContractEntryDO.getAmount());
|
||||
context.setVariable("deliverydate" + j, DateUtil.date(saleContractEntryDO.getDeliveryDate()).toDateStr());
|
||||
context.setVariable("explain" + j + "1", name);
|
||||
context.setVariable("explain" + j + "2", details);
|
||||
context.setVariable("explain" + j + "3", spec);
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generatePdf(HttpServletResponse response,List<Long> ids) throws IOException {
|
||||
public void generatePdf(HttpServletResponse response, List<Long> ids) throws IOException {
|
||||
List<String> delFiles = new ArrayList<>();
|
||||
List<File> files = new ArrayList<>();
|
||||
List<SaleOrderDO> saleOrders = saleOrderMapper.selectList(SaleOrderDO::getId, ids);
|
||||
|
|
@ -538,29 +546,29 @@ public class SaleOrderServiceImpl implements SaleOrderService {
|
|||
SaleContractSaveReqVO saleContractVO = toSaleContractVO(saleOrder, entrys);
|
||||
SaleContractDO saleContract = BeanUtils.toBean(saleContractVO, SaleContractDO.class);
|
||||
List<SaleContractEntryDO> saleContractEntrys = BeanUtils.toBean(saleContractVO.getSaleContractEntrys(), SaleContractEntryDO.class);
|
||||
String htmlContent = generateHtmlContent(saleContract,saleContractEntrys);
|
||||
String htmlContent = generateHtmlContent(saleContract, saleContractEntrys);
|
||||
|
||||
|
||||
//docker生成路径
|
||||
String pathUrl = System.getProperty("user.dir") + "/pdffile";
|
||||
String fileName = StrUtil.format(pathUrl+"/SaleContract_{}", saleOrder.getBillno());
|
||||
String fileName = StrUtil.format(pathUrl + "/SaleContract_{}", saleOrder.getBillno());
|
||||
//主宿机生成路径
|
||||
String fileName2 = StrUtil.format(pdfPath+"/SaleContract_{}", saleOrder.getBillno());
|
||||
String fileName2 = StrUtil.format(pdfPath + "/SaleContract_{}", saleOrder.getBillno());
|
||||
|
||||
String templatePath = fileName + ".html";
|
||||
String pdfPath = fileName + ".pdf";
|
||||
String templatePath2 = fileName2 + ".html";
|
||||
String pdfPath2 = fileName2 + ".pdf";
|
||||
FileUtil.writeString(htmlContent,templatePath, "UTF-8");
|
||||
FileUtil.writeString(htmlContent, templatePath, "UTF-8");
|
||||
|
||||
log.info("已生成HTML文件:"+templatePath);
|
||||
log.info("已生成HTML文件:" + templatePath);
|
||||
//请求wkapp
|
||||
JSONObject params = new JSONObject();
|
||||
params.put("input_html_path","file://"+templatePath2);
|
||||
params.put("output_pdf_path",pdfPath2);
|
||||
log.info("请求wkapp接口url:"+wkappUrl+"/exehtmltopdf");
|
||||
params.put("input_html_path", "file://" + templatePath2);
|
||||
params.put("output_pdf_path", pdfPath2);
|
||||
log.info("请求wkapp接口url:" + wkappUrl + "/exehtmltopdf");
|
||||
String result = HttpUtil.post(wkappUrl + "/exehtmltopdf", params, 5 * 60 * 1000);
|
||||
log.info("请求wkapp接口返回结果:"+result);
|
||||
log.info("请求wkapp接口返回结果:" + result);
|
||||
//WKHtmlToPdfUtil.convert(templatePath, pdfPath);
|
||||
File file = FileUtil.file(pdfPath);
|
||||
files.add(file);
|
||||
|
|
@ -571,16 +579,16 @@ public class SaleOrderServiceImpl implements SaleOrderService {
|
|||
String zipFileName = StrUtil.format(pathUrl + "/SaleContract_{}", new Date().getTime());
|
||||
|
||||
// 压缩到的位置
|
||||
File zipFile = new File(zipFileName+".zip");
|
||||
File zipFile = new File(zipFileName + ".zip");
|
||||
|
||||
ZipUtil.zip(zipFile,false,files.toArray(new File[files.size()]));
|
||||
ZipUtil.zip(zipFile, false, files.toArray(new File[files.size()]));
|
||||
|
||||
//downloadZip(zipFile,response);
|
||||
|
||||
// 设置响应类型
|
||||
//response.setContentType("application/pdf");
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(zipFile.getName(),"UTF-8"));
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(zipFile.getName(), "UTF-8"));
|
||||
|
||||
// 输出PDF到响应输出流
|
||||
// 将文件内容写入响应流
|
||||
|
|
@ -608,10 +616,10 @@ public class SaleOrderServiceImpl implements SaleOrderService {
|
|||
LocalDateTime lastEndWeekDate = DateUtil.endOfWeek(DateUtil.lastWeek()).toLocalDateTime();
|
||||
|
||||
return new DataComparisonRespVO<TradeOrderSummaryRespVO>()
|
||||
.setValue(getOrderQtySummary(dayDate,dayDate,customerId))//今日
|
||||
.setReference(getOrderQtySummary(lastDayDate,lastDayDate,customerId))//昨日
|
||||
.setValue2(getOrderQtySummary(beginWeekDate,endWeekDate,customerId))//本周
|
||||
.setReference2(getOrderQtySummary(lastBeginWeekDate,lastEndWeekDate,customerId));//上周
|
||||
.setValue(getOrderQtySummary(dayDate, dayDate, customerId))//今日
|
||||
.setReference(getOrderQtySummary(lastDayDate, lastDayDate, customerId))//昨日
|
||||
.setValue2(getOrderQtySummary(beginWeekDate, endWeekDate, customerId))//本周
|
||||
.setReference2(getOrderQtySummary(lastBeginWeekDate, lastEndWeekDate, customerId));//上周
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -627,9 +635,9 @@ public class SaleOrderServiceImpl implements SaleOrderService {
|
|||
@Override
|
||||
public Long getCountByBillStatus(String billstatus, Long customerId) {
|
||||
LambdaQueryWrapper<SaleOrderDO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(SaleOrderDO::getBillStatus,billstatus);
|
||||
if(customerId!=null){
|
||||
lambdaQueryWrapper.eq(SaleOrderDO::getCustomerId,customerId);
|
||||
lambdaQueryWrapper.eq(SaleOrderDO::getBillStatus, billstatus);
|
||||
if (customerId != null) {
|
||||
lambdaQueryWrapper.eq(SaleOrderDO::getCustomerId, customerId);
|
||||
}
|
||||
return saleOrderMapper.selectCount(lambdaQueryWrapper);
|
||||
}
|
||||
|
|
@ -654,6 +662,7 @@ public class SaleOrderServiceImpl implements SaleOrderService {
|
|||
long l = IdUtil.getSnowflake().nextId();
|
||||
System.out.println(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long placeOrder(CreateSaleOrderDTO dto) {
|
||||
|
|
@ -678,7 +687,7 @@ public class SaleOrderServiceImpl implements SaleOrderService {
|
|||
// sku
|
||||
for (SaleOrderSkuDTO saleOrderSkuDTO : productSkuList) {
|
||||
SaleOrderSkuDO saleOrderSkuDO = new SaleOrderSkuDO();
|
||||
BeanUtil.copyProperties(saleOrderSkuDTO,saleOrderSkuDO,"specInfo");
|
||||
BeanUtil.copyProperties(saleOrderSkuDTO, saleOrderSkuDO, "specInfo");
|
||||
saleOrderSkuDO.setSaleOrderId(order.getId());
|
||||
saleOrderSkuDO.setEntryId(entry.getId());
|
||||
saleOrderSkuDO.setProductTemplateType(saleOrderSkuDTO.getProductTemplateType());
|
||||
|
|
@ -699,7 +708,7 @@ public class SaleOrderServiceImpl implements SaleOrderService {
|
|||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long editOrder(Long id,CreateSaleOrderDTO dto) {
|
||||
public Long editOrder(Long id, CreateSaleOrderDTO dto) {
|
||||
|
||||
SaleOrderDO saleOrderDO = checkEditOrder(id);
|
||||
// 校验订单
|
||||
|
|
@ -734,7 +743,7 @@ public class SaleOrderServiceImpl implements SaleOrderService {
|
|||
// sku
|
||||
for (SaleOrderSkuDTO saleOrderSkuDTO : productSkuList) {
|
||||
SaleOrderSkuDO saleOrderSkuDO = new SaleOrderSkuDO();
|
||||
BeanUtil.copyProperties(saleOrderSkuDTO,saleOrderSkuDO,"specInfo");
|
||||
BeanUtil.copyProperties(saleOrderSkuDTO, saleOrderSkuDO, "specInfo");
|
||||
saleOrderSkuDO.setSaleOrderId(order.getId());
|
||||
saleOrderSkuDO.setEntryId(entry.getId());
|
||||
saleOrderSkuDO.setProductTemplateType(saleOrderSkuDTO.getProductTemplateType());
|
||||
|
|
@ -750,60 +759,64 @@ public class SaleOrderServiceImpl implements SaleOrderService {
|
|||
updateCustomerInvoiceData(order);
|
||||
return order.getId();
|
||||
}
|
||||
|
||||
private static final long codeId = 6L;
|
||||
private static final long saleContractCodeId = 7L;
|
||||
|
||||
@Override
|
||||
public String getNewOrderCode() {
|
||||
String s = "";
|
||||
int count = 10;
|
||||
while (true){
|
||||
count --;
|
||||
while (true) {
|
||||
count--;
|
||||
try {
|
||||
s = CodingRulesUtils.generateCode(codeId, false);
|
||||
checkCode(null,s);
|
||||
s = CodingRulesUtils.generateCode(codeId, false);
|
||||
checkCode(null, s);
|
||||
return s;
|
||||
}catch (ServiceException e){
|
||||
} catch (ServiceException e) {
|
||||
log.warn("重复或者下一个编码");
|
||||
if(count < 0){
|
||||
if (count < 0) {
|
||||
log.error("编码获取失败");
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNewContractCode2() {
|
||||
String s = "";
|
||||
int count = 10;
|
||||
while (true){
|
||||
count --;
|
||||
while (true) {
|
||||
count--;
|
||||
try {
|
||||
s = CodingRulesUtils.generateCode(saleContractCodeId, false);
|
||||
checkSaleContractCode2(null,s);
|
||||
s = CodingRulesUtils.generateCode(saleContractCodeId, false);
|
||||
checkSaleContractCode2(null, s);
|
||||
return s;
|
||||
}catch (ServiceException e){
|
||||
} catch (ServiceException e) {
|
||||
log.warn("重复或者下一个编码");
|
||||
if(count < 0){
|
||||
if (count < 0) {
|
||||
log.error("编码获取失败");
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void checkCode(Long id,String code){
|
||||
if(FuncUtil.isNotEmpty(code)){
|
||||
|
||||
private void checkCode(Long id, String code) {
|
||||
if (FuncUtil.isNotEmpty(code)) {
|
||||
LambdaQueryWrapper<SaleOrderDO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.select(SaleOrderDO::getId,SaleOrderDO::getOrderCode, BaseDO::getDeleted);
|
||||
lambdaQueryWrapper.select(SaleOrderDO::getId, SaleOrderDO::getOrderCode, BaseDO::getDeleted);
|
||||
lambdaQueryWrapper.eq(SaleOrderDO::getOrderCode, code);
|
||||
lambdaQueryWrapper.eq(SaleOrderDO::getDeleted,false);
|
||||
lambdaQueryWrapper.eq(SaleOrderDO::getDeleted, false);
|
||||
List<SaleOrderDO> dos = saleOrderMapper.selectList(lambdaQueryWrapper);
|
||||
if(FuncUtil.isEmpty(id) && FuncUtil.isNotEmpty(dos)){
|
||||
if (FuncUtil.isEmpty(id) && FuncUtil.isNotEmpty(dos)) {
|
||||
throw exception(GlobalErrorCodeConstants.DATA_DUPLICATE);
|
||||
}
|
||||
if (FuncUtil.isNotEmpty(id) && FuncUtil.isNotEmpty(dos)) {
|
||||
for (SaleOrderDO aDo : dos) {
|
||||
// 出现重复并当前id 不一致
|
||||
if(!FuncUtil.equals(aDo.getId(), id)){
|
||||
if (!FuncUtil.equals(aDo.getId(), id)) {
|
||||
throw exception(GlobalErrorCodeConstants.DATA_DUPLICATE);
|
||||
}
|
||||
}
|
||||
|
|
@ -812,44 +825,45 @@ public class SaleOrderServiceImpl implements SaleOrderService {
|
|||
}
|
||||
|
||||
|
||||
private void checkSaleContractCode2(Long id, String code){
|
||||
if(FuncUtil.isNotEmpty(code)){
|
||||
private void checkSaleContractCode2(Long id, String code) {
|
||||
if (FuncUtil.isNotEmpty(code)) {
|
||||
LambdaQueryWrapper<SaleContractDO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.select(SaleContractDO::getId,SaleContractDO::getBillno, BaseDO::getDeleted);
|
||||
lambdaQueryWrapper.select(SaleContractDO::getId, SaleContractDO::getBillno, BaseDO::getDeleted);
|
||||
lambdaQueryWrapper.eq(SaleContractDO::getBillno, code);
|
||||
lambdaQueryWrapper.eq(SaleContractDO::getDeleted,false);
|
||||
lambdaQueryWrapper.eq(SaleContractDO::getDeleted, false);
|
||||
List<SaleContractDO> dos = saleContractMapper.selectList(lambdaQueryWrapper);
|
||||
if(FuncUtil.isEmpty(id) && FuncUtil.isNotEmpty(dos)){
|
||||
if (FuncUtil.isEmpty(id) && FuncUtil.isNotEmpty(dos)) {
|
||||
throw exception(GlobalErrorCodeConstants.DATA_DUPLICATE);
|
||||
}
|
||||
if (FuncUtil.isNotEmpty(id) && FuncUtil.isNotEmpty(dos)) {
|
||||
for (SaleContractDO aDo : dos) {
|
||||
// 出现重复并当前id 不一致
|
||||
if(!FuncUtil.equals(aDo.getId(), id)){
|
||||
if (!FuncUtil.equals(aDo.getId(), id)) {
|
||||
throw exception(GlobalErrorCodeConstants.DATA_DUPLICATE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private SaleOrderDO wrapperEntity(SaleOrderDO order,CreateSaleOrderDTO dto){
|
||||
|
||||
private SaleOrderDO wrapperEntity(SaleOrderDO order, CreateSaleOrderDTO dto) {
|
||||
// 客户信息
|
||||
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||
AssertUtil.isEmpty(loginUser,"登录信息已过期,请重新登录");
|
||||
AssertUtil.isEmpty(loginUser, "登录信息已过期,请重新登录");
|
||||
CustomerDO customer = customerService.getCustomerByUserId(loginUser.getId());
|
||||
AssertUtil.isEmpty(customer,"客户信息不存在");
|
||||
AssertUtil.isEmpty(customer, "客户信息不存在");
|
||||
|
||||
order.setCustomerId(customer.getId());
|
||||
if(FuncUtil.isEmpty(order.getId())){
|
||||
if (FuncUtil.isEmpty(order.getId())) {
|
||||
order.setId(FuncUtil.getNextId());
|
||||
}
|
||||
order.setBizdate(LocalDateTime.now());
|
||||
order.setPlansenddate( FuncUtil.timeToLocalDate(dto.getPlansenddate()));
|
||||
order.setPlansenddate(FuncUtil.timeToLocalDate(dto.getPlansenddate()));
|
||||
// 设置订单状态
|
||||
order.setOrderStatus(SaleOrderStatusEnum.YXD.getValue());
|
||||
order.setBillStatus(BillStatusEnum.SUBMIT.getValue());
|
||||
String orderType = order.getOrderType();
|
||||
if(FuncUtil.isEmpty(orderType)){
|
||||
if (FuncUtil.isEmpty(orderType)) {
|
||||
order.setOrderType(SaleOrderTypeEnum.NORMAL.getType());
|
||||
}
|
||||
order.setBillno(getNewOrderCode());
|
||||
|
|
@ -869,7 +883,7 @@ public class SaleOrderServiceImpl implements SaleOrderService {
|
|||
LocalDateTime beginTime = LocalDateTimeUtil.beginOfDay(beginDate);
|
||||
LocalDateTime endTime = LocalDateTimeUtil.endOfDay(endDate);
|
||||
return saleOrderMapper.selectOrderQtySummaryByOrderStatusAndCreateTimeBetween(
|
||||
null, beginTime, endTime,customerId);
|
||||
null, beginTime, endTime, customerId);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -890,10 +904,10 @@ public class SaleOrderServiceImpl implements SaleOrderService {
|
|||
BigDecimal price = saleOrderEntryDO.getPrice();
|
||||
Integer qty = saleOrderEntryDO.getQty();
|
||||
BigDecimal discount = saleOrderEntryDO.getDiscount();
|
||||
if(price!=null){
|
||||
if(discount!=null){
|
||||
if (price != null) {
|
||||
if (discount != null) {
|
||||
saleOrderEntryDO.setAmount(price.multiply(BigDecimal.valueOf(qty)).multiply(discount));
|
||||
}else {
|
||||
} else {
|
||||
saleOrderEntryDO.setAmount(price.multiply(BigDecimal.valueOf(qty)));
|
||||
}
|
||||
amount = amount.add(saleOrderEntryDO.getAmount());
|
||||
|
|
@ -909,7 +923,7 @@ public class SaleOrderServiceImpl implements SaleOrderService {
|
|||
|
||||
private void updateSaleOrderEntryList(Long parentId, List<SaleOrderEntryDO> list) {
|
||||
deleteSaleOrderEntryByParentId(parentId);
|
||||
list.forEach(o -> o.setId(null).setUpdater(null).setUpdateTime(null)); // 解决更新情况下:1)id 冲突;2)updateTime 不更新
|
||||
list.forEach(o -> o.setId(null).setUpdater(null).setUpdateTime(null)); // 解决更新情况下:1)id 冲突;2)updateTime 不更新
|
||||
createSaleOrderEntryList(parentId, list);
|
||||
}
|
||||
|
||||
|
|
@ -921,14 +935,14 @@ public class SaleOrderServiceImpl implements SaleOrderService {
|
|||
/**
|
||||
* 更新客户发票数据
|
||||
*/
|
||||
private void updateCustomerInvoiceData(SaleOrderDO order){
|
||||
private void updateCustomerInvoiceData(SaleOrderDO order) {
|
||||
String invoiceCode = order.getInvoiceCode();
|
||||
String invoiceName = order.getInvoiceName();
|
||||
String invoiceAddress = order.getInvoiceAddress();
|
||||
Long customerId = order.getCustomerId();
|
||||
if(customerId!=null){
|
||||
if (customerId != null) {
|
||||
CustomerDO customer = customerService.getCustomer(customerId);
|
||||
if(customer!=null){
|
||||
if (customer != null) {
|
||||
customer.setInvoiceCode(invoiceCode);
|
||||
customer.setInvoiceName(invoiceName);
|
||||
customer.setInvoiceAddress(invoiceAddress);
|
||||
|
|
@ -938,18 +952,18 @@ public class SaleOrderServiceImpl implements SaleOrderService {
|
|||
}
|
||||
|
||||
|
||||
private Long generateSaleContract(SaleOrderDO saleOrder, List<SaleOrderEntryDO> entrys){
|
||||
private Long generateSaleContract(SaleOrderDO saleOrder, List<SaleOrderEntryDO> entrys) {
|
||||
SaleContractSaveReqVO saveReqVO = toSaleContractVO(saleOrder, entrys);
|
||||
return saleContractService.createSaleContract(saveReqVO);
|
||||
}
|
||||
|
||||
|
||||
private SaleContractSaveReqVO toSaleContractVO(SaleOrderDO saleOrder, List<SaleOrderEntryDO> entrys){
|
||||
private SaleContractSaveReqVO toSaleContractVO(SaleOrderDO saleOrder, List<SaleOrderEntryDO> entrys) {
|
||||
CustomerDO customer = customerService.getCustomer(saleOrder.getCustomerId());
|
||||
SaleContractSaveReqVO saveReqVO = new SaleContractSaveReqVO();
|
||||
// 优先使用销售订单合同号
|
||||
String billno = saleOrder.getContractCode();
|
||||
if(FuncUtil.isEmpty(billno)){
|
||||
if (FuncUtil.isEmpty(billno)) {
|
||||
billno = getNewContractCode2();
|
||||
}
|
||||
saveReqVO.setBillno(billno);
|
||||
|
|
@ -991,11 +1005,29 @@ public class SaleOrderServiceImpl implements SaleOrderService {
|
|||
|
||||
@Override
|
||||
public List<SaleOrderFollowerUserVO> queryFollowerUserListByBrandId(String brandId) {
|
||||
// TODO 查询品牌下的所有跟单人员
|
||||
List<SaleOrderFollowerUserVO> res = new ArrayList<>();
|
||||
LambdaQueryWrapper<UserBrandDO> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(UserBrandDO::getBrandId, brandId);
|
||||
queryWrapper.eq(UserBrandDO::getDeleted, false);
|
||||
List<UserBrandDO> userBrandDOS = userBrandMapper.selectList(queryWrapper);
|
||||
for (UserBrandDO brandDO : userBrandDOS) {
|
||||
SaleOrderFollowerUserVO userVO = new SaleOrderFollowerUserVO();
|
||||
|
||||
AdminUserDO user = adminUserService.getUser(brandDO.getUserId());
|
||||
String userNane = "";
|
||||
if (FuncUtil.isEmpty(user) || user.getDeleted()) {
|
||||
continue;
|
||||
}
|
||||
userNane = user.getUsername();
|
||||
userVO.setId(brandDO.getUserId());
|
||||
userVO.setUsername(userNane);
|
||||
res.add(userVO);
|
||||
}
|
||||
if (FuncUtil.isEmpty(res)) {
|
||||
// 设置管理为跟单员
|
||||
res.add(new SaleOrderFollowerUserVO().setId(1L).setUsername("admin"));
|
||||
}
|
||||
|
||||
// 测试数据
|
||||
res.add(new SaleOrderFollowerUserVO().setId(1L).setUsername("admin"));
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
@ -1005,7 +1037,7 @@ public class SaleOrderServiceImpl implements SaleOrderService {
|
|||
CreateSaleOrderDTO res = new CreateSaleOrderDTO();
|
||||
SaleOrderDO saleOrderDO = checkEditOrder(id);
|
||||
BeanUtil.copyProperties(saleOrderDO, res);
|
||||
LambdaQueryWrapper<SaleOrderEntryDO> entryQueryWrapper = new LambdaQueryWrapper<>();
|
||||
LambdaQueryWrapper<SaleOrderEntryDO> entryQueryWrapper = new LambdaQueryWrapper<>();
|
||||
entryQueryWrapper.eq(SaleOrderEntryDO::getParentId, saleOrderDO.getId());
|
||||
entryQueryWrapper.eq(SaleOrderEntryDO::getDeleted, false);
|
||||
List<SaleOrderEntryDO> entryDOS = saleOrderEntryMapper.selectList(entryQueryWrapper);
|
||||
|
|
@ -1032,7 +1064,7 @@ public class SaleOrderServiceImpl implements SaleOrderService {
|
|||
// unit: row.unit || 'pcs',
|
||||
|
||||
// sku list
|
||||
LambdaQueryWrapper<SaleOrderSkuDO> skuWrapper = new LambdaQueryWrapper<>();
|
||||
LambdaQueryWrapper<SaleOrderSkuDO> skuWrapper = new LambdaQueryWrapper<>();
|
||||
skuWrapper.eq(SaleOrderSkuDO::getSaleOrderId, saleOrderDO.getId());
|
||||
skuWrapper.eq(SaleOrderSkuDO::getDeleted, false);
|
||||
List<SaleOrderSkuDO> sukList = skuOrderSkuMapper.selectList(skuWrapper);
|
||||
|
|
@ -1067,7 +1099,7 @@ public class SaleOrderServiceImpl implements SaleOrderService {
|
|||
toClient = new BufferedOutputStream(response.getOutputStream());
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(file.getName(),"UTF-8"));
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(file.getName(), "UTF-8"));
|
||||
toClient.write(buffer);
|
||||
toClient.flush();
|
||||
} catch (Exception e) {
|
||||
|
|
@ -1085,7 +1117,7 @@ public class SaleOrderServiceImpl implements SaleOrderService {
|
|||
}
|
||||
}
|
||||
|
||||
private SaleOrderDO checkEditOrder(Long id){
|
||||
private SaleOrderDO checkEditOrder(Long id) {
|
||||
SaleOrderDO saleOrderDO = saleOrderMapper.selectById(id);
|
||||
AssertUtil.isEmpty(saleOrderDO, "订单不存在");
|
||||
String billStatus = saleOrderDO.getBillStatus();
|
||||
|
|
@ -1093,7 +1125,7 @@ public class SaleOrderServiceImpl implements SaleOrderService {
|
|||
boolean order1 = BillStatusEnum.isCanEditOrder(billStatus);
|
||||
BillStatusEnum byValue = BillStatusEnum.getByValue(billStatus);
|
||||
AssertUtil.isEmpty(byValue, "订单状态异常");
|
||||
AssertUtil.isTrue(!order1,byValue.getName()+"状态不允许修改" );
|
||||
AssertUtil.isTrue(!order1, byValue.getName() + "状态不允许修改");
|
||||
return saleOrderDO;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
package cn.hangtag.module.system.service.user;
|
||||
|
||||
import cn.hangtag.framework.common.util.FuncUtil;
|
||||
import cn.hangtag.module.system.dal.dataobject.brand.UserBrandDO;
|
||||
import cn.hangtag.module.system.dal.mysql.brand.UserBrandMapper;
|
||||
import cn.hutool.cache.CacheUtil;
|
||||
import cn.hutool.cache.impl.LFUCache;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
|
|
@ -11,7 +14,6 @@ import cn.hangtag.framework.common.exception.ServiceException;
|
|||
import cn.hangtag.framework.common.pojo.PageResult;
|
||||
import cn.hangtag.framework.common.util.collection.CollectionUtils;
|
||||
import cn.hangtag.framework.common.util.object.BeanUtils;
|
||||
import cn.hangtag.framework.datapermission.core.util.DataPermissionUtils;
|
||||
import cn.hangtag.module.infra.api.file.FileApi;
|
||||
import cn.hangtag.module.system.controller.admin.user.vo.profile.UserProfileUpdatePasswordReqVO;
|
||||
import cn.hangtag.module.system.controller.admin.user.vo.profile.UserProfileUpdateReqVO;
|
||||
|
|
@ -84,6 +86,8 @@ public class AdminUserServiceImpl implements AdminUserService {
|
|||
@Resource
|
||||
private FileApi fileApi;
|
||||
|
||||
private static final LFUCache<Long, AdminUserDO> ADMIN_USERS_CACHE = CacheUtil.newLFUCache(500,1000*60*60*24L);
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@LogRecord(type = SYSTEM_USER_TYPE, subType = SYSTEM_USER_CREATE_SUB_TYPE, bizNo = "{{#user.id}}",
|
||||
|
|
@ -261,6 +265,7 @@ public class AdminUserServiceImpl implements AdminUserService {
|
|||
|
||||
// 3. 记录操作日志上下文
|
||||
LogRecordContext.putVariable("user", user);
|
||||
ADMIN_USERS_CACHE.remove(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -280,7 +285,12 @@ public class AdminUserServiceImpl implements AdminUserService {
|
|||
|
||||
@Override
|
||||
public AdminUserDO getUser(Long id) {
|
||||
return userMapper.selectById(id);
|
||||
AdminUserDO adminUserDO = ADMIN_USERS_CACHE.get(id);
|
||||
if(FuncUtil.isEmpty(adminUserDO)){
|
||||
adminUserDO = userMapper.selectById(id);
|
||||
ADMIN_USERS_CACHE.put(id,adminUserDO);
|
||||
}
|
||||
return adminUserDO;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
v-loading="formLoading"
|
||||
>
|
||||
<el-tabs v-model="activeName" @tab-change="changTab">
|
||||
<el-tab-pane label="基本信息" name="base" >
|
||||
<el-tab-pane label="基本信息" name="base">
|
||||
<el-row>
|
||||
<el-col :span="12" :xs="24">
|
||||
<el-form-item label="产品编码" prop="code">
|
||||
|
|
@ -67,12 +67,12 @@
|
|||
<el-row>
|
||||
<el-col :span="12" :xs="24">
|
||||
<el-form-item label="宽(mm)" prop="specSizeWidth">
|
||||
<el-input-number :min="0" :precision="2" v-model="formData.specSizeWidth" />
|
||||
<el-input-number :min="0" :precision="2" v-model="formData.specSizeWidth"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12" :xs="24">
|
||||
<el-form-item label="高(mm)" prop="specSizeHeight">
|
||||
<el-input-number :min="0" :precision="2" v-model="formData.specSizeHeight" />
|
||||
<el-input-number :min="0" :precision="2" v-model="formData.specSizeHeight"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
|
|
@ -81,12 +81,13 @@
|
|||
<el-row>
|
||||
<el-col :span="12" :xs="24">
|
||||
<el-form-item label="材质说明" prop="specMaterial">
|
||||
<el-input name="auto_specMaterial" autocomplete="on" v-model="formData.specMaterial" />
|
||||
<el-input name="auto_specMaterial" autocomplete="on"
|
||||
v-model="formData.specMaterial"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12" :xs="24">
|
||||
<el-form-item label="厚度(mm)" prop="specSizeThk">
|
||||
<el-input-number :min="0" :precision="2" v-model="formData.specSizeThk" />
|
||||
<el-input-number :min="0" :precision="2" v-model="formData.specSizeThk"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
|
@ -105,7 +106,8 @@
|
|||
</el-col>
|
||||
|
||||
</el-row>
|
||||
<el-form-item label="关联设计稿" v-if="formData.templateType === '1'" prop="draftDesignDataId">
|
||||
<el-form-item label="关联设计稿" v-if="formData.templateType === '1'"
|
||||
prop="draftDesignDataId">
|
||||
<div style="width: calc(100% - 20px);">
|
||||
<el-button @click="addRow">添加</el-button>
|
||||
<el-scrollbar max-height="400px">
|
||||
|
|
@ -149,7 +151,9 @@
|
|||
</div>
|
||||
</template>
|
||||
<template #default="scope">
|
||||
<el-input name="auto_input@draftDesignList_label" autocomplete="on" clearable v-model="scope.row.label" placeholder="请输入风格主色名称"/>
|
||||
<el-input name="auto_input@draftDesignList_label" autocomplete="on"
|
||||
clearable v-model="scope.row.label"
|
||||
placeholder="请输入风格主色名称"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="remark">
|
||||
|
|
@ -162,10 +166,10 @@
|
|||
<el-input clearable v-model="scope.row.remark" placeholder="备注说明"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="80">
|
||||
<el-table-column label="操作" width="80">
|
||||
<template #default="{$index}">
|
||||
<el-button size="small" type="danger" @click="removeRow($index) ">
|
||||
<Icon icon="ep:delete" />
|
||||
<Icon icon="ep:delete"/>
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
|
@ -194,7 +198,7 @@
|
|||
</div>
|
||||
</template>
|
||||
<template #default="scope">
|
||||
<el-input-number :min="1" v-model="scope.row.step" />
|
||||
<el-input-number :min="1" v-model="scope.row.step"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="name" width="280">
|
||||
|
|
@ -207,12 +211,12 @@
|
|||
<template #default="scope">
|
||||
<div
|
||||
:class="{ 'duplicate-tips' : duplicateInfoCheck(scope.row.name)}">
|
||||
<el-input v-model="scope.row.name" placeholder="请输入名称"/>
|
||||
<el-input v-model="scope.row.name" placeholder="请输入名称"/>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column prop="remark" >
|
||||
<el-table-column prop="remark">
|
||||
<template #header>
|
||||
<div>
|
||||
<span class="color-red">*</span>
|
||||
|
|
@ -220,10 +224,11 @@
|
|||
</div>
|
||||
</template>
|
||||
<template #default="scope">
|
||||
<el-input type="textarea" rows="1" v-model="scope.row.remark" placeholder="请输入工艺说明"/>
|
||||
<el-input type="textarea" rows="1" v-model="scope.row.remark"
|
||||
placeholder="请输入工艺说明"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="80">
|
||||
<el-table-column label="操作" width="80">
|
||||
<template #default="{$index}">
|
||||
<el-button size="small" type="danger" @click="removeInfoRow($index) ">删除
|
||||
</el-button>
|
||||
|
|
@ -306,8 +311,8 @@ const that = reactive({
|
|||
processInfoList: [{
|
||||
key: Math.random().toString(36).substring(2, 6),
|
||||
id: null, // id
|
||||
name: "" ,// 名称
|
||||
remark: "" ,// 说明
|
||||
name: "",// 名称
|
||||
remark: "",// 说明
|
||||
step: 1, // 工序
|
||||
productInfoId: null // 产品id oms_product_info
|
||||
}]
|
||||
|
|
@ -315,7 +320,7 @@ const that = reactive({
|
|||
const addRow = () => {
|
||||
that.draftDesignList.push({
|
||||
remark: '',
|
||||
label: '默认'+Math.random().toString(36).substring(2, 5),
|
||||
label: '默认' + Math.random().toString(36).substring(2, 5),
|
||||
id: ''
|
||||
})
|
||||
}
|
||||
|
|
@ -330,13 +335,13 @@ const removeRow = (index) => {
|
|||
const removeInfoRow = (index: number) => {
|
||||
if (that.processInfoList.length >= 1) {
|
||||
//@ts-ignore
|
||||
const tmp = that.processInfoList[index];
|
||||
if(tmp.id){
|
||||
message.confirm('确定删除吗?').then(()=>{
|
||||
const tmp = that.processInfoList[index];
|
||||
if (tmp.id) {
|
||||
message.confirm('确定删除吗?').then(() => {
|
||||
ProductProcessApi.deleteProductProcess(tmp.id)
|
||||
that.processInfoList.splice(index, 1)
|
||||
})
|
||||
}else {
|
||||
} else {
|
||||
that.processInfoList.splice(index, 1)
|
||||
}
|
||||
|
||||
|
|
@ -375,6 +380,10 @@ const formRef = ref() // 表单 Ref
|
|||
const open = async (type: string, id?: number) => {
|
||||
dialogVisible.value = true
|
||||
type = type ? type : 'create'
|
||||
let isCopy = type === 'copy'
|
||||
if (isCopy) {
|
||||
type = 'create'
|
||||
}
|
||||
dialogTitle.value = t('action.' + type)
|
||||
formType.value = type
|
||||
that.brandId = route.query.brandId
|
||||
|
|
@ -385,6 +394,11 @@ const open = async (type: string, id?: number) => {
|
|||
try {
|
||||
formData.value = await ProductInfoApi.getProductInfo(id)
|
||||
that.draftDesignList = JSON.parse(formData.value.draftDesignList || '[]')
|
||||
if (isCopy) {
|
||||
formData.value.id = null
|
||||
formData.value.code = null
|
||||
formData.value.cover = null
|
||||
}
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
|
|
@ -402,9 +416,9 @@ const submitCheck = () => {
|
|||
message.error('请完善表单信息')
|
||||
})
|
||||
}
|
||||
const changTab = (tab)=>{
|
||||
const changTab = (tab) => {
|
||||
console.log(tab)
|
||||
if(tab === 'processInfo' && formData.value.id){
|
||||
if (tab === 'processInfo' && formData.value.id) {
|
||||
that.updateProcess = true;
|
||||
// 查询工艺流程
|
||||
ProductProcessApi.getProductProcessPage({
|
||||
|
|
@ -425,54 +439,58 @@ const submitForm = async () => {
|
|||
// 校验关联设计稿
|
||||
let countInfo = {};
|
||||
let ids = [];
|
||||
for (let i = 0; i < that.draftDesignList.length; i++) {
|
||||
const id = that.draftDesignList[i].id
|
||||
const l = that.draftDesignList[i].label
|
||||
if (!id) {
|
||||
message.error(`第${i + 1}行设计稿不能为空`)
|
||||
return;
|
||||
// 有模板才校验稿件
|
||||
if (`${formData.value.templateType}` === '1') {
|
||||
for (let i = 0; i < that.draftDesignList.length; i++) {
|
||||
const id = that.draftDesignList[i].id
|
||||
const l = that.draftDesignList[i].label
|
||||
if (!id) {
|
||||
message.error(`第${i + 1}行设计稿不能为空`)
|
||||
return;
|
||||
}
|
||||
if (!l) {
|
||||
message.error(`第${i + 1}行风格名称不能为空`)
|
||||
return;
|
||||
}
|
||||
const key = `${id}_${l}`
|
||||
if (countInfo[key]) {
|
||||
message.error(`${l} 行重复`)
|
||||
return;
|
||||
}
|
||||
countInfo[key] = 1;
|
||||
ids.push(id);
|
||||
}
|
||||
if (!l) {
|
||||
message.error(`第${i + 1}行风格名称不能为空`)
|
||||
return;
|
||||
}
|
||||
const key = `${id}_${l}`
|
||||
if (countInfo[key]) {
|
||||
message.error(`${l} 行重复`)
|
||||
return;
|
||||
}
|
||||
countInfo[key] = 1;
|
||||
ids.push(id);
|
||||
}
|
||||
|
||||
|
||||
const data = formData.value;
|
||||
if ( that.updateProcess ) {
|
||||
// 校验工艺流程
|
||||
let countInfo2 = {};
|
||||
for (let i = 0; i < that.processInfoList.length; i++) {
|
||||
const name = that.processInfoList[i].name;
|
||||
const remark = that.processInfoList[i].remark
|
||||
if (!name) {
|
||||
message.error(`产品工艺-第${i + 1}行工艺名称不能为空`)
|
||||
return;
|
||||
}
|
||||
if (!remark) {
|
||||
message.error(`产品工艺-第${i + 1}行工艺说明不能为空`)
|
||||
return;
|
||||
}
|
||||
const key = `${name}`
|
||||
if (countInfo2[key]) {
|
||||
message.error(`产品工艺-第${i+1} 行工艺名称重复`)
|
||||
return;
|
||||
}
|
||||
countInfo2[key] = 1;
|
||||
if (that.updateProcess) {
|
||||
// 校验工艺流程
|
||||
let countInfo2 = {};
|
||||
for (let i = 0; i < that.processInfoList.length; i++) {
|
||||
const name = that.processInfoList[i].name;
|
||||
const remark = that.processInfoList[i].remark
|
||||
if (!name) {
|
||||
message.error(`产品工艺-第${i + 1}行工艺名称不能为空`)
|
||||
return;
|
||||
}
|
||||
data['productProcessList'] = that.processInfoList;
|
||||
if (!remark) {
|
||||
message.error(`产品工艺-第${i + 1}行工艺说明不能为空`)
|
||||
return;
|
||||
}
|
||||
const key = `${name}`
|
||||
if (countInfo2[key]) {
|
||||
message.error(`产品工艺-第${i + 1} 行工艺名称重复`)
|
||||
return;
|
||||
}
|
||||
countInfo2[key] = 1;
|
||||
}
|
||||
data['productProcessList'] = that.processInfoList;
|
||||
}
|
||||
|
||||
data.draftDesignList = JSON.stringify(that.draftDesignList)
|
||||
// 作为默认的设计稿
|
||||
if(ids.length > 0){
|
||||
if (ids.length > 0) {
|
||||
data.draftDesignDataId = ids.join(",");
|
||||
}
|
||||
if (formType.value === 'create') {
|
||||
|
|
@ -489,18 +507,18 @@ const submitForm = async () => {
|
|||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
const resetStep = ()=>{
|
||||
const resetStep = () => {
|
||||
for (let i = 0; i < that.processInfoList.length; i++) {
|
||||
that.processInfoList[i].step = i + 1;
|
||||
}
|
||||
|
||||
}
|
||||
const addProcessRow = () => {
|
||||
const addProcessRow = () => {
|
||||
that.processInfoList.push({
|
||||
key: Math.random().toString(36).substring(2, 6),
|
||||
id: null, // id
|
||||
name: "" ,// 名称
|
||||
remark: "" ,// 说明
|
||||
name: "",// 名称
|
||||
remark: "",// 说明
|
||||
step: that.processInfoList.length + 1, // 工序
|
||||
productInfoId: null // 产品id oms_product_info
|
||||
})
|
||||
|
|
@ -529,11 +547,11 @@ const resetForm = () => {
|
|||
templateType: '1',
|
||||
}
|
||||
that.draftDesignList = []
|
||||
that.processInfoList =[{
|
||||
that.processInfoList = [{
|
||||
key: Math.random().toString(36).substring(2, 6),
|
||||
id: null, // id
|
||||
name: "" ,// 名称
|
||||
remark: "" ,// 说明
|
||||
name: "",// 名称
|
||||
remark: "",// 说明
|
||||
step: 1, // 工序
|
||||
productInfoId: null // 产品id oms_product_info
|
||||
}]
|
||||
|
|
|
|||
|
|
@ -133,8 +133,16 @@
|
|||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" align="center" prop="remark"/>
|
||||
<el-table-column label="操作" width="200px" align="center">
|
||||
<el-table-column label="操作" width="240px" align="center">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
@click="openForm('copy', scope.row.id)"
|
||||
v-hasPermi="['oms:product-info:update']"
|
||||
>
|
||||
复制
|
||||
</el-button>
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
|
|
@ -143,7 +151,6 @@
|
|||
>
|
||||
编辑
|
||||
</el-button>
|
||||
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
|
|
@ -178,7 +185,6 @@
|
|||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import {dateFormatter} from '@/utils/formatTime'
|
||||
import download from '@/utils/download'
|
||||
import {ProductInfoApi, ProductInfoVO} from '@/api/oms/productinfo'
|
||||
import ProductInfoForm from './ProductInfoForm.vue'
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ const crudSchemas = reactive<CrudSchema[]>([
|
|||
label: 'id',
|
||||
field: 'id',
|
||||
isForm: false,
|
||||
isTable: false,
|
||||
},
|
||||
{
|
||||
label: '编码',
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ const crudSchemas = reactive<CrudSchema[]>([
|
|||
label: 'id',
|
||||
field: 'id',
|
||||
isForm: false,
|
||||
isTable:false
|
||||
},
|
||||
{
|
||||
label: '产品编码',
|
||||
|
|
|
|||
Loading…
Reference in New Issue