Merge branch 'master' of http://git.unissense.tech/mula/unis_sip
commit
6a62d079d5
|
@ -59,4 +59,6 @@ public interface AgentInfoMapper
|
|||
*/
|
||||
public int deleteAgentInfoByIds(String[] ids);
|
||||
public int selectCountByCode(AgentInfo agentInfo);
|
||||
|
||||
AgentInfo selectAgentInfoByCode(String agentCode);
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ public interface ProductInfoMapper
|
|||
* @return 产品管理集合
|
||||
*/
|
||||
public List<ProductInfo> selectProductInfoList(ProductInfo productInfo);
|
||||
public List<ProductInfo> selectProductInfoByCodeList(List<String> productCodeList);
|
||||
|
||||
/**
|
||||
* 新增产品管理
|
||||
|
|
|
@ -62,4 +62,6 @@ public interface ProjectOrderInfoMapper
|
|||
List<ProjectOrderInfo> selectProjectOrderInfoByProjectId(List<Long> projectId);
|
||||
|
||||
int selectMaxOrderCode(String province);
|
||||
|
||||
String selectAgentProvinceByProjectId(Long projectId);
|
||||
}
|
||||
|
|
|
@ -58,4 +58,6 @@ public interface IAgentInfoService
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteAgentInfoById(Long id);
|
||||
|
||||
AgentInfo selectAgentInfoByCode(String agentCode);
|
||||
}
|
||||
|
|
|
@ -63,4 +63,5 @@ public interface IProductInfoService
|
|||
public int deleteProductInfoById(Long id);
|
||||
|
||||
List<ProductInfo> query(MaintenanceRecordsDto dto);
|
||||
List<ProductInfo> selectProductInfoByCodeList(List<String> productCodeList);
|
||||
}
|
||||
|
|
|
@ -105,4 +105,10 @@ public class AgentInfoServiceImpl implements IAgentInfoService
|
|||
{
|
||||
return agentInfoMapper.deleteAgentInfoById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AgentInfo selectAgentInfoByCode(String agentCode) {
|
||||
|
||||
return agentInfoMapper.selectAgentInfoByCode(agentCode);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -319,7 +319,9 @@ public class OrderInfoServiceImpl implements IOrderInfoService
|
|||
throw new ServiceException("excel模板错误,导入失败");
|
||||
}
|
||||
//只处理当前产品表有的数据
|
||||
List<ProductInfo> productInfos = productInfoService.selectProductInfoList(new ProductInfo());
|
||||
// List<ProductInfo> productInfos = productInfoService.selectProductInfoList(new ProductInfo());
|
||||
List<String> codeList = orderListList.stream().map(OrderList::getProductCode).filter(StringUtils::isNotEmpty).collect(Collectors.toList());
|
||||
List<ProductInfo> productInfos = productInfoService.selectProductInfoByCodeList(codeList);
|
||||
Map<String, ProductInfo> productInfoMap = productInfos.stream().collect(Collectors.toMap(ProductInfo::getProductCode, Function.identity(), (v1, v2) -> v1));
|
||||
orderListList = orderListList.stream().filter(item -> item != null && StringUtils.isNotEmpty(item.getProductCode())
|
||||
&& productInfoMap.containsKey(item.getProductCode()))
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package com.ruoyi.sip.service.impl;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.ShiroUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
|
@ -114,4 +116,12 @@ public class ProductInfoServiceImpl implements IProductInfoService
|
|||
}
|
||||
return productInfoMapper.query(dto);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProductInfo> selectProductInfoByCodeList(List<String> productCodeList) {
|
||||
if (CollUtil.isEmpty(productCodeList)){
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return productInfoMapper.selectProductInfoByCodeList(productCodeList);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.Period;
|
||||
import java.time.ZoneId;
|
||||
|
@ -241,8 +242,9 @@ public class ProjectInfoServiceImpl implements IProjectInfoService {
|
|||
logIndex = compareField(logContent, logIndex, "代理商", oldProjectInfo.getPartnerName(), projectInfo.getPartnerName());
|
||||
logIndex = compareField(logContent, logIndex, "联系方式", oldProjectInfo.getContactWay(), projectInfo.getContactWay());
|
||||
logIndex = compareBigDecimalField(logContent, logIndex, "预计金额", oldProjectInfo.getEstimatedAmount(), projectInfo.getEstimatedAmount());
|
||||
logIndex = compareField(logContent, logIndex, "预计下单时间", oldProjectInfo.getEstimatedOrderTime(), projectInfo.getEstimatedOrderTime());
|
||||
logIndex = compareField(logContent, logIndex, "预计发货时间", oldProjectInfo.getEstimatedDeliverTime(), projectInfo.getEstimatedDeliverTime());
|
||||
logIndex = compareField(logContent, logIndex, "预计下单时间", formatterDate(oldProjectInfo.getEstimatedOrderTime()),
|
||||
formatterDate(projectInfo.getEstimatedOrderTime()));
|
||||
logIndex = compareField(logContent, logIndex, "预计发货时间", formatterDate(oldProjectInfo.getEstimatedDeliverTime()), formatterDate(projectInfo.getEstimatedDeliverTime()));
|
||||
logIndex = compareField(logContent, logIndex, "竞争对手", oldProjectInfo.getCompetitor(), projectInfo.getCompetitor());
|
||||
logIndex = compareField(logContent, logIndex, "关键技术问题", oldProjectInfo.getKeyProblem(), projectInfo.getKeyProblem());
|
||||
logIndex = compareField(logContent, logIndex, "项目简述", oldProjectInfo.getProjectDesc(), projectInfo.getProjectDesc());
|
||||
|
@ -297,6 +299,12 @@ public class ProjectInfoServiceImpl implements IProjectInfoService {
|
|||
}
|
||||
}
|
||||
|
||||
private String formatterDate(Date date) {
|
||||
if (date == null) {
|
||||
return null;
|
||||
}
|
||||
return DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, date);
|
||||
}
|
||||
/**
|
||||
* 比较产品信息列表并生成日志内容
|
||||
*
|
||||
|
@ -323,11 +331,11 @@ public class ProjectInfoServiceImpl implements IProjectInfoService {
|
|||
|
||||
if (oldProduct == null && newProduct != null) {
|
||||
// 新增产品
|
||||
logContent.append(index).append(".").append(type).append("新增:").append(newProduct.getProductBomCode()).append("\n");
|
||||
logContent.append(index).append(".").append(type).append("新增:").append(StringUtils.isEmpty(newProduct.getProductBomCode()) ? "空" : newProduct.getProductBomCode()).append("\n");
|
||||
index++;
|
||||
} else if (oldProduct != null && newProduct == null) {
|
||||
// 删除产品
|
||||
logContent.append(index).append(".").append(type).append("删除:").append(oldProduct.getProductBomCode()).append("\n");
|
||||
logContent.append(index).append(".").append(type).append("删除:").append(StringUtils.isEmpty(oldProduct.getProductBomCode()) ? "空" : oldProduct.getProductBomCode()).append("\n");
|
||||
index++;
|
||||
} else if (oldProduct != null) {
|
||||
// 变更产品
|
||||
|
|
|
@ -10,6 +10,7 @@ import cn.hutool.core.collection.CollUtil;
|
|||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.ShiroUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.sip.domain.*;
|
||||
import com.ruoyi.sip.service.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -34,6 +35,7 @@ public class ProjectOrderInfoServiceImpl implements IProjectOrderInfoService {
|
|||
private IProjectProductInfoService productInfoService;
|
||||
@Autowired
|
||||
private ICnareaService cnareaService;
|
||||
|
||||
/**
|
||||
* 查询订单管理
|
||||
*
|
||||
|
@ -80,8 +82,9 @@ public class ProjectOrderInfoServiceImpl implements IProjectOrderInfoService {
|
|||
*/
|
||||
@Override
|
||||
public int insertProjectOrderInfo(ProjectOrderInfo projectOrderInfo) {
|
||||
|
||||
// 生成订单编号
|
||||
String orderNumber = generateOrderNumber(projectOrderInfo.getProvince());
|
||||
String orderNumber = generateOrderNumber(projectOrderInfo.getProjectId());
|
||||
projectOrderInfo.setOrderCode(orderNumber);
|
||||
projectOrderInfo.setCreateTime(DateUtils.getNowDate());
|
||||
projectOrderInfo.setCreateBy(ShiroUtils.getUserId().toString());
|
||||
|
@ -111,7 +114,11 @@ public class ProjectOrderInfoServiceImpl implements IProjectOrderInfoService {
|
|||
* @param province 省份代码
|
||||
* @return 订单编号
|
||||
*/
|
||||
private String generateOrderNumber(String province) {
|
||||
private String generateOrderNumber(Long projectId) {
|
||||
String province = projectOrderInfoMapper.selectAgentProvinceByProjectId(projectId);
|
||||
if (StringUtils.isEmpty(province)) {
|
||||
throw new ServiceException("代表处所属省为空,无法生成订单编号");
|
||||
}
|
||||
// 获取当前时间,格式为yyyyMMdd
|
||||
String currentDate = DateUtils.dateTimeNow("yyyyMMdd");
|
||||
Cnarea cnarea = new Cnarea();
|
||||
|
@ -143,7 +150,7 @@ public class ProjectOrderInfoServiceImpl implements IProjectOrderInfoService {
|
|||
public int updateProjectOrderInfo(ProjectOrderInfo projectOrderInfo) {
|
||||
ProjectOrderInfo existProjectOrderInfo = projectOrderInfoMapper.selectProjectOrderInfoById(projectOrderInfo.getId());
|
||||
if (!existProjectOrderInfo.getProvince().equals(projectOrderInfo.getProvince())) {
|
||||
String orderNumber = generateOrderNumber(projectOrderInfo.getProvince());
|
||||
String orderNumber = generateOrderNumber(projectOrderInfo.getProjectId());
|
||||
projectOrderInfo.setOrderCode(orderNumber);
|
||||
}
|
||||
projectOrderInfo.setUpdateBy(ShiroUtils.getUserId().toString());
|
||||
|
|
|
@ -3,9 +3,14 @@ package com.ruoyi.sip.service.impl;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.StringJoiner;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.sip.domain.ProductInfo;
|
||||
import com.ruoyi.sip.service.IProductInfoService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.sip.mapper.ProjectProductInfoMapper;
|
||||
|
@ -23,6 +28,8 @@ import com.ruoyi.common.core.text.Convert;
|
|||
public class ProjectProductInfoServiceImpl implements IProjectProductInfoService {
|
||||
@Autowired
|
||||
private ProjectProductInfoMapper projectProductInfoMapper;
|
||||
@Autowired
|
||||
private IProductInfoService productInfoService;
|
||||
|
||||
/**
|
||||
* 查询项目产品信息
|
||||
|
@ -97,6 +104,21 @@ public class ProjectProductInfoServiceImpl implements IProjectProductInfoService
|
|||
|
||||
@Override
|
||||
public void saveBatch(List<ProjectProductInfo> list) {
|
||||
//校验数据是否在产品库中
|
||||
List<String> codeList = list.stream().map(ProjectProductInfo::getProductBomCode).distinct().collect(Collectors.toList());
|
||||
List<ProductInfo> productInfos = productInfoService.selectProductInfoByCodeList(codeList);
|
||||
Set<String> existsProductCodeMapSet = productInfos.stream().map(ProductInfo::getProductCode).collect(Collectors.toSet());
|
||||
StringJoiner stringJoiner = new StringJoiner(",");
|
||||
for (String code : codeList) {
|
||||
if (!existsProductCodeMapSet.contains(code)) {
|
||||
stringJoiner.add(code);
|
||||
}
|
||||
}
|
||||
if (stringJoiner.length() > 0) {
|
||||
throw new ServiceException(StringUtils.format("产品编码[{}]在产品库中未找到,请确认后重试", stringJoiner.toString()));
|
||||
}
|
||||
|
||||
|
||||
List<ProjectProductInfo> projectProductInfos = projectProductInfoMapper.selectProjectProductInfoListByProjectId(list.get(0).getProjectId());
|
||||
Set<Long> idSet = list.stream().map(ProjectProductInfo::getId).collect(Collectors.toSet());
|
||||
String[] deleteIds = projectProductInfos.stream().filter(item -> !idSet.contains(item.getId())).map(item -> item.getId().toString()).toArray(String[]::new);
|
||||
|
|
|
@ -101,6 +101,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
|
||||
|
||||
|
||||
</select>
|
||||
<select id="selectAgentProvinceByProjectId" resultType="java.lang.String">
|
||||
select t2.province
|
||||
from project_info t1
|
||||
inner join agent_info t2 on t1.agent_code = t2.agent_code
|
||||
where t1.id = #{projectId}
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<insert id="insertProjectOrderInfo" parameterType="ProjectOrderInfo" useGeneratedKeys="true" keyProperty="id">
|
||||
|
|
|
@ -49,6 +49,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
where agent_code=#{agentCode} and status=0
|
||||
<if test="id != null">and id!=#{id}</if>
|
||||
</select>
|
||||
<select id="selectAgentInfoByCode" resultType="com.ruoyi.sip.domain.AgentInfo">
|
||||
<include refid="selectAgentInfoVo"/>
|
||||
where agent_code=#{agentCode}
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<insert id="insertAgentInfo" parameterType="AgentInfo" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into agent_info
|
||||
|
|
|
@ -38,6 +38,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<include refid="selectProductInfoVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
<select id="selectProductInfoByCodeList" resultMap="ProductInfoResult">
|
||||
<include refid="selectProductInfoVo"/>
|
||||
where product_code in
|
||||
<foreach item="item" index="index" collection="list"
|
||||
open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</select>
|
||||
<select id="listByProductCodeList" resultMap="ProductInfoResult">
|
||||
<include refid="selectProductInfoVo"/>
|
||||
where product_code in
|
||||
|
|
Loading…
Reference in New Issue