提交商户导入
This commit is contained in:
parent
5d2d44b268
commit
ade898b1eb
|
|
@ -38,6 +38,12 @@ public class WrkInfoStoreRecord extends BaseEntity {
|
|||
@TableField(value = "store_no")
|
||||
private String storeNo;
|
||||
|
||||
/**
|
||||
* 商户id
|
||||
*/
|
||||
@TableField(value = "store_id")
|
||||
private Long storeId;
|
||||
|
||||
/**
|
||||
* 商户名称
|
||||
*/
|
||||
|
|
@ -110,11 +116,6 @@ public class WrkInfoStoreRecord extends BaseEntity {
|
|||
@TableField(value = "ins_fre")
|
||||
private Integer insFre;
|
||||
|
||||
/**
|
||||
* 客户经理
|
||||
*/
|
||||
@TableField(value = "account_manager")
|
||||
private String accountManager;
|
||||
|
||||
/**
|
||||
* 经理电话
|
||||
|
|
|
|||
|
|
@ -38,17 +38,9 @@ public class WrkInfoTerminalRecord extends BaseEntity {
|
|||
@TableField(value = "terminal_id")
|
||||
private Long terminalId;
|
||||
|
||||
/**
|
||||
* 所属商户id
|
||||
*/
|
||||
@TableField(value = "store_id")
|
||||
private Long storeId;
|
||||
|
||||
/**
|
||||
* 所属商户编号
|
||||
*/
|
||||
@TableField(value = "store_no")
|
||||
private String storeNo;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 终端sn号
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public class DispatchQuery extends CommonParam {
|
|||
private Long userId;
|
||||
|
||||
/** 工单类型 */
|
||||
@NotNull(message = "必须指定工单类型")
|
||||
// @NotNull(message = "必须指定工单类型")
|
||||
@Range(min = 1, max = 50, message = "工单类型非法")
|
||||
private Integer workType;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,11 +4,15 @@ import cn.hutool.core.bean.BeanUtil;
|
|||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.db.DaoTemplate;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.chushang.common.core.constant.SecurityConstants;
|
||||
import com.chushang.common.core.util.StringUtils;
|
||||
import com.chushang.common.core.web.Result;
|
||||
import com.chushang.common.dict.feign.RemoteDictDataService;
|
||||
import com.chushang.common.mybatis.page.CommonParam;
|
||||
import com.chushang.common.mybatis.utils.PageResult;
|
||||
import com.chushang.common.mybatis.utils.WrapperUtils;
|
||||
|
|
@ -44,8 +48,14 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @auther: zhao
|
||||
|
|
@ -69,6 +79,10 @@ public class StoreImportServiceImpl extends ServiceImpl<StoreImportMapper, Store
|
|||
@Resource
|
||||
PollingTaskService pollingTaskService;
|
||||
|
||||
@Resource
|
||||
RemoteDictDataService remoteDictDataService;
|
||||
|
||||
|
||||
@Override
|
||||
public PageResult pageList(StoreImportQuery query, CommonParam commonParam) {
|
||||
LambdaQueryWrapper<StoreImport> queryWrapper = WrapperUtils.builder(query, commonParam);
|
||||
|
|
@ -80,33 +94,88 @@ public class StoreImportServiceImpl extends ServiceImpl<StoreImportMapper, Store
|
|||
return new PageResult(page);
|
||||
}
|
||||
|
||||
|
||||
Store genStoreEntity(StoreImportDTO storeImportDTO,Map<String, String> data){
|
||||
// 通过任务名称查询任务
|
||||
List<PollingTask> list = pollingTaskService.list(new LambdaQueryWrapper<PollingTask>().eq(PollingTask::getName, storeImportDTO.getTaskName()));
|
||||
if (CollectionUtil.isEmpty(list)){
|
||||
throw new RuntimeException("任务名称不存在");
|
||||
}
|
||||
PollingTask topTask = pollingTaskService.getTopTask(list.get(0).getId());
|
||||
Store store = new Store();
|
||||
store.setAccountManager(storeImportDTO.getAccountManager());
|
||||
store.setDelState(true);
|
||||
store.setAccountPhone(storeImportDTO.getAccountPhone());
|
||||
store.setLegalName(storeImportDTO.getLegalName());
|
||||
store.setSpecialNum(storeImportDTO.getSpecialNum());
|
||||
store.setShopName(storeImportDTO.getShopName());
|
||||
store.setProducts(storeImportDTO.getProducts());
|
||||
store.setTipTool(storeImportDTO.getTipTool());
|
||||
LocalDateTime registerTime = LocalDateTime.now();
|
||||
|
||||
Integer insFre = 0;
|
||||
try{
|
||||
insFre = Integer.valueOf(storeImportDTO.getInsFre());
|
||||
}catch (Exception e){
|
||||
insFre = -1;
|
||||
}
|
||||
|
||||
try{
|
||||
LocalDate registerDate = storeImportDTO.getRegisterTime();
|
||||
registerTime = LocalDateTime.of(registerDate, LocalTime.MIDNIGHT);
|
||||
}catch (Exception e){
|
||||
registerTime = LocalDateTime.now();
|
||||
}
|
||||
store.setInsFre(insFre);
|
||||
store.setStoreNo(storeImportDTO.getStoreNo());
|
||||
store.setStoreName(storeImportDTO.getStoreName());
|
||||
store.setStoreAddress(storeImportDTO.getStoreAddress());
|
||||
store.setStoreContact(storeImportDTO.getStoreContact());
|
||||
store.setStorePhone(storeImportDTO.getStorePhone());
|
||||
store.setStoreType(1);
|
||||
store.setRegisterTime(registerTime); // registertime
|
||||
store.setTaskId(topTask.getId());
|
||||
store.setDeptId(SecurityUtils.getDeptId());
|
||||
store.setLowerTaskId(list.get(0).getId());
|
||||
store.setStoreId(IdUtil.getSnowflake().nextId());
|
||||
return store;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int confimImport(List<StoreImportDTO> lists) {
|
||||
int i = 0;
|
||||
Result<Map<String, String>> storeType = remoteDictDataService.getInfo("store_type", SecurityConstants.INNER);
|
||||
Map<String, String> data = new HashMap<>();
|
||||
//todo 将返回的map一一对应
|
||||
if(storeType.isSuccess()){
|
||||
data = storeType.getData();
|
||||
}
|
||||
// 商户类型枚举
|
||||
for (StoreImportDTO storeImportDTO : lists) {
|
||||
i++;
|
||||
if (StringUtils.isBlank(storeImportDTO.getTaskName())) {
|
||||
throw new RuntimeException("任务名称不能为空");
|
||||
}
|
||||
|
||||
// 通过任务名称查询任务
|
||||
List<PollingTask> list = pollingTaskService.list(new LambdaQueryWrapper<PollingTask>().eq(PollingTask::getName, storeImportDTO.getTaskName()));
|
||||
if (CollectionUtil.isEmpty(list)){
|
||||
throw new RuntimeException("任务名称不存在");
|
||||
}
|
||||
PollingTask topTask = pollingTaskService.getTopTask(list.get(0).getId());
|
||||
StoreImport storeImport = BeanCopyUtils.copy(storeImportDTO, StoreImport.class);
|
||||
Store store = BeanCopyUtils.copy(storeImport, Store.class);
|
||||
store.setTaskId(topTask.getId());
|
||||
store.setDeptId(SecurityUtils.getDeptId());
|
||||
store.setLowerTaskId(list.get(0).getId());
|
||||
store.setStoreId(IdUtil.getSnowflake().nextId());
|
||||
Store store = genStoreEntity(storeImportDTO,data);
|
||||
storeMapper.insert(store);
|
||||
Terminal terminal = BeanCopyUtils.copy(storeImport, Terminal.class);
|
||||
Terminal terminal = new Terminal();
|
||||
terminal.setTerminalNo(storeImportDTO.getTerminalNo());
|
||||
terminal.setTerminalSn(storeImportDTO.getTerminalSn());
|
||||
terminal.setTerminalModel(storeImportDTO.getTerminalModel());
|
||||
terminal.setTerminalType(1);//storeImportDTO.getTerminalType()
|
||||
terminal.setTerminalVersion(storeImportDTO.getTerminalVersion());
|
||||
terminal.setTerminalSource(1);//storeImportDTO.getTerminalSource()
|
||||
terminal.setTerminalAddress(storeImportDTO.getTerminalAddress());
|
||||
terminal.setOccupy(0);
|
||||
terminal.setTerminalStatus(1);
|
||||
terminal.setStoreId(store.getStoreId());
|
||||
terminal.setLowerTaskId(store.getLowerTaskId());
|
||||
terminal.setTaskId(store.getTaskId());
|
||||
terminal.setDeptId(SecurityUtils.getDeptId());
|
||||
terminalMapper.insert(terminal);
|
||||
TerminalIns terminalIns = BeanCopyUtils.copy(storeImport, TerminalIns.class);
|
||||
TerminalIns terminalIns = new TerminalIns();//BeanCopyUtils.copy(storeImport, TerminalIns.class);
|
||||
terminalIns.setTerminalId(terminal.getTerminalId());
|
||||
terminalIns.setStoreId(store.getStoreId());
|
||||
terminalInsMapper.insert(terminalIns);
|
||||
|
|
|
|||
|
|
@ -534,6 +534,7 @@ public class WrkInfoServiceImpl extends ServiceImpl<WrkInfoMapper, WrkInfo> impl
|
|||
private WrkInfo makeWrkInfoEntity(DispatchDTO dispatch, DispatchQuery query, Long userId, String userName, Integer workMethod) {
|
||||
WrkInfo wrkInfo = new WrkInfo();
|
||||
wrkInfo.setTaskId(query.getTaskId());
|
||||
wrkInfo.setDeptId(SecurityUtils.getDeptId());
|
||||
wrkInfo.setUserId(userId);
|
||||
wrkInfo.setAccountPhone(dispatch.getAccountPhone());
|
||||
wrkInfo.setUserName(userName);
|
||||
|
|
@ -543,6 +544,8 @@ public class WrkInfoServiceImpl extends ServiceImpl<WrkInfoMapper, WrkInfo> impl
|
|||
wrkInfo.setWorkSort(query.getWorkSort());
|
||||
wrkInfo.setWrkStatus(1);
|
||||
wrkInfo.setWorkSource(query.getWorkSource());
|
||||
wrkInfo.setTaskId(dispatch.getTaskId());
|
||||
wrkInfo.setLowerTaskId(dispatch.getLowerTaskId());
|
||||
// 处理时间
|
||||
//wrkInfo.setDisposeTime(query.getEndTime());
|
||||
// 业务员名字和客户经理?
|
||||
|
|
@ -558,7 +561,7 @@ public class WrkInfoServiceImpl extends ServiceImpl<WrkInfoMapper, WrkInfo> impl
|
|||
if (result.isSuccess()) {
|
||||
Map<String, Long> userIds = result.getData();
|
||||
for (DispatchDTO dispatchDTO : dispatch) {
|
||||
Long userId = userIds.get(dispatchDTO.getAccountManager());
|
||||
Long userId = 1L;// 先固定 userIds.get(dispatchDTO.getAccountManager());
|
||||
Assert.notNull(userId, "【{}】未设置商户", dispatchDTO.getAccountManager());
|
||||
// 组装wrkinfo实体
|
||||
WrkInfo wrkInfo = makeWrkInfoEntity(dispatchDTO, query, userId, dispatchDTO.getAccountManager(), 0);
|
||||
|
|
@ -569,6 +572,7 @@ public class WrkInfoServiceImpl extends ServiceImpl<WrkInfoMapper, WrkInfo> impl
|
|||
wrkInfoTerminalRecordService.save(wrkInfoTerminalRecord);
|
||||
WrkInfoStoreRecord wrkInfoStoreRecord = BeanUtil.copyProperties(dispatchDTO, WrkInfoStoreRecord.class);
|
||||
wrkInfoStoreRecord.setWrkId(wrkInfo.getWrkId());
|
||||
wrkInfoStoreRecord.setStoreId(dispatchDTO.getStoreId());
|
||||
wrkInfoStoreRecordService.save(wrkInfoStoreRecord);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -179,48 +179,45 @@
|
|||
</select>
|
||||
|
||||
<select id="getStoreByTasKIdOrIds" resultType="com.chushang.inspection.work.dto.DispatchDTO">
|
||||
select t1.terminal_id,
|
||||
t1.terminal_sn,
|
||||
t1.terminal_no,
|
||||
t1.terminal_type,
|
||||
t1.terminal_model,
|
||||
t1.terminal_version,
|
||||
t1.terminal_address,
|
||||
t1.terminal_source,
|
||||
t1.terminal_source,
|
||||
t1.terminal_property,
|
||||
t2.store_no,
|
||||
t2.store_name,
|
||||
t2.store_contact,
|
||||
t2.store_phone,
|
||||
t2.store_address,
|
||||
t2.special_num,
|
||||
t2.shop_name,
|
||||
t2.store_type,
|
||||
t2.products,
|
||||
t2.tip_tool,
|
||||
t2.ins_fre,
|
||||
t2.register_address,
|
||||
t2.legal_name,
|
||||
t2.legal_name,
|
||||
t2.legal_name,
|
||||
t2.legal_name,
|
||||
t2.legal_name,
|
||||
t3.management_code,
|
||||
t3.geographic_location,
|
||||
t3.geographic_address
|
||||
select
|
||||
t1.terminal_id AS terminalId,
|
||||
t1.terminal_sn AS terminalSn,
|
||||
t1.terminal_no AS terminalNo,
|
||||
t1.terminal_type AS terminalType,
|
||||
t1.terminal_model AS terminalModel,
|
||||
t1.terminal_version AS terminalVersion,
|
||||
t1.terminal_address AS terminalAddress,
|
||||
t1.terminal_source AS terminalSource,
|
||||
t1.terminal_property AS terminalProperty,
|
||||
t2.store_no AS storeNo,
|
||||
t2.store_id AS storeId,
|
||||
t2.store_name AS storeName,
|
||||
t2.store_contact AS storeContact,
|
||||
t2.store_phone AS storePhone,
|
||||
t2.store_address AS storeAddress,
|
||||
t2.special_num AS specialNum,
|
||||
t2.shop_name AS shopName,
|
||||
t2.store_type AS storeType,
|
||||
t2.products AS products,
|
||||
t2.tip_tool AS tipTool,
|
||||
t2.ins_fre AS insFre,
|
||||
t2.task_id AS taskId,
|
||||
t2.lower_task_id AS lowerTaskId,
|
||||
t2.register_address AS registerAddress,
|
||||
t2.legal_name AS legalName,
|
||||
t2.account_manager AS accountManager,
|
||||
t3.management_code AS managementCode,
|
||||
t3.geographic_location AS geographicLocation,
|
||||
t3.geographic_address AS geographicAddress
|
||||
from st_terminal t1
|
||||
left join st_store t2 on t1.store_id = t2.store_id
|
||||
left join st_terminal_ins t3 on t3.terminal_id = t1.terminal_id
|
||||
|
||||
<where>
|
||||
<if test="query.taskId != null">
|
||||
AND t.task_id = #{query.taskId}
|
||||
</if>
|
||||
<if test="1 == 1">
|
||||
${query.sqlParam.get('dataScope')}
|
||||
AND t1.task_id = #{query.taskId}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY t.create_time DESC
|
||||
ORDER BY t1.create_time DESC limit 10
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue