供应商和客户数据导出导入功能
This commit is contained in:
parent
653664a1e6
commit
cf81f9e636
@ -85,6 +85,8 @@ public class UserConstants
|
||||
/**
|
||||
* 各种业务单据的内定自动编码规则标识
|
||||
*/
|
||||
public static final String VENDOR_CODE = "VENDOR_CODE";
|
||||
public static final String CLIENT_CODE = "CLIENT_CODE";
|
||||
public static final String ITEM_TYPE_CODE ="ITEM_TYPE_CODE";
|
||||
public static final String ITEM_CODE ="ITEM_CODE";
|
||||
public static final String MACHINERY_TYPE_CODE="MACHINERY_TYPE_CODE";
|
||||
|
@ -4,6 +4,7 @@ import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.ktg.common.constant.UserConstants;
|
||||
import com.ktg.mes.md.domain.MdVendor;
|
||||
import com.ktg.mes.wm.utils.WmBarCodeUtil;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -23,6 +24,7 @@ import com.ktg.mes.md.domain.MdClient;
|
||||
import com.ktg.mes.md.service.IMdClientService;
|
||||
import com.ktg.common.utils.poi.ExcelUtil;
|
||||
import com.ktg.common.core.page.TableDataInfo;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* 客户Controller
|
||||
@ -64,6 +66,39 @@ public class MdClientController extends BaseController
|
||||
util.exportExcel(response, list, "客户数据");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 下载导入模板
|
||||
* @param response
|
||||
*/
|
||||
@PostMapping("/importTemplate")
|
||||
public void importTemplate(HttpServletResponse response)
|
||||
{
|
||||
ExcelUtil<MdClient> util = new ExcelUtil<MdClient>(MdClient.class);
|
||||
util.importTemplateExcel(response, "客户数据");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 从模板导入客户数据
|
||||
* @param file
|
||||
* @param updateSupport
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Log(title = "客户", businessType = BusinessType.IMPORT)
|
||||
@PreAuthorize("@ss.hasPermi('mes:md:client:import')")
|
||||
@PostMapping("/importData")
|
||||
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
|
||||
{
|
||||
ExcelUtil<MdClient> util = new ExcelUtil<MdClient>(MdClient.class);
|
||||
List<MdClient> clientList = util.importExcel(file.getInputStream());
|
||||
String operName = getUsername();
|
||||
String message = mdClientService.importClient(clientList,updateSupport,operName);
|
||||
return AjaxResult.success(message);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取客户详细信息
|
||||
*/
|
||||
@ -132,4 +167,8 @@ public class MdClientController extends BaseController
|
||||
{
|
||||
return toAjax(mdClientService.deleteMdClientByClientIds(clientIds));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -66,6 +66,10 @@ public class MdVendorController extends BaseController
|
||||
util.exportExcel(response, list, "供应商数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载导入模板
|
||||
* @param response
|
||||
*/
|
||||
@PostMapping("/importTemplate")
|
||||
public void importTemplate(HttpServletResponse response)
|
||||
{
|
||||
@ -74,8 +78,15 @@ public class MdVendorController extends BaseController
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 从模板导入供应商数据
|
||||
* @param file
|
||||
* @param updateSupport
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Log(title = "供应商", businessType = BusinessType.IMPORT)
|
||||
@PreAuthorize("@ss.hasPermi('system:user:import')")
|
||||
@PreAuthorize("@ss.hasPermi('mes:md:vendor:import')")
|
||||
@PostMapping("/importData")
|
||||
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
|
||||
{
|
||||
|
@ -39,11 +39,9 @@ public class MdClient extends BaseEntity
|
||||
private String clientDes;
|
||||
|
||||
/** 客户LOGO地址 */
|
||||
@Excel(name = "客户LOGO地址")
|
||||
private String clientLogo;
|
||||
|
||||
/** 客户类型 */
|
||||
@Excel(name = "客户类型")
|
||||
private String clientType;
|
||||
|
||||
/** 客户地址 */
|
||||
@ -91,11 +89,9 @@ public class MdClient extends BaseEntity
|
||||
private String creditCode;
|
||||
|
||||
/** 是否启用 */
|
||||
@Excel(name = "是否启用")
|
||||
private String enableFlag;
|
||||
|
||||
/** 预留字段1 */
|
||||
@Excel(name = "预留字段1")
|
||||
private String attr1;
|
||||
|
||||
/** 预留字段2 */
|
||||
|
@ -39,15 +39,12 @@ public class MdVendor extends BaseEntity
|
||||
private String vendorDes;
|
||||
|
||||
/** 供应商LOGO地址 */
|
||||
@Excel(name = "供应商LOGO地址")
|
||||
private String vendorLogo;
|
||||
|
||||
/** 供应商等级 */
|
||||
@Excel(name = "供应商等级")
|
||||
private String vendorLevel;
|
||||
|
||||
/** 供应商评分 */
|
||||
@Excel(name = "供应商评分")
|
||||
private Long vendorScore;
|
||||
|
||||
/** 供应商地址 */
|
||||
@ -95,7 +92,6 @@ public class MdVendor extends BaseEntity
|
||||
private String creditCode;
|
||||
|
||||
/** 是否启用 */
|
||||
@Excel(name = "是否启用")
|
||||
private String enableFlag;
|
||||
|
||||
/** 预留字段1 */
|
||||
|
@ -2,6 +2,7 @@ package com.ktg.mes.md.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ktg.mes.md.domain.MdClient;
|
||||
import com.ktg.mes.md.domain.MdVendor;
|
||||
|
||||
/**
|
||||
* 客户Service接口
|
||||
@ -64,4 +65,15 @@ public interface IMdClientService
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteMdClientByClientId(Long clientId);
|
||||
|
||||
|
||||
/**
|
||||
* 导入客户信息
|
||||
* @param clientList
|
||||
* @param isUpdateSupport
|
||||
* @param operName
|
||||
* @return
|
||||
*/
|
||||
public String importClient(List<MdClient> clientList, Boolean isUpdateSupport, String operName);
|
||||
|
||||
}
|
||||
|
@ -3,8 +3,12 @@ package com.ktg.mes.md.service.impl;
|
||||
import java.util.List;
|
||||
|
||||
import com.ktg.common.constant.UserConstants;
|
||||
import com.ktg.common.exception.ServiceException;
|
||||
import com.ktg.common.utils.DateUtils;
|
||||
import com.ktg.common.utils.StringUtils;
|
||||
import com.ktg.common.utils.bean.BeanValidators;
|
||||
import com.ktg.mes.wm.utils.WmBarCodeUtil;
|
||||
import com.ktg.system.strategy.AutoCodeUtil;
|
||||
import org.apache.catalina.User;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -12,6 +16,8 @@ import com.ktg.mes.md.mapper.MdClientMapper;
|
||||
import com.ktg.mes.md.domain.MdClient;
|
||||
import com.ktg.mes.md.service.IMdClientService;
|
||||
|
||||
import javax.validation.Validator;
|
||||
|
||||
/**
|
||||
* 客户Service业务层处理
|
||||
*
|
||||
@ -24,6 +30,15 @@ public class MdClientServiceImpl implements IMdClientService
|
||||
@Autowired
|
||||
private MdClientMapper mdClientMapper;
|
||||
|
||||
@Autowired
|
||||
protected Validator validator;
|
||||
|
||||
@Autowired
|
||||
private WmBarCodeUtil barCodeUtil;
|
||||
|
||||
@Autowired
|
||||
private AutoCodeUtil autoCodeUtil;
|
||||
|
||||
/**
|
||||
* 查询客户
|
||||
*
|
||||
@ -127,4 +142,63 @@ public class MdClientServiceImpl implements IMdClientService
|
||||
{
|
||||
return mdClientMapper.deleteMdClientByClientId(clientId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导入客户信息
|
||||
* @param clientList
|
||||
* @param isUpdateSupport
|
||||
* @param operName
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String importClient(List<MdClient> clientList, Boolean isUpdateSupport, String operName) {
|
||||
if (StringUtils.isNull(clientList) || clientList.size() == 0)
|
||||
{
|
||||
throw new ServiceException("导入客户数据不能为空!");
|
||||
}
|
||||
int successNum = 0;
|
||||
int failureNum = 0;
|
||||
StringBuilder successMsg = new StringBuilder();
|
||||
StringBuilder failureMsg = new StringBuilder();
|
||||
for (MdClient client : clientList)
|
||||
{
|
||||
try{
|
||||
//是否存在
|
||||
MdClient v = mdClientMapper.checkClientCodeUnique(client);
|
||||
if(StringUtils.isNull(v)){
|
||||
BeanValidators.validateWithException(validator, client);
|
||||
String clientCode = autoCodeUtil.genSerialCode(UserConstants.CLIENT_CODE,"");
|
||||
client.setClientCode(clientCode);
|
||||
this.insertMdClient(client);
|
||||
barCodeUtil.generateBarCode(UserConstants.BARCODE_TYPE_CLIENT,client.getClientId(),client.getClientCode(),client.getClientName());
|
||||
successNum++;
|
||||
}else if (isUpdateSupport){
|
||||
BeanValidators.validateWithException(validator, client);
|
||||
client.setUpdateBy(operName);
|
||||
client.setClientId(v.getClientId());
|
||||
this.updateMdClient(client);
|
||||
successNum++;
|
||||
}else {
|
||||
failureNum++;
|
||||
failureMsg.append("<br/>" + failureNum + "、客户 " + client.getClientName() + " 已存在");
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
failureNum++;
|
||||
String msg = "<br/>" + failureNum + "、客户 " + client.getClientName() + " 导入失败:";
|
||||
failureMsg.append(msg + e.getMessage());
|
||||
}
|
||||
if (failureNum > 0)
|
||||
{
|
||||
failureMsg.insert(0, "导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
||||
throw new ServiceException(failureMsg.toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条");
|
||||
}
|
||||
}
|
||||
return successMsg.toString();
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,8 @@ import com.ktg.common.exception.ServiceException;
|
||||
import com.ktg.common.utils.DateUtils;
|
||||
import com.ktg.common.utils.StringUtils;
|
||||
import com.ktg.common.utils.bean.BeanValidators;
|
||||
import com.ktg.mes.wm.utils.WmBarCodeUtil;
|
||||
import com.ktg.system.strategy.AutoCodeUtil;
|
||||
import org.apache.catalina.User;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -32,6 +34,12 @@ public class MdVendorServiceImpl implements IMdVendorService
|
||||
@Autowired
|
||||
protected Validator validator;
|
||||
|
||||
@Autowired
|
||||
private WmBarCodeUtil barCodeUtil;
|
||||
|
||||
@Autowired
|
||||
private AutoCodeUtil autoCodeUtil;
|
||||
|
||||
/**
|
||||
* 查询供应商
|
||||
*
|
||||
@ -103,7 +111,10 @@ public class MdVendorServiceImpl implements IMdVendorService
|
||||
MdVendor v = mdVendorMapper.checkVendorCodeUnique(vendor);
|
||||
if(StringUtils.isNull(v)){
|
||||
BeanValidators.validateWithException(validator, vendor);
|
||||
String vendorCode = autoCodeUtil.genSerialCode(UserConstants.VENDOR_CODE,"");
|
||||
vendor.setVendorCode(vendorCode);
|
||||
this.insertMdVendor(vendor);
|
||||
barCodeUtil.generateBarCode(UserConstants.BARCODE_TYPE_VENDOR,vendor.getVendorId(),vendor.getVendorCode(),vendor.getVendorName());
|
||||
successNum++;
|
||||
}else if (isUpdateSupport){
|
||||
BeanValidators.validateWithException(validator, vendor);
|
||||
@ -128,7 +139,7 @@ public class MdVendorServiceImpl implements IMdVendorService
|
||||
}
|
||||
else
|
||||
{
|
||||
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
|
||||
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条");
|
||||
}
|
||||
}
|
||||
return successMsg.toString();
|
||||
|
@ -149,7 +149,7 @@ public class ProTaskController extends BaseController
|
||||
data.setWorkstation(task.getWorkstationName());
|
||||
BigDecimal taskproduced = task.getQuantityProduced();
|
||||
BigDecimal taskquantitiy = task.getQuantity();
|
||||
data.setProgress(taskproduced.divide(taskquantitiy,BigDecimal.ROUND_HALF_UP).floatValue());
|
||||
data.setProgress(taskproduced.divide(taskquantitiy).setScale(4,BigDecimal.ROUND_HALF_UP).floatValue());
|
||||
data.setType(UserConstants.GANTT_TASK_TYPE_TASK);
|
||||
ganttData.add(data);
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import com.ktg.mes.wm.domain.WmBarcode;
|
||||
import com.ktg.mes.wm.service.IWmBarcodeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@ -106,4 +107,18 @@ public class WmBarcodeController extends BaseController
|
||||
{
|
||||
return toAjax(wmBarcodeService.deleteWmBarcodeByBarcodeIds(barcodeIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取某个对象的二维码地址
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getBarcodeUrl")
|
||||
public AjaxResult getBarcodeUrl(WmBarcode wmBarcode){
|
||||
List<WmBarcode> list = wmBarcodeService.selectWmBarcodeList(wmBarcode);
|
||||
if(!CollectionUtils.isEmpty(list)){
|
||||
return AjaxResult.success(list.get(0));
|
||||
}
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user