Commit c4d2be67 by zhaoxiaolei

上传下载

parent f9467261
...@@ -19,8 +19,10 @@ import org.slf4j.LoggerFactory; ...@@ -19,8 +19,10 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
/** /**
...@@ -30,7 +32,7 @@ import java.util.List; ...@@ -30,7 +32,7 @@ import java.util.List;
@RestController @RestController
@RequestMapping("/characteristic") @RequestMapping("/characteristic")
@Api(tags = {"Characteristic 特征管理"}) @Api(tags = {"Characteristic 特征管理"})
@ApiIgnore //@ApiIgnore
public class CharacteristicController { public class CharacteristicController {
private static final Logger logger = LoggerFactory.getLogger(CharacteristicController.class); private static final Logger logger = LoggerFactory.getLogger(CharacteristicController.class);
...@@ -107,4 +109,26 @@ public class CharacteristicController { ...@@ -107,4 +109,26 @@ public class CharacteristicController {
} }
/**
* @desc 特征管理 导出特征
* @param dto
* @param response
*/
@PostMapping("/exportCharacteristic")
@ApiOperation(value = "特征管理 导出特征", notes = "特征管理 导出特征", httpMethod = "POST")
public void exportCharacteristic(@RequestBody CharacteristicRequestParamDto dto, HttpServletResponse response){
characteristicService.exportCharacteristic(dto,response);
}
/**
* @desc 特征管理 上传文件更新
* @param file
* @return
*/
@RequestMapping("/batchUpdateByUpload")
@ApiOperation(value = "特征管理 上传文件更新", notes = "特征管理 上传文件更新", httpMethod = "POST")
public CrmResponseEntity<?> batchUpdateByUpload(@RequestParam("file") MultipartFile file){
return ResultGenerator.genSuccessResult(characteristicService.batchUpdateByUpload(file));
}
} }
...@@ -34,7 +34,7 @@ import java.util.List; ...@@ -34,7 +34,7 @@ import java.util.List;
@RestController @RestController
@RequestMapping("/characteristicValue") @RequestMapping("/characteristicValue")
@Api(tags = {"CharacteristicValue 特征值管理"}) @Api(tags = {"CharacteristicValue 特征值管理"})
@ApiIgnore //@ApiIgnore
public class CharacteristicValueController { public class CharacteristicValueController {
private static final Logger logger = LoggerFactory.getLogger(CharacteristicValueController.class); private static final Logger logger = LoggerFactory.getLogger(CharacteristicValueController.class);
...@@ -103,8 +103,8 @@ public class CharacteristicValueController { ...@@ -103,8 +103,8 @@ public class CharacteristicValueController {
* @param dto * @param dto
* @param response * @param response
*/ */
@RequestMapping("/exportCharacteristicValue") @PostMapping("/exportCharacteristicValue")
@ApiOperation(value = "特征值管理 导出特征值", notes = "特征值管理 导出特征值", httpMethod = "POST") @ApiOperation(value = "特征值管理 导出特征值", notes = "特征值管理 导出特征值", httpMethod = "GPOSTET")
public void exportCharacteristicValue(@RequestBody CharacteristicValueRequestParamDto dto, HttpServletResponse response){ public void exportCharacteristicValue(@RequestBody CharacteristicValueRequestParamDto dto, HttpServletResponse response){
characteristicValueService.exportCharacteristicValue(dto,response); characteristicValueService.exportCharacteristicValue(dto,response);
} }
......
package cn.com.uitech.authorization.controller; package cn.com.uitech.authorization.controller;
import cn.com.uitech.authorization.pojo.dto.CharacteristicValueExportDto;
import cn.com.uitech.authorization.pojo.dto.CharacteristicValueRequestParamDto;
import cn.com.uitech.authorization.pojo.entity.*; import cn.com.uitech.authorization.pojo.entity.*;
import cn.com.uitech.authorization.service.SuperBomPriceCalculateService; import cn.com.uitech.authorization.service.SuperBomPriceCalculateService;
import cn.com.uitech.authorization.utils.CrmResponseEntity; import cn.com.uitech.authorization.utils.CrmResponseEntity;
...@@ -7,13 +9,12 @@ import cn.com.uitech.authorization.utils.ResultGenerator; ...@@ -7,13 +9,12 @@ import cn.com.uitech.authorization.utils.ResultGenerator;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.Map; import java.util.Map;
/** /**
...@@ -26,7 +27,7 @@ import java.util.Map; ...@@ -26,7 +27,7 @@ import java.util.Map;
@RestController @RestController
@RequestMapping("/superBom") @RequestMapping("/superBom")
@Api(tags = {"部件产品价格系数维护"}) @Api(tags = {"部件产品价格系数维护"})
@ApiIgnore //@ApiIgnore
public class SuperBomPriceCalculateController { public class SuperBomPriceCalculateController {
@Resource @Resource
...@@ -68,4 +69,27 @@ public class SuperBomPriceCalculateController { ...@@ -68,4 +69,27 @@ public class SuperBomPriceCalculateController {
public CrmResponseEntity<Object> getPriceByConfigInfo(@RequestBody SuperBomEntity superBomEntity) { public CrmResponseEntity<Object> getPriceByConfigInfo(@RequestBody SuperBomEntity superBomEntity) {
return ResultGenerator.genSuccessResult(superBomPriceCalculateService.getPriceByConfigInfo(superBomEntity)); return ResultGenerator.genSuccessResult(superBomPriceCalculateService.getPriceByConfigInfo(superBomEntity));
} }
/**
* @desc 特征值价格管理 导出特征值价格
* @param dto
* @param response
*/
@PostMapping("/exportCharacteristicValuePrice")
@ApiOperation(value = "特征值价格管理 导出特征值价格", notes = "特征值价格管理 导出特征值价格", httpMethod = "POST")
public void exportCharacteristicValuePrice(@RequestBody CharacteristicValueExportDto dto, HttpServletResponse response){
superBomPriceCalculateService.exportCharacteristicValuePrice(dto,response);
}
/**
* @desc 特征值价格管理 上传文件更新
* @param file
* @return
*/
@RequestMapping("/batchUpdateByUpload")
@ApiOperation(value = "特征值价格管理 上传文件更新", notes = "特征值价格管理 上传文件更新", httpMethod = "POST")
public CrmResponseEntity<?> batchUpdateByUpload(@RequestParam("file") MultipartFile file){
return ResultGenerator.genSuccessResult(superBomPriceCalculateService.batchUpdateByUpload(file));
}
} }
package cn.com.uitech.authorization.mapper; package cn.com.uitech.authorization.mapper;
import cn.com.uitech.authorization.pojo.dto.ApplySkuCodeResultDto; import cn.com.uitech.authorization.pojo.dto.ApplySkuCodeResultDto;
import cn.com.uitech.authorization.pojo.dto.CharacteristicExportDto;
import cn.com.uitech.authorization.pojo.dto.CharacteristicRequestParamDto; import cn.com.uitech.authorization.pojo.dto.CharacteristicRequestParamDto;
import cn.com.uitech.authorization.pojo.entity.*; import cn.com.uitech.authorization.pojo.entity.*;
import io.swagger.models.auth.In; import io.swagger.models.auth.In;
...@@ -93,4 +94,8 @@ public interface CharacteristicMapper extends IBaseMapper<Characteristic>, Inser ...@@ -93,4 +94,8 @@ public interface CharacteristicMapper extends IBaseMapper<Characteristic>, Inser
List<Characteristic> getCharacteristicH3CList(String superBomCode); List<Characteristic> getCharacteristicH3CList(String superBomCode);
Integer getCharacteristicInfo(String characteristicCode, String superBomCode); Integer getCharacteristicInfo(String characteristicCode, String superBomCode);
List<CharacteristicExportDto> exportCharacteristic(CharacteristicRequestParamDto dto);
void updateCharacteristicInfo(Characteristic info);
} }
...@@ -107,4 +107,6 @@ public interface CharacteristicValueMapper extends IBaseMapper<CharacteristicVal ...@@ -107,4 +107,6 @@ public interface CharacteristicValueMapper extends IBaseMapper<CharacteristicVal
void saveDeployPlm(SendDataToPlmLog log); void saveDeployPlm(SendDataToPlmLog log);
CharacteristicValue getCharacteristicValueInfoByCCode(String isH3cCode, String superBomCode); CharacteristicValue getCharacteristicValueInfoByCCode(String isH3cCode, String superBomCode);
void updateCharacteristicValue(CharacteristicValue v);
} }
package cn.com.uitech.authorization.mapper; package cn.com.uitech.authorization.mapper;
import cn.com.uitech.authorization.pojo.dto.CharacteristicValueExportDto;
import cn.com.uitech.authorization.pojo.dto.SuperCharacterPriceInfoDto;
import cn.com.uitech.authorization.pojo.entity.*; import cn.com.uitech.authorization.pojo.entity.*;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -46,4 +48,8 @@ public interface SuperBomPriceCalculateMapper { ...@@ -46,4 +48,8 @@ public interface SuperBomPriceCalculateMapper {
List<SuperCharacterPriceInfoEntity> getCharacterValueList(CharacteristicValue characteristicValue); List<SuperCharacterPriceInfoEntity> getCharacterValueList(CharacteristicValue characteristicValue);
SuperBomPriceInfoEntity getCharacteristicsPrice(String superBomCode, Integer type); SuperBomPriceInfoEntity getCharacteristicsPrice(String superBomCode, Integer type);
List<SuperCharacterPriceInfoDto> exportCharacteristicValuePrice(CharacteristicValueExportDto dto);
void updateCharacteristicInfo(Characteristics info);
} }
package cn.com.uitech.authorization.mapper; package cn.com.uitech.authorization.mapper;
import cn.com.uitech.authorization.pojo.dto.DeployTempItemParam;
import cn.com.uitech.authorization.pojo.dto.DeployTempParam; import cn.com.uitech.authorization.pojo.dto.DeployTempParam;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper @Mapper
public interface TempMapper { public interface TempMapper {
DeployTempParam getTempList(); DeployTempParam getTempList();
void updateTemp(DeployTempParam deployTempParam); void updateTemp(DeployTempParam deployTempParam);
List<DeployTempItemParam> getTempListBySkuCode(String oldSkuCode);
} }
package cn.com.uitech.authorization.pojo.dto;
import cn.com.uitech.authorization.annotation.FieldNameMapping;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;
import java.io.Serializable;
@Accessors(chain = true)
@NoArgsConstructor
@Getter
@Setter
@ToString
public class CharacteristicExportDto implements Serializable {
private static final long serialVersionUID = 587176618049116478L;
/**
* 排序
*/
@FieldNameMapping(name = "sort", value = "排序")
private String sort;
/**
* SuperBOM
*/
@FieldNameMapping(name = "superBomCode", value = "SuperBOM")
private String superBomCode;
/**
* 特征编码
*/
@FieldNameMapping(name = "characteristicCode", value = "特征编码")
private String characteristicCode;
/**
* PLM名称
*/
@FieldNameMapping(name = "characteristicName", value = "PLM名称")
private String characteristicName;
/**
* 销售名称
*/
@FieldNameMapping(name = "unisSalesCName", value = "销售名称")
private String unisSalesCName;
/**
* IsH3C
*/
@FieldNameMapping(name = "isH3C", value = "IsH3C")
private String isH3C;
}
...@@ -4,10 +4,7 @@ import cn.com.uitech.authorization.annotation.BathUpdate; ...@@ -4,10 +4,7 @@ import cn.com.uitech.authorization.annotation.BathUpdate;
import cn.com.uitech.authorization.annotation.EditSave; import cn.com.uitech.authorization.annotation.EditSave;
import cn.com.uitech.authorization.annotation.Query; import cn.com.uitech.authorization.annotation.Query;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Getter; import lombok.*;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -23,8 +20,7 @@ import java.io.Serializable; ...@@ -23,8 +20,7 @@ import java.io.Serializable;
*/ */
@Accessors(chain = true) @Accessors(chain = true)
@NoArgsConstructor @NoArgsConstructor
@Getter @Data
@Setter
@ToString @ToString
public class CharacteristicRequestParamDto extends BasePageDto implements Serializable{ public class CharacteristicRequestParamDto extends BasePageDto implements Serializable{
......
package cn.com.uitech.authorization.pojo.dto; package cn.com.uitech.authorization.pojo.dto;
import cn.com.uitech.authorization.annotation.FieldNameMapping; import cn.com.uitech.authorization.annotation.FieldNameMapping;
import lombok.Getter; import lombok.*;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import org.springframework.stereotype.Component;
import java.io.Serializable; import java.io.Serializable;
/**
* @author yangkuo
* @date 2020/6/18 14:37
* @desc 特征值导出实体体
*/
@Accessors(chain = true) @Accessors(chain = true)
@NoArgsConstructor @NoArgsConstructor
@Getter @Data
@Setter
@ToString @ToString
public class CharacteristicValueExportDto implements Serializable{ public class CharacteristicValueExportDto implements Serializable{
private static final long serialVersionUID = 587176618049116478L; private static final long serialVersionUID = 587176618049116478L;
private String brand;
private String productClassCode;
/**
* SuperBOM
*/
@FieldNameMapping(name = "superBomCode", value = "SuperBOM")
private String superBomCode;
/** /**
* cto 机型名称 * 特征编码
*/ */
@FieldNameMapping(name = "superBomName",value = "CTO机型名称") @FieldNameMapping(name = "CharacteristicCode", value = "特征编码")
private String superBomName; private String characteristicCode;
/**
* 特征名称
*/
@FieldNameMapping(name = "CharacteristicName", value = "特征名称")
private String characteristicName;
/** /**
* 特征值编码 * 特征值编码
*/ */
@FieldNameMapping(name = "characteristicValueCode",value = "特征值编码(请勿修改)") @FieldNameMapping(name = "CharacteristicValueCode", value = "特征值编码")
private String characteristicValueCode; private String characteristicValueCode;
/** /**
* 特征值名称 * PLM名称
*/ */
@FieldNameMapping(name = "characteristicValueName",value = "特征值名称") @FieldNameMapping(name = "CharacteristicValueName", value = "PLM名称")
private String characteristicValueName; private String characteristicValueName;
/** /**
* 特征名称 * 销售名称
*/
@FieldNameMapping(name = "characteristicName",value = "特征名称")
private String characteristicName;
/**
* cto 物料编号
*/ */
@FieldNameMapping(name = "superBomCode",value = "产品BOM") @FieldNameMapping(name = "unisSalesVName", value = "销售名称")
private String superBomCode; private String unisSalesVName;
/** /**
* 特征值是否可卖 * 是否可卖
*/ */
@FieldNameMapping(name = "isState",value = "可卖状态") @FieldNameMapping(name = "isState", value = "是否可卖")
private String isState; private String isState;
/** /**
* 是否可见 * ZPHCode
*/ */
@FieldNameMapping(name = "isShow",value = "可见状态") @FieldNameMapping(name = "zphCode", value = "ZPHCode")
private String isShow; private String zphCode;
/** /**
* cto 是否可卖 * ZPHName
*/ */
@FieldNameMapping(name = "bomStatus",value = "CTO机型可卖") @FieldNameMapping(name = "zphName", value = "ZPHName")
private String bomStatus; private String zphName;
/** /**
* 产品组 * 开始时间
*/ */
@FieldNameMapping(name = "productClassCode",value = "产品组") @FieldNameMapping(name = "qualifyDate", value = "开始时间")
private String productClassCode; private String qualifyDate;
/** /**
* 产品组 * H3C对照关系
*/ */
@FieldNameMapping(name = "productClassName",value = "产品组") @FieldNameMapping(name = "h3cCValue", value = "H3C对照关系")
private String productClassName; private String h3cCValue;
private String h3cDeliverCode;
} }
package cn.com.uitech.authorization.pojo.dto;
import cn.com.uitech.authorization.annotation.FieldNameMapping;
import lombok.Data;
import java.math.BigDecimal;
import java.sql.Date;
@Data
public class SuperCharacterPriceInfoDto {
private String cvPriceId;
@FieldNameMapping(name = "superBomCode", value = "SuperBOM")
private String superBomCode;
@FieldNameMapping(name = "superBomName", value = "SuperBOM名称")
private String superBomName;
@FieldNameMapping(name = "priceType", value = "定价类型")
private String priceType;
@FieldNameMapping(name = "characterCode", value = "特征编号")
private String characterCode;
@FieldNameMapping(name = "characterName", value = "特征名称")
private String characterName;
@FieldNameMapping(name = "characterValueCode", value = "特征值编号")
private String characterValueCode;
@FieldNameMapping(name = "characterValueName", value = "特征值名称")
private String characterValueName;
@FieldNameMapping(name = "actualPrice", value = "真实成本")
private String actualPrice;
@FieldNameMapping(name = "leve0Price", value = "标准成本")
private String leve0Price;
@FieldNameMapping(name = "leve1Price", value = "一级调整价")
private String leve1Price;
@FieldNameMapping(name = "leve2Price", value = "二级调整价")
private String leve2Price;
@FieldNameMapping(name = "leve3Price", value = "三级调整价")
private String leve3Price;
@FieldNameMapping(name = "leve4Price", value = "四级调整价")
private String leve4Price;
@FieldNameMapping(name = "agentPrice", value = "代理价")
private String agentPrice;
}
...@@ -24,6 +24,7 @@ public class Characteristics { ...@@ -24,6 +24,7 @@ public class Characteristics {
private String unisSalesVName; private String unisSalesVName;
private String h3cCValue; private String h3cCValue;
private String h3cCName; private String h3cCName;
private String superBomCode;
/** /**
* 真实成本价 * 真实成本价
*/ */
......
package cn.com.uitech.authorization.pojo.entity; package cn.com.uitech.authorization.pojo.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data; import lombok.Data;
import javax.persistence.*; import javax.persistence.*;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.sql.Date; import java.sql.Date;
import java.sql.Timestamp;
import java.util.Objects; import java.util.Objects;
/** /**
...@@ -32,5 +34,7 @@ public class SuperCharacterPriceInfoEntity { ...@@ -32,5 +34,7 @@ public class SuperCharacterPriceInfoEntity {
private BigDecimal leve4Price; private BigDecimal leve4Price;
private BigDecimal agentPrice; private BigDecimal agentPrice;
private String updateUser; private String updateUser;
private Date updateTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private Timestamp updateTime;
} }
...@@ -21,7 +21,7 @@ public class UserInfo { ...@@ -21,7 +21,7 @@ public class UserInfo {
@Column(name = "user_code") @Column(name = "user_code")
private String userCode; private String userCode;
@Column(name = "pass_word") @Column(name = "pass_word")
private String passWord; private String password;
@Column(name = "user_name") @Column(name = "user_name")
private String userName; private String userName;
@Column(name = "user_dimension") @Column(name = "user_dimension")
......
...@@ -5,7 +5,9 @@ import cn.com.uitech.authorization.pojo.dto.CharacteristicRequestParamDto; ...@@ -5,7 +5,9 @@ import cn.com.uitech.authorization.pojo.dto.CharacteristicRequestParamDto;
import cn.com.uitech.authorization.pojo.dto.CharacteristicValueRequestParamDto; import cn.com.uitech.authorization.pojo.dto.CharacteristicValueRequestParamDto;
import cn.com.uitech.authorization.pojo.entity.Characteristic; import cn.com.uitech.authorization.pojo.entity.Characteristic;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
/** /**
...@@ -55,4 +57,7 @@ public interface CharacteristicService { ...@@ -55,4 +57,7 @@ public interface CharacteristicService {
Object updateCharacteristicIsH3C(CharacteristicRequestParamDto dto); Object updateCharacteristicIsH3C(CharacteristicRequestParamDto dto);
void exportCharacteristic(CharacteristicRequestParamDto dto, HttpServletResponse response);
Object batchUpdateByUpload(MultipartFile file);
} }
package cn.com.uitech.authorization.service; package cn.com.uitech.authorization.service;
import cn.com.uitech.authorization.pojo.dto.CharacteristicValueExportDto;
import cn.com.uitech.authorization.pojo.entity.*; import cn.com.uitech.authorization.pojo.entity.*;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
/** /**
* @Author: ZXN * @Author: ZXN
...@@ -32,4 +36,8 @@ public interface SuperBomPriceCalculateService { ...@@ -32,4 +36,8 @@ public interface SuperBomPriceCalculateService {
* @return * @return
*/ */
PageInfo<SuperCharacterPriceInfoEntity> getCharacterValueList(CharacteristicValue characteristicValue); PageInfo<SuperCharacterPriceInfoEntity> getCharacterValueList(CharacteristicValue characteristicValue);
void exportCharacteristicValuePrice(CharacteristicValueExportDto dto, HttpServletResponse response);
Object batchUpdateByUpload(MultipartFile file);
} }
...@@ -2,23 +2,36 @@ package cn.com.uitech.authorization.service.impl; ...@@ -2,23 +2,36 @@ package cn.com.uitech.authorization.service.impl;
import cn.com.uitech.authorization.exception.BizException; import cn.com.uitech.authorization.exception.BizException;
import cn.com.uitech.authorization.mapper.CharacteristicMapper; import cn.com.uitech.authorization.mapper.CharacteristicMapper;
import cn.com.uitech.authorization.pojo.dto.CharacteristicExportDto;
import cn.com.uitech.authorization.pojo.dto.CharacteristicRequestParamDto; import cn.com.uitech.authorization.pojo.dto.CharacteristicRequestParamDto;
import cn.com.uitech.authorization.pojo.entity.Characteristic; import cn.com.uitech.authorization.pojo.entity.Characteristic;
import cn.com.uitech.authorization.service.CharacteristicService; import cn.com.uitech.authorization.service.CharacteristicService;
import cn.com.uitech.authorization.service.CtoBomService; import cn.com.uitech.authorization.service.CtoBomService;
import cn.com.uitech.authorization.utils.ApiResult; import cn.com.uitech.authorization.utils.ApiResult;
import cn.com.uitech.authorization.utils.DateUitl;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.google.common.collect.Lists;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.openxml4j.util.ZipSecureFile;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.web.multipart.MultipartFile;
import tk.mybatis.mapper.entity.Condition; import tk.mybatis.mapper.entity.Condition;
import tk.mybatis.mapper.entity.Example; import tk.mybatis.mapper.entity.Example;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List; import javax.servlet.ServletOutputStream;
import java.util.Objects; import javax.servlet.http.HttpServletResponse;
import java.nio.charset.StandardCharsets;
import java.text.DecimalFormat;
import java.util.*;
/** /**
* @author yangkuo * @author yangkuo
...@@ -116,4 +129,346 @@ public class CharacteristicServiceImpl implements CharacteristicService { ...@@ -116,4 +129,346 @@ public class CharacteristicServiceImpl implements CharacteristicService {
public Object updateCharacteristicIsH3C(CharacteristicRequestParamDto dto) { public Object updateCharacteristicIsH3C(CharacteristicRequestParamDto dto) {
return characteristicMapper.updateCharacteristicIsH3C(dto); return characteristicMapper.updateCharacteristicIsH3C(dto);
} }
@Override
public void exportCharacteristic(CharacteristicRequestParamDto dto, HttpServletResponse response) {
//根据页面输入框查询要导出的数据
try {
Date date = DateUitl.getNowAll();
String format = DateUitl.format(date, "yyyy-MM-dd");
String[] split = format.split("-");
StringBuilder worktableTitle = new StringBuilder();
for (String string : split) {
worktableTitle.append(string);
}
String file = "";
List<CharacteristicExportDto> priceModelList = new ArrayList<>();
List<CharacteristicExportDto> excelDtos = new ArrayList<>();
HSSFWorkbook wb = new HSSFWorkbook();
file = dto.getSuperBomCode() + worktableTitle + ".xls";
//根据页面输入框查询要导出的数据
priceModelList = characteristicMapper.exportCharacteristic(dto);
excelDtos = exportStandBom(priceModelList);
wb = exportExcelBom(excelDtos);
String filename = null;
filename = new String(file.getBytes("GBK"), StandardCharsets.ISO_8859_1);
response.setContentType("APPLICATION/OCTET-STREAM");
response.setCharacterEncoding("utf-8");
response.setHeader("Content-Disposition", "attachment;filename=\"" + filename + "\"");
ServletOutputStream outputStream = response.getOutputStream();
wb.write(outputStream);
outputStream.close();
} catch (Exception e) {
throw new BizException(ApiResult.INTERNAL_SERVER_ERROR, e.getMessage());
}
}
private List<CharacteristicExportDto> exportStandBom(List<CharacteristicExportDto> priceModelList) {
List<CharacteristicExportDto> excelDtos = new ArrayList<>();
for (CharacteristicExportDto priceInfoDto : priceModelList) {
CharacteristicExportDto dto = new CharacteristicExportDto();
if (!ObjectUtils.isEmpty(priceInfoDto.getSort())) {
dto.setSort(priceInfoDto.getSort());
} else {
dto.setSort(null);
}
if (!ObjectUtils.isEmpty(priceInfoDto.getSuperBomCode())) {
dto.setSuperBomCode(priceInfoDto.getSuperBomCode());
} else {
dto.setSuperBomCode(null);
}
if (!ObjectUtils.isEmpty(priceInfoDto.getCharacteristicCode())) {
dto.setCharacteristicCode(priceInfoDto.getCharacteristicCode());
} else {
dto.setCharacteristicCode(null);
}
if (!ObjectUtils.isEmpty(priceInfoDto.getCharacteristicName())) {
dto.setCharacteristicName(priceInfoDto.getCharacteristicName());
} else {
dto.setCharacteristicName(null);
}
if (!ObjectUtils.isEmpty(priceInfoDto.getUnisSalesCName())) {
dto.setUnisSalesCName(priceInfoDto.getUnisSalesCName());
} else {
dto.setUnisSalesCName(null);
}
if (!ObjectUtils.isEmpty(priceInfoDto.getIsH3C())) {
dto.setIsH3C(priceInfoDto.getIsH3C());
} else {
dto.setIsH3C(null);
}
excelDtos.add(dto);
}
return excelDtos;
}
private HSSFWorkbook exportExcelBom(List<CharacteristicExportDto> excelDtos) {
String[] excelHeader = new String[]{"排序", "SuperBOM", "特征编码", "PLM名称", "销售名称", "IsH3C"};
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet();
// 产生表格标题行
HSSFRow titleRow = sheet.createRow(1);
// 定义所需列数
int columnNum = excelHeader.length;
HSSFRow rowRowName = sheet.createRow(0); // 在索引2的位置创建行(最顶端的行开始的第二行)
// 将列头设置到sheet的单元格中
for (int n = 0; n < columnNum; n++) {
CellStyle style = workbook.createCellStyle();
HSSFCell cellRowName = rowRowName.createCell(n); // 创建列头对应个数的单元格
cellRowName.setCellType(HSSFCell.CELL_TYPE_STRING);
cellRowName.setCellValue(excelHeader[n]); // 设置列头单元格的值
style.setFillPattern(CellStyle.SOLID_FOREGROUND);
style.setFillForegroundColor(IndexedColors.WHITE.getIndex());
cellRowName.setCellStyle(style); // 设置列头单元格样式
}
// 添加表内容
for (int i = 0; i < excelDtos.size(); i++) {
HSSFRow ContentRow = sheet.createRow(i + 1);
if (ObjectUtils.isEmpty(excelDtos.get(i).getSort())) {
ContentRow.createCell(0).setCellValue("");
} else {
ContentRow.createCell(0).setCellValue(excelDtos.get(i).getSort());
}
if (ObjectUtils.isEmpty(excelDtos.get(i).getSuperBomCode())) {
ContentRow.createCell(1).setCellValue("");
} else {
ContentRow.createCell(1).setCellValue(excelDtos.get(i).getSuperBomCode());
}
if (ObjectUtils.isEmpty(excelDtos.get(i).getCharacteristicCode())) {
ContentRow.createCell(2).setCellValue("");
} else {
ContentRow.createCell(2).setCellValue(excelDtos.get(i).getCharacteristicCode());
}
if (ObjectUtils.isEmpty(excelDtos.get(i).getCharacteristicName())) {
ContentRow.createCell(3).setCellValue("");
} else {
ContentRow.createCell(3).setCellValue(excelDtos.get(i).getCharacteristicName());
}
if (ObjectUtils.isEmpty(excelDtos.get(i).getUnisSalesCName())) {
ContentRow.createCell(4).setCellValue("");
} else {
ContentRow.createCell(4).setCellValue(excelDtos.get(i).getUnisSalesCName());
}
if (ObjectUtils.isEmpty(excelDtos.get(i).getIsH3C())) {
ContentRow.createCell(5).setCellValue("");
} else {
ContentRow.createCell(5).setCellValue(excelDtos.get(i).getIsH3C());
}
}
// 让列宽随着导出的列长自动适应
for (int colNum = 0; colNum < columnNum; colNum++) {
int columnWidth = sheet.getColumnWidth(colNum) / 256;
for (int rowNum = 0; rowNum < sheet.getLastRowNum(); rowNum++) {
HSSFRow currentRow;
// 当前行未被使用过
if (sheet.getRow(rowNum) == null) {
currentRow = sheet.createRow(rowNum);
} else {
currentRow = sheet.getRow(rowNum);
}
if (currentRow.getCell(colNum) != null) {
HSSFCell currentCell = currentRow.getCell(colNum);
if (currentCell.getCellType() == HSSFCell.CELL_TYPE_STRING) {
int length = currentCell.getStringCellValue().getBytes().length;
if (columnWidth < length) {
columnWidth = length;
}
}
}
}
if (colNum == 0) {
sheet.setColumnWidth(colNum, (columnWidth - 2) * 256);
} else {
sheet.setColumnWidth(colNum, (columnWidth + 4) * 256);
}
}
return workbook;
}
/**
* @param file
* @return
* @desc 特征管理 上传文件更新
*/
@Override
public String batchUpdateByUpload(MultipartFile file) {
int result = 0;
//判断文件是否为空
if (null == file || file.isEmpty()) {
throw new BizException(ApiResult.API_REQ_DATA_IS_FAIL, "特征上传文件批量更新-上传文件为空");
}
//读取文件内容
List<CharacteristicExportDto> list = uploadExcl(file);
//非空校验
if (!CollectionUtils.isEmpty(list)) {
ArrayList<String> checkFileIsNull = checkFileIsNull(list);
if (!CollectionUtils.isEmpty(checkFileIsNull)) {
return String.valueOf(checkFileIsNull);
}
} else {
}
updateData(list);
return "更新附件内容成功";
}
/**
* @param list
* @根据特征编码和superBom更新特征表
*/
public void updateData(List<CharacteristicExportDto> list) {
//更新数据库里数据
ArrayList<Characteristic> updateList = new ArrayList<>();
list.stream().forEach((dto) -> {
Characteristic c = new Characteristic();
c.setCharacteristicCode(dto.getCharacteristicCode());
c.setSuperBomCode(dto.getSuperBomCode());
String isState = dto.getIsH3C();
if (isState.equals("是")) {
c.setIsH3C(1);
} else {
c.setIsH3C(0);
}
c.setUnisSalesCName(dto.getUnisSalesCName());
if(!ObjectUtils.isEmpty(dto.getSort())){
c.setSort(Integer.valueOf(dto.getSort()));
}
updateList.add(c);
});
for (Characteristic info : updateList) {
characteristicMapper.updateCharacteristicInfo(info);
}
}
/**
* @param list
* @return
* @desc 对上传的数据做非空校验
*/
public ArrayList<String> checkFileIsNull(List<CharacteristicExportDto> list) {
ArrayList<String> checkList = new ArrayList<>();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < list.size(); i++) {
CharacteristicExportDto item = list.get(i);
if (StringUtils.isBlank(item.getSuperBomCode())) {
sb.append("SuperBom编号不能为空");
}
if (StringUtils.isBlank(item.getCharacteristicCode())) {
sb.append("特征编号不能为空");
}
if (StringUtils.isNotBlank(sb.toString())) {
sb.insert(0, "上传文件的第" + i + "行数据:");
checkList.add(sb.toString());
}
}
return checkList;
}
/**
* @param file
* @return List<CharacteristicExportDto>
* @desc 解析上传文件
*/
public List<CharacteristicExportDto> uploadExcl(MultipartFile file) {
long startDate = Calendar.getInstance().getTimeInMillis();
List<CharacteristicExportDto> list = Lists.newArrayList();
Workbook wook = null;
try {
String filename = file.getOriginalFilename();
if (filename.endsWith("xls")) {
ZipSecureFile.setMinInflateRatio(-1.0d);
wook = new HSSFWorkbook(file.getInputStream());
} else if (filename.endsWith("xlsx")) {
ZipSecureFile.setMinInflateRatio(-1.0d);
wook = new XSSFWorkbook(file.getInputStream());
}
int numberOfSheets = wook.getNumberOfSheets();
for (int i = 0; i < numberOfSheets; i++) {
Sheet sheetAt = wook.getSheetAt(i);
int rows = sheetAt.getPhysicalNumberOfRows();
for (int j = 1; j < rows; j++) {
Row row = sheetAt.getRow(j);
int cells = row.getPhysicalNumberOfCells();
//把每条数据封装进对象里
CharacteristicExportDto dto = setCharacteristicExportDto(row, cells);
list.add(dto);
}
}
} catch (Exception e) {
e.printStackTrace();
}
long endDate = Calendar.getInstance().getTimeInMillis();
return list;
}
/**
* @param row
* @param cells
* @return CharacteristicValueExportDto
* @desc 把excel每行数据返回一个对象
*/
public CharacteristicExportDto setCharacteristicExportDto(Row row, int cells) {
CharacteristicExportDto dto = new CharacteristicExportDto();
try {
for (int i = 0; i < cells; i++) {
//读取到内存的只保留有更新逻辑的字段
dto.setSort(getCellValueByCell(row.getCell(0)));
dto.setSuperBomCode(getCellValueByCell(row.getCell(1)));
dto.setCharacteristicCode(getCellValueByCell(row.getCell(2)));
dto.setCharacteristicName(getCellValueByCell(row.getCell(3)));
dto.setUnisSalesCName(getCellValueByCell(row.getCell(4)));
dto.setIsH3C(getCellValueByCell(row.getCell(5)));
}
} catch (Exception e) {
e.printStackTrace();
}
return dto;
}
/**
* @param cell
* @return
* @desc 获取单元格各类型值,返回字符串类型
*/
private String getCellValueByCell(Cell cell) {
//判断是否为null或空串
if (cell == null || cell.toString().trim().equals("")) {
return "";
}
String cellValue = "";
int cellType = cell.getCellType();
switch (cellType) {
case Cell.CELL_TYPE_STRING: //字符串类型
cellValue = cell.getStringCellValue().trim();
break;
case Cell.CELL_TYPE_BOOLEAN: //布尔类型
cellValue = String.valueOf(cell.getBooleanCellValue());
break;
case Cell.CELL_TYPE_NUMERIC: //数值类型
if (HSSFDateUtil.isCellDateFormatted(cell)) { //判断日期类型
cellValue = DateFormatUtils.format(cell.getDateCellValue(), "yyyy-MM-dd");
} else { //否
cellValue = new DecimalFormat("#.######").format(cell.getNumericCellValue());
}
break;
default: //其它类型,取空串吧
cellValue = "";
break;
}
return cellValue;
}
} }
package cn.com.uitech.authorization.service.impl; package cn.com.uitech.authorization.service.impl;
import cn.com.uitech.authorization.annotation.FieldNameMapping;
import cn.com.uitech.authorization.enums.CtoStatusEnum;
import cn.com.uitech.authorization.enums.SalesVisibleEnum;
import cn.com.uitech.authorization.exception.BizException; import cn.com.uitech.authorization.exception.BizException;
import cn.com.uitech.authorization.mapper.CharacteristicValueMapper; import cn.com.uitech.authorization.mapper.CharacteristicValueMapper;
import cn.com.uitech.authorization.pojo.dto.*; import cn.com.uitech.authorization.pojo.dto.*;
...@@ -10,7 +7,7 @@ import cn.com.uitech.authorization.pojo.entity.CharacteristicValue; ...@@ -10,7 +7,7 @@ import cn.com.uitech.authorization.pojo.entity.CharacteristicValue;
import cn.com.uitech.authorization.pojo.entity.OdRelation; import cn.com.uitech.authorization.pojo.entity.OdRelation;
import cn.com.uitech.authorization.service.CharacteristicValueService; import cn.com.uitech.authorization.service.CharacteristicValueService;
import cn.com.uitech.authorization.utils.ApiResult; import cn.com.uitech.authorization.utils.ApiResult;
import cn.com.uitech.authorization.utils.ProductExportUtils; import cn.com.uitech.authorization.utils.DateUitl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
...@@ -18,12 +15,9 @@ import com.github.pagehelper.PageInfo; ...@@ -18,12 +15,9 @@ import com.github.pagehelper.PageInfo;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.poi.hssf.usermodel.HSSFDateUtil; import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.openxml4j.util.ZipSecureFile;
import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.streaming.SXSSFWorkbook; import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -40,9 +34,10 @@ import org.springframework.web.client.RestTemplate; ...@@ -40,9 +34,10 @@ import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import tk.mybatis.mapper.entity.Condition; import tk.mybatis.mapper.entity.Condition;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.OutputStream; import java.io.OutputStream;
import java.lang.reflect.Field; import java.nio.charset.StandardCharsets;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
...@@ -210,72 +205,237 @@ public class CharacteristicValueServiceImpl implements CharacteristicValueServic ...@@ -210,72 +205,237 @@ public class CharacteristicValueServiceImpl implements CharacteristicValueServic
@Override @Override
public void exportCharacteristicValue(CharacteristicValueRequestParamDto dto, HttpServletResponse response) { public void exportCharacteristicValue(CharacteristicValueRequestParamDto dto, HttpServletResponse response) {
//根据页面输入框查询要导出的数据 //根据页面输入框查询要导出的数据
List<CharacteristicValueExportDto> list = characteristicValueMapper.exportCharacteristicValue(dto);
try { try {
//标题 Date date = DateUitl.getNowAll();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss"); String format = DateUitl.format(date, "yyyy-MM-dd");
String name = simpleDateFormat.format(new Date()); String[] split = format.split("-");
String sheetName = list.get(0).getSuperBomName(); StringBuilder worktableTitle = new StringBuilder();
for (String string : split) {
//获取表头 worktableTitle.append(string);
ArrayList<String> titList = getFiledName(new CharacteristicValueExportDto()); }
//数据转list中list String file = "";
List<String[]> datalist = getListData(list); List<CharacteristicValueExportDto> priceModelList = new ArrayList<>();
//下载 List<CharacteristicValueExportDto> excelDtos = new ArrayList<>();
SXSSFWorkbook sxssfWorkbook = ProductExportUtils.getSXSSFWorkbook(sheetName, titList, datalist); HSSFWorkbook wb = new HSSFWorkbook();
ProductExportUtils.export(sxssfWorkbook, sheetName + name, response);
file = dto.getSuperBomCode() + worktableTitle + ".xls";
//根据页面输入框查询要导出的数据
priceModelList = characteristicValueMapper.exportCharacteristicValue(dto);
excelDtos = exportStandBom(priceModelList);
wb = exportExcelBom(excelDtos);
String filename = null;
filename = new String(file.getBytes("GBK"), StandardCharsets.ISO_8859_1);
response.setContentType("APPLICATION/OCTET-STREAM");
response.setCharacterEncoding("utf-8");
response.setHeader("Content-Disposition", "attachment;filename=\"" + filename + "\"");
ServletOutputStream outputStream = response.getOutputStream();
wb.write(outputStream);
outputStream.close();
} catch (Exception e) { } catch (Exception e) {
throw new BizException(ApiResult.INTERNAL_SERVER_ERROR, e.getMessage()); throw new BizException(ApiResult.INTERNAL_SERVER_ERROR, e.getMessage());
} }
} }
/** private List<CharacteristicValueExportDto> exportStandBom(List<CharacteristicValueExportDto> priceModelList) {
* @param list List<CharacteristicValueExportDto> excelDtos = new ArrayList<>();
* @return for (CharacteristicValueExportDto priceInfoDto : priceModelList) {
* @desc 把对象转数组 CharacteristicValueExportDto dto = new CharacteristicValueExportDto();
*/ //"SuperBOM", "特征编码", "特征名称",
public List<String[]> getListData(List<CharacteristicValueExportDto> list) { if (!ObjectUtils.isEmpty(priceInfoDto.getSuperBomCode())) {
List<String[]> dataList = Lists.newArrayList(); dto.setSuperBomCode(priceInfoDto.getSuperBomCode());
String[] str = new String[]{}; } else {
for (int i = 0; i < list.size(); i++) { dto.setSuperBomCode(null);
String[] arrDate = new String[6]; }
CharacteristicValueExportDto dto = list.get(i); if (!ObjectUtils.isEmpty(priceInfoDto.getCharacteristicCode())) {
dto.setCharacteristicCode(priceInfoDto.getCharacteristicCode());
arrDate[0] = dto.getSuperBomName(); } else {
arrDate[1] = dto.getCharacteristicValueCode(); dto.setCharacteristicCode(null);
arrDate[2] = dto.getSuperBomCode(); }
if (!ObjectUtils.isEmpty(priceInfoDto.getCharacteristicName())) {
arrDate[3] = dto.getIsState(); dto.setCharacteristicName(priceInfoDto.getCharacteristicName());
arrDate[4] = dto.getIsShow(); } else {
arrDate[5] = dto.getBomStatus(); dto.setCharacteristicName(null);
}
dataList.add(arrDate); //"特征值编号", "PLM名称", "销售名称",
if (!ObjectUtils.isEmpty(priceInfoDto.getCharacteristicValueCode())) {
dto.setCharacteristicValueCode(priceInfoDto.getCharacteristicValueCode());
} else {
dto.setCharacteristicValueCode(null);
}
if (!ObjectUtils.isEmpty(priceInfoDto.getCharacteristicValueName())) {
dto.setCharacteristicValueName(priceInfoDto.getCharacteristicValueName());
} else {
dto.setCharacteristicValueName(null);
}
if (!ObjectUtils.isEmpty(priceInfoDto.getUnisSalesVName())) {
dto.setUnisSalesVName(priceInfoDto.getUnisSalesVName());
} else {
dto.setUnisSalesVName(null);
}
//"是否可卖", "ZPHCode", "ZPHName",
if (!ObjectUtils.isEmpty(priceInfoDto.getIsState())) {
dto.setIsState(priceInfoDto.getIsState());
} else {
dto.setIsState(null);
}
if (!ObjectUtils.isEmpty(priceInfoDto.getZphCode())) {
dto.setZphCode(priceInfoDto.getZphCode());
} else {
dto.setZphCode(null);
}
if (!ObjectUtils.isEmpty(priceInfoDto.getZphName())) {
dto.setZphName(priceInfoDto.getZphName());
} else {
dto.setZphName(null);
}
//"开始时间", "H3C对照关系"
if (!ObjectUtils.isEmpty(priceInfoDto.getQualifyDate())) {
dto.setQualifyDate(priceInfoDto.getQualifyDate());
} else {
dto.setQualifyDate(null);
}
if (!ObjectUtils.isEmpty(priceInfoDto.getH3cCValue())) {
dto.setH3cCValue(priceInfoDto.getH3cCValue());
} else {
dto.setH3cCValue(null);
}
if (!ObjectUtils.isEmpty(priceInfoDto.getH3cDeliverCode())) {
dto.setH3cDeliverCode(priceInfoDto.getH3cDeliverCode());
} else {
dto.setH3cDeliverCode(null);
}
excelDtos.add(dto);
} }
return dataList; return excelDtos;
} }
; private HSSFWorkbook exportExcelBom(List<CharacteristicValueExportDto> excelDtos) {
String[] excelHeader = new String[]{
"SuperBOM", "特征编码", "特征名称",
"特征值编码", "PLM名称", "销售名称",
"是否可卖", "ZPHCode", "ZPHName",
"开始时间", "H3C对照关系", "H3C交付码"};
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet();
// 产生表格标题行
HSSFRow titleRow = sheet.createRow(1);
// 定义所需列数
int columnNum = excelHeader.length;
HSSFRow rowRowName = sheet.createRow(0); // 在索引2的位置创建行(最顶端的行开始的第二行)
// 将列头设置到sheet的单元格中
for (int n = 0; n < columnNum; n++) {
CellStyle style = workbook.createCellStyle();
HSSFCell cellRowName = rowRowName.createCell(n); // 创建列头对应个数的单元格
cellRowName.setCellType(HSSFCell.CELL_TYPE_STRING);
cellRowName.setCellValue(excelHeader[n]); // 设置列头单元格的值
style.setFillPattern(CellStyle.SOLID_FOREGROUND);
style.setFillForegroundColor(IndexedColors.WHITE.getIndex());
cellRowName.setCellStyle(style); // 设置列头单元格样式
}
/** // 添加表内容
* @param target for (int i = 0; i < excelDtos.size(); i++) {
* @return HSSFRow ContentRow = sheet.createRow(i + 1);
* @throws Exception //"SuperBOM", "特征编码", "特征名称",
* @desc 根据自定义注解获取到处文件列名
*/ if (ObjectUtils.isEmpty(excelDtos.get(i).getSuperBomCode())) {
public ArrayList<String> getFiledName(Object target) throws Exception { ContentRow.createCell(0).setCellValue("");
ArrayList<String> list = Lists.newArrayList(); } else {
Field[] fields = target.getClass().getDeclaredFields(); ContentRow.createCell(0).setCellValue(excelDtos.get(i).getSuperBomCode());
String[] fieldNames = new String[fields.length]; }
for (int i = 0; i < fields.length; ++i) { if (ObjectUtils.isEmpty(excelDtos.get(i).getCharacteristicCode())) {
fieldNames[i] = fields[i].getName(); ContentRow.createCell(1).setCellValue("");
Field declaredField = target.getClass().getDeclaredField(fields[i].getName()); } else {
FieldNameMapping annotation = declaredField.getAnnotation(FieldNameMapping.class); ContentRow.createCell(1).setCellValue(excelDtos.get(i).getCharacteristicCode());
if (null != annotation) { }
list.add(annotation.value()); if (ObjectUtils.isEmpty(excelDtos.get(i).getCharacteristicName())) {
ContentRow.createCell(2).setCellValue("");
} else {
ContentRow.createCell(2).setCellValue(excelDtos.get(i).getCharacteristicName());
}
//"特征值编号", "PLM名称", "销售名称",
if (ObjectUtils.isEmpty(excelDtos.get(i).getCharacteristicValueCode())) {
ContentRow.createCell(3).setCellValue("");
} else {
ContentRow.createCell(3).setCellValue(excelDtos.get(i).getCharacteristicValueCode());
}
if (ObjectUtils.isEmpty(excelDtos.get(i).getCharacteristicValueName())) {
ContentRow.createCell(4).setCellValue("");
} else {
ContentRow.createCell(4).setCellValue(excelDtos.get(i).getCharacteristicValueName());
}
if (ObjectUtils.isEmpty(excelDtos.get(i).getUnisSalesVName())) {
ContentRow.createCell(5).setCellValue("");
} else {
ContentRow.createCell(5).setCellValue(excelDtos.get(i).getUnisSalesVName());
}
//"是否可卖", "ZPHCode", "ZPHName",
if (ObjectUtils.isEmpty(excelDtos.get(i).getIsState())) {
ContentRow.createCell(6).setCellValue("");
} else {
ContentRow.createCell(6).setCellValue(excelDtos.get(i).getIsState());
}
if (ObjectUtils.isEmpty(excelDtos.get(i).getZphCode())) {
ContentRow.createCell(7).setCellValue("");
} else {
ContentRow.createCell(7).setCellValue(excelDtos.get(i).getZphCode());
}
if (ObjectUtils.isEmpty(excelDtos.get(i).getZphName())) {
ContentRow.createCell(8).setCellValue("");
} else {
ContentRow.createCell(8).setCellValue(excelDtos.get(i).getZphName());
}
//"开始时间", "H3C对照关系"
if (ObjectUtils.isEmpty(excelDtos.get(i).getQualifyDate())) {
ContentRow.createCell(9).setCellValue("");
} else {
ContentRow.createCell(9).setCellValue(excelDtos.get(i).getQualifyDate());
}
if (ObjectUtils.isEmpty(excelDtos.get(i).getH3cCValue())) {
ContentRow.createCell(10).setCellValue("");
} else {
ContentRow.createCell(10).setCellValue(excelDtos.get(i).getH3cCValue());
}
if (ObjectUtils.isEmpty(excelDtos.get(i).getH3cDeliverCode())) {
ContentRow.createCell(11).setCellValue("");
} else {
ContentRow.createCell(11).setCellValue(excelDtos.get(i).getH3cDeliverCode());
} }
} }
return list; // 让列宽随着导出的列长自动适应
for (int colNum = 0; colNum < columnNum; colNum++) {
int columnWidth = sheet.getColumnWidth(colNum) / 256;
for (int rowNum = 0; rowNum < sheet.getLastRowNum(); rowNum++) {
HSSFRow currentRow;
// 当前行未被使用过
if (sheet.getRow(rowNum) == null) {
currentRow = sheet.createRow(rowNum);
} else {
currentRow = sheet.getRow(rowNum);
}
if (currentRow.getCell(colNum) != null) {
HSSFCell currentCell = currentRow.getCell(colNum);
if (currentCell.getCellType() == HSSFCell.CELL_TYPE_STRING) {
int length = currentCell.getStringCellValue().getBytes().length;
if (columnWidth < length) {
columnWidth = length;
}
}
}
}
if (colNum == 0) {
sheet.setColumnWidth(colNum, (columnWidth - 2) * 256);
} else {
sheet.setColumnWidth(colNum, (columnWidth + 4) * 256);
}
}
return workbook;
} }
/** /**
...@@ -294,9 +454,9 @@ public class CharacteristicValueServiceImpl implements CharacteristicValueServic ...@@ -294,9 +454,9 @@ public class CharacteristicValueServiceImpl implements CharacteristicValueServic
List<CharacteristicValueExportDto> list = uploadExcl(file); List<CharacteristicValueExportDto> list = uploadExcl(file);
//非空校验 //非空校验
if (!CollectionUtils.isEmpty(list)) { if (!CollectionUtils.isEmpty(list)) {
ArrayList<String> checkFileIsNnull = checkFileIsNnull(list); ArrayList<String> checkFileIsNull = checkFileIsNull(list);
if (!CollectionUtils.isEmpty(checkFileIsNnull)) { if (!CollectionUtils.isEmpty(checkFileIsNull)) {
return String.valueOf(checkFileIsNnull); return String.valueOf(checkFileIsNull);
} }
} else { } else {
} }
...@@ -316,15 +476,16 @@ public class CharacteristicValueServiceImpl implements CharacteristicValueServic ...@@ -316,15 +476,16 @@ public class CharacteristicValueServiceImpl implements CharacteristicValueServic
list.stream().forEach((dto) -> { list.stream().forEach((dto) -> {
CharacteristicValue c = new CharacteristicValue(); CharacteristicValue c = new CharacteristicValue();
c.setCharacteristicValueCode(dto.getCharacteristicValueCode()); c.setCharacteristicValueCode(dto.getCharacteristicValueCode());
c.setIsState(CtoStatusEnum.getCode(dto.getIsState())); c.setCharacteristicCode(dto.getCharacteristicCode());
c.setIsShow(SalesVisibleEnum.getCode(dto.getIsShow())); c.setSuperBomCode(dto.getSuperBomCode());
c.setH3cCValue(dto.getH3cCValue());
c.setUnisSalesVName(dto.getUnisSalesVName());
c.setH3cDeliverCode(dto.getH3cDeliverCode());
updateList.add(c); updateList.add(c);
}); });
for (CharacteristicValue c : updateList) { for (CharacteristicValue v : updateList) {
Condition condition = characteristicValueMapper.getCondition(); characteristicValueMapper.updateCharacteristicValue(v);
condition.createCriteria().andEqualTo("characteristicValueCode", c.getCharacteristicValueCode());
characteristicValueMapper.updateByExampleSelective(c, condition);
} }
} }
...@@ -335,20 +496,23 @@ public class CharacteristicValueServiceImpl implements CharacteristicValueServic ...@@ -335,20 +496,23 @@ public class CharacteristicValueServiceImpl implements CharacteristicValueServic
* @return * @return
* @desc 对上传的数据做非空校验 * @desc 对上传的数据做非空校验
*/ */
public ArrayList<String> checkFileIsNnull(List<CharacteristicValueExportDto> list) { public ArrayList<String> checkFileIsNull(List<CharacteristicValueExportDto> list) {
ArrayList<String> checkList = new ArrayList<>(); ArrayList<String> checkList = new ArrayList<>();
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
CharacteristicValueExportDto item = list.get(i); CharacteristicValueExportDto item = list.get(i);
if (StringUtils.isBlank(item.getSuperBomCode())) {
sb.append("SuperBom编号不能为空");
}
if (StringUtils.isBlank(item.getCharacteristicCode())) {
sb.append("特征编号不能为空");
}
if (StringUtils.isBlank(item.getCharacteristicValueCode())) { if (StringUtils.isBlank(item.getCharacteristicValueCode())) {
sb.append("特征值编号不能为空"); sb.append("特征值编号不能为空");
} }
if (StringUtils.isBlank(item.getIsState())) { if (StringUtils.isBlank(item.getIsState())) {
sb.append("特征值可卖状态不能为空"); sb.append("特征值可卖状态不能为空");
} }
if (StringUtils.isBlank(item.getIsShow())) {
sb.append("特征值可见状态不能为空");
}
if (StringUtils.isNotBlank(sb.toString())) { if (StringUtils.isNotBlank(sb.toString())) {
sb.insert(0, "上传文件的第" + i + "行数据:"); sb.insert(0, "上传文件的第" + i + "行数据:");
checkList.add(sb.toString()); checkList.add(sb.toString());
...@@ -371,8 +535,10 @@ public class CharacteristicValueServiceImpl implements CharacteristicValueServic ...@@ -371,8 +535,10 @@ public class CharacteristicValueServiceImpl implements CharacteristicValueServic
try { try {
String filename = file.getOriginalFilename(); String filename = file.getOriginalFilename();
if (filename.endsWith("xls")) { if (filename.endsWith("xls")) {
ZipSecureFile.setMinInflateRatio(-1.0d);
wook = new HSSFWorkbook(file.getInputStream()); wook = new HSSFWorkbook(file.getInputStream());
} else if (filename.endsWith("xlsx")) { } else if (filename.endsWith("xlsx")) {
ZipSecureFile.setMinInflateRatio(-1.0d);
wook = new XSSFWorkbook(file.getInputStream()); wook = new XSSFWorkbook(file.getInputStream());
} }
...@@ -406,12 +572,17 @@ public class CharacteristicValueServiceImpl implements CharacteristicValueServic ...@@ -406,12 +572,17 @@ public class CharacteristicValueServiceImpl implements CharacteristicValueServic
try { try {
for (int i = 0; i < cells; i++) { for (int i = 0; i < cells; i++) {
//读取到内存的只保留有更新逻辑的字段 //读取到内存的只保留有更新逻辑的字段
dto.setSuperBomName(getCellValueByCell(row.getCell(0))); dto.setSuperBomCode(getCellValueByCell(row.getCell(0)));
dto.setCharacteristicValueCode(getCellValueByCell(row.getCell(1))); dto.setCharacteristicCode(getCellValueByCell(row.getCell(1)));
dto.setSuperBomCode(getCellValueByCell(row.getCell(2))); dto.setCharacteristicName(getCellValueByCell(row.getCell(2)));
dto.setIsState(getCellValueByCell(row.getCell(3))); dto.setCharacteristicValueCode(getCellValueByCell(row.getCell(3)));
dto.setIsShow(getCellValueByCell(row.getCell(4))); dto.setCharacteristicValueName(getCellValueByCell(row.getCell(4)));
dto.setBomStatus(getCellValueByCell(row.getCell(5))); dto.setUnisSalesVName(getCellValueByCell(row.getCell(5)));
dto.setIsState(getCellValueByCell(row.getCell(6)));
dto.setZphCode(getCellValueByCell(row.getCell(7)));
dto.setZphName(getCellValueByCell(row.getCell(8)));
dto.setQualifyDate(getCellValueByCell(row.getCell(9)));
dto.setH3cCValue(getCellValueByCell(row.getCell(10)));
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
......
...@@ -165,6 +165,7 @@ public class IntegrateServiceImpl implements IntegrateService { ...@@ -165,6 +165,7 @@ public class IntegrateServiceImpl implements IntegrateService {
characteristic.setUnisSalesCName(saveSuperCharacterInputDto.getOptionName()); characteristic.setUnisSalesCName(saveSuperCharacterInputDto.getOptionName());
characteristic.setIsShow(1); characteristic.setIsShow(1);
characteristic.setIsHidden(1); characteristic.setIsHidden(1);
characteristic.setIsH3C(0);
characteristic.setCharacteristicType("否"); characteristic.setCharacteristicType("否");
Characteristic getOne = characteristicMapper.selectByCode(characteristic); Characteristic getOne = characteristicMapper.selectByCode(characteristic);
if (!ObjectUtils.isEmpty(getOne)) { if (!ObjectUtils.isEmpty(getOne)) {
...@@ -683,15 +684,15 @@ public class IntegrateServiceImpl implements IntegrateService { ...@@ -683,15 +684,15 @@ public class IntegrateServiceImpl implements IntegrateService {
GetProductOutDto result = new GetProductOutDto(); GetProductOutDto result = new GetProductOutDto();
UserInfo getOne = userInfoMapper.getUser(userinfo); UserInfo getOne = userInfoMapper.getUser(userinfo);
if (!ObjectUtils.isEmpty(getOne)) { if (!ObjectUtils.isEmpty(getOne)) {
String redis = redisHelper.get("unis_cpq:" + getOne.getUserCode()); String redis = redisHelper.get("unis_cpq:" + getOne.getUserCode().toUpperCase());
if (StringUtils.isEmpty(redis)) { if (StringUtils.isEmpty(redis)) {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
Date date = new Date(System.currentTimeMillis()); Date date = new Date(System.currentTimeMillis());
String md5Str = MD5Util.getMD5Str(getOne.getPassWord() + "_unis_cpq_" + getOne.getUserCode() + formatter.format(date)); String md5Str = MD5Util.getMD5Str(getOne.getPassword() + "_unis_cpq_" + getOne.getUserCode() + formatter.format(date));
String doubleMd5 = MD5Util.getMD5Str(md5Str); String doubleMd5 = MD5Util.getMD5Str(md5Str);
result.setData(doubleMd5); result.setData(doubleMd5);
result.setCode(200); result.setCode(200);
redisHelper.set("unis_cpq:" + getOne.getUserCode(), doubleMd5, 86400); redisHelper.set("unis_cpq:" + getOne.getUserCode().toUpperCase(), doubleMd5, 86400);
} else { } else {
result.setData(redis); result.setData(redis);
result.setCode(200); result.setCode(200);
...@@ -736,7 +737,7 @@ public class IntegrateServiceImpl implements IntegrateService { ...@@ -736,7 +737,7 @@ public class IntegrateServiceImpl implements IntegrateService {
GetProductOutDto result = new GetProductOutDto(); GetProductOutDto result = new GetProductOutDto();
UserInfo getOne = userInfoMapper.getUserOne(userinfo); UserInfo getOne = userInfoMapper.getUserOne(userinfo);
if (!ObjectUtils.isEmpty(getOne)) { if (!ObjectUtils.isEmpty(getOne)) {
String redis = redisHelper.get("unis_cpq:" + userinfo.getUserCode()); String redis = redisHelper.get("unis_cpq:" + userinfo.getUserCode().toUpperCase());
if (!StringUtils.isEmpty(redis)) { if (!StringUtils.isEmpty(redis)) {
if (userinfo.getToken().equals(redis)) { if (userinfo.getToken().equals(redis)) {
result.setMsg(null); result.setMsg(null);
...@@ -763,18 +764,18 @@ public class IntegrateServiceImpl implements IntegrateService { ...@@ -763,18 +764,18 @@ public class IntegrateServiceImpl implements IntegrateService {
public Object ldapAuth(UserInfo userinfo) { public Object ldapAuth(UserInfo userinfo) {
GetProductOutDto result = new GetProductOutDto(); GetProductOutDto result = new GetProductOutDto();
EqualsFilter filter = new EqualsFilter("sAMAccountName", userinfo.getUserCode()); EqualsFilter filter = new EqualsFilter("sAMAccountName", userinfo.getUserCode());
boolean authenticate = ldapTemplate.authenticate("", filter.toString(), userinfo.getPassWord()); boolean authenticate = ldapTemplate.authenticate("", filter.toString(), userinfo.getPassword());
//true 存在 //true 存在
if (authenticate) { if (authenticate) {
String redis = redisHelper.get("unis_cpq:" + userinfo.getUserCode()); String redis = redisHelper.get("unis_cpq:" + userinfo.getUserCode().toUpperCase());
if (StringUtils.isEmpty(redis)) { if (StringUtils.isEmpty(redis)) {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
Date date = new Date(System.currentTimeMillis()); Date date = new Date(System.currentTimeMillis());
String md5Str = MD5Util.getMD5Str(userinfo.getPassWord() + "_unis_cpq_" + userinfo.getUserCode() + formatter.format(date)); String md5Str = MD5Util.getMD5Str(userinfo.getPassword() + "_unis_cpq_" + userinfo.getUserCode() + formatter.format(date));
String doubleMd5 = MD5Util.getMD5Str(md5Str); String doubleMd5 = MD5Util.getMD5Str(md5Str);
result.setData(doubleMd5); result.setData(doubleMd5);
result.setCode(200); result.setCode(200);
redisHelper.set("unis_cpq:" + userinfo.getUserCode(), doubleMd5, 86400); redisHelper.set("unis_cpq:" + userinfo.getUserCode().toUpperCase(), doubleMd5, 86400);
//用于代码校验token //用于代码校验token
//redisHelper.set("unis_cpq:" + doubleMd5, doubleMd5, 86400); //redisHelper.set("unis_cpq:" + doubleMd5, doubleMd5, 86400);
} else { } else {
......
package cn.com.uitech.authorization.service.impl; package cn.com.uitech.authorization.service.impl;
import cn.com.uitech.authorization.exception.BizException;
import cn.com.uitech.authorization.exception.BusinessException; import cn.com.uitech.authorization.exception.BusinessException;
import cn.com.uitech.authorization.mapper.BasicsPriceInfoMapper; import cn.com.uitech.authorization.mapper.BasicsPriceInfoMapper;
import cn.com.uitech.authorization.mapper.SuperBomPriceCalculateMapper; import cn.com.uitech.authorization.mapper.SuperBomPriceCalculateMapper;
import cn.com.uitech.authorization.pojo.dto.CharacteristicValueExportDto;
import cn.com.uitech.authorization.pojo.dto.GetProductOutDto; import cn.com.uitech.authorization.pojo.dto.GetProductOutDto;
import cn.com.uitech.authorization.pojo.dto.SuperCharacterPriceInfoDto;
import cn.com.uitech.authorization.pojo.entity.*; import cn.com.uitech.authorization.pojo.entity.*;
import cn.com.uitech.authorization.service.BasicsPriceInfoService;
import cn.com.uitech.authorization.service.SuperBomPriceCalculateService; import cn.com.uitech.authorization.service.SuperBomPriceCalculateService;
import cn.com.uitech.authorization.utils.ApiResult;
import cn.com.uitech.authorization.utils.DateUitl;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.google.common.collect.Lists;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.openxml4j.util.ZipSecureFile;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
import java.text.DecimalFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
...@@ -240,4 +258,489 @@ public class SuperBomPriceCalculateServiceImpl implements SuperBomPriceCalculate ...@@ -240,4 +258,489 @@ public class SuperBomPriceCalculateServiceImpl implements SuperBomPriceCalculate
List<SuperCharacterPriceInfoEntity> list = superBomPriceCalculateMapper.getCharacterValueList(characteristicValue); List<SuperCharacterPriceInfoEntity> list = superBomPriceCalculateMapper.getCharacterValueList(characteristicValue);
return new PageInfo(list); return new PageInfo(list);
} }
@Override
public void exportCharacteristicValuePrice(CharacteristicValueExportDto dto, HttpServletResponse response) {
try {
Date date = DateUitl.getNowAll();
String format = DateUitl.format(date, "yyyy-MM-dd");
String[] split = format.split("-");
StringBuilder worktableTitle = new StringBuilder();
for (String string : split) {
worktableTitle.append(string);
}
String file = "";
List<SuperCharacterPriceInfoDto> priceModelList = new ArrayList<>();
List<SuperCharacterPriceInfoDto> excelDtos = new ArrayList<>();
HSSFWorkbook wb = new HSSFWorkbook();
file = "特征值价格" + worktableTitle + ".xls";
//根据页面输入框查询要导出的数据
priceModelList = superBomPriceCalculateMapper.exportCharacteristicValuePrice(dto);
if (ObjectUtils.isEmpty(priceModelList)) {
BasicsPriceInfoEntity basicsPriceInfoEntity = new BasicsPriceInfoEntity();
basicsPriceInfoEntity.setSuperBomCode(dto.getSuperBomCode());
basicsPriceInfoEntity.setBrand(dto.getBrand());
basicsPriceInfoEntity.setProductClassCode(dto.getProductClassCode());
basicsPriceInfoEntity.setPriceType(1);
BasicsPriceInfoEntity basicsPriceInfo;
basicsPriceInfo = superBomPriceCalculateMapper.getBasicsPriceInfo(basicsPriceInfoEntity);
if (ObjectUtils.isEmpty(basicsPriceInfo) && !StringUtils.isEmpty(basicsPriceInfoEntity.getSuperBomCode())) {
basicsPriceInfoEntity.setSuperBomCode(null);
basicsPriceInfo = superBomPriceCalculateMapper.getBasicsPriceInfo(basicsPriceInfoEntity);
if (ObjectUtils.isEmpty(basicsPriceInfo)) {
basicsPriceInfoEntity.setPriceType(2);
basicsPriceInfo = superBomPriceCalculateMapper.getBasicsPriceInfo(basicsPriceInfoEntity);
if (ObjectUtils.isEmpty(basicsPriceInfo) && !StringUtils.isEmpty(basicsPriceInfoEntity.getSuperBomCode())) {
basicsPriceInfoEntity.setSuperBomCode(null);
basicsPriceInfo = superBomPriceCalculateMapper.getBasicsPriceInfo(basicsPriceInfoEntity);
if (ObjectUtils.isEmpty(basicsPriceInfo)) {
throw new BusinessException(HttpStatus.INTERNAL_SERVER_ERROR.value(), "请维护价格系数!");
}
}
}
}
for (SuperCharacterPriceInfoDto superCharacterPriceInfoDto : priceModelList) {
if (basicsPriceInfo.getPriceType().equals(1)) {
superCharacterPriceInfoDto.setPriceType("成本定价法");
} else {
superCharacterPriceInfoDto.setPriceType("市场定价法");
}
}
}
excelDtos = exportStandBom(priceModelList);
wb = exportExcelBom(excelDtos);
String filename = null;
filename = new String(file.getBytes("GBK"), StandardCharsets.ISO_8859_1);
response.setContentType("APPLICATION/OCTET-STREAM");
response.setCharacterEncoding("utf-8");
response.setHeader("Content-Disposition", "attachment;filename=\"" + filename + "\"");
ServletOutputStream outputStream = response.getOutputStream();
wb.write(outputStream);
outputStream.close();
} catch (Exception e) {
throw new BizException(ApiResult.INTERNAL_SERVER_ERROR, e.getMessage());
}
}
private List<SuperCharacterPriceInfoDto> exportStandBom(List<SuperCharacterPriceInfoDto> priceModelList) {
List<SuperCharacterPriceInfoDto> excelDtos = new ArrayList<>();
for (SuperCharacterPriceInfoDto priceInfoDto : priceModelList) {
SuperCharacterPriceInfoDto dto = new SuperCharacterPriceInfoDto();
if (!ObjectUtils.isEmpty(priceInfoDto.getSuperBomCode())) {
dto.setSuperBomCode(priceInfoDto.getSuperBomCode());
} else {
dto.setSuperBomCode(null);
}
if (!ObjectUtils.isEmpty(priceInfoDto.getSuperBomName())) {
dto.setSuperBomName(priceInfoDto.getSuperBomName());
} else {
dto.setSuperBomName(null);
}
if (!ObjectUtils.isEmpty(priceInfoDto.getPriceType())) {
dto.setPriceType(priceInfoDto.getPriceType());
} else {
dto.setPriceType(null);
}
if (!ObjectUtils.isEmpty(priceInfoDto.getCharacterCode())) {
dto.setCharacterCode(priceInfoDto.getCharacterCode());
} else {
dto.setCharacterCode(null);
}
if (!ObjectUtils.isEmpty(priceInfoDto.getCharacterName())) {
dto.setCharacterName(priceInfoDto.getCharacterName());
} else {
dto.setCharacterName(null);
}
if (!ObjectUtils.isEmpty(priceInfoDto.getCharacterValueCode())) {
dto.setCharacterValueCode(priceInfoDto.getCharacterValueCode());
} else {
dto.setCharacterValueCode(null);
}
if (!ObjectUtils.isEmpty(priceInfoDto.getCharacterValueName())) {
dto.setCharacterValueName(priceInfoDto.getCharacterValueName());
} else {
dto.setCharacterValueName(null);
}
if (!ObjectUtils.isEmpty(priceInfoDto.getActualPrice())) {
dto.setActualPrice(priceInfoDto.getActualPrice());
} else {
dto.setActualPrice(null);
}
if (!ObjectUtils.isEmpty(priceInfoDto.getLeve0Price())) {
dto.setLeve0Price(priceInfoDto.getLeve0Price());
} else {
dto.setLeve0Price(null);
}
if (!ObjectUtils.isEmpty(priceInfoDto.getLeve1Price())) {
dto.setLeve1Price(priceInfoDto.getLeve1Price());
} else {
dto.setLeve1Price(null);
}
if (!ObjectUtils.isEmpty(priceInfoDto.getLeve2Price())) {
dto.setLeve2Price(priceInfoDto.getLeve2Price());
} else {
dto.setLeve2Price(null);
}
if (!ObjectUtils.isEmpty(priceInfoDto.getLeve3Price())) {
dto.setLeve3Price(priceInfoDto.getLeve3Price());
} else {
dto.setLeve3Price(null);
}
if (!ObjectUtils.isEmpty(priceInfoDto.getSuperBomCode())) {
dto.setLeve4Price(priceInfoDto.getLeve4Price());
} else {
dto.setLeve4Price(null);
}
if (!ObjectUtils.isEmpty(priceInfoDto.getActualPrice())) {
dto.setAgentPrice(priceInfoDto.getAgentPrice());
} else {
dto.setAgentPrice(null);
}
excelDtos.add(dto);
}
return excelDtos;
}
private HSSFWorkbook exportExcelBom(List<SuperCharacterPriceInfoDto> excelDtos) {
String[] excelHeader = new String[]{
"SuperBOM", "SuperBOM名称",
"定价类型", "特征编码",
"特征名称", "特征值编码",
"特征值名称", "真实成本",
"标准成本", "一级调整价",
"二级调整价", "三级调整价",
"四级调整价", "代理价"};
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet();
// 产生表格标题行
HSSFRow titleRow = sheet.createRow(1);
// 定义所需列数
int columnNum = excelHeader.length;
HSSFRow rowRowName = sheet.createRow(0); // 在索引2的位置创建行(最顶端的行开始的第二行)
// 将列头设置到sheet的单元格中
for (int n = 0; n < columnNum; n++) {
CellStyle style = workbook.createCellStyle();
HSSFCell cellRowName = rowRowName.createCell(n); // 创建列头对应个数的单元格
cellRowName.setCellType(HSSFCell.CELL_TYPE_STRING);
cellRowName.setCellValue(excelHeader[n]); // 设置列头单元格的值
style.setFillPattern(CellStyle.SOLID_FOREGROUND);
style.setFillForegroundColor(IndexedColors.WHITE.getIndex());
cellRowName.setCellStyle(style); // 设置列头单元格样式
}
// 添加表内容
for (int i = 0; i < excelDtos.size(); i++) {
HSSFRow ContentRow = sheet.createRow(i + 1);
if (ObjectUtils.isEmpty(excelDtos.get(i).getSuperBomCode())) {
ContentRow.createCell(0).setCellValue("");
} else {
ContentRow.createCell(0).setCellValue(excelDtos.get(i).getSuperBomCode());
}
if (ObjectUtils.isEmpty(excelDtos.get(i).getSuperBomName())) {
ContentRow.createCell(1).setCellValue("");
} else {
ContentRow.createCell(1).setCellValue(excelDtos.get(i).getSuperBomName());
}
if (ObjectUtils.isEmpty(excelDtos.get(i).getPriceType())) {
ContentRow.createCell(2).setCellValue("");
} else {
ContentRow.createCell(2).setCellValue(excelDtos.get(i).getPriceType());
}
if (ObjectUtils.isEmpty(excelDtos.get(i).getCharacterCode())) {
ContentRow.createCell(3).setCellValue("");
} else {
ContentRow.createCell(3).setCellValue(excelDtos.get(i).getCharacterCode());
}
if (ObjectUtils.isEmpty(excelDtos.get(i).getCharacterName())) {
ContentRow.createCell(4).setCellValue("");
} else {
ContentRow.createCell(4).setCellValue(excelDtos.get(i).getCharacterName());
}
if (ObjectUtils.isEmpty(excelDtos.get(i).getCharacterValueCode())) {
ContentRow.createCell(5).setCellValue("");
} else {
ContentRow.createCell(5).setCellValue(excelDtos.get(i).getCharacterValueCode());
}
if (ObjectUtils.isEmpty(excelDtos.get(i).getCharacterValueName())) {
ContentRow.createCell(6).setCellValue("");
} else {
ContentRow.createCell(6).setCellValue(excelDtos.get(i).getCharacterValueName());
}
if (ObjectUtils.isEmpty(excelDtos.get(i).getActualPrice())) {
ContentRow.createCell(7).setCellValue("");
} else {
ContentRow.createCell(7).setCellValue(excelDtos.get(i).getActualPrice());
}
if (ObjectUtils.isEmpty(excelDtos.get(i).getLeve0Price())) {
ContentRow.createCell(8).setCellValue("");
} else {
ContentRow.createCell(8).setCellValue(excelDtos.get(i).getLeve0Price());
}
if (ObjectUtils.isEmpty(excelDtos.get(i).getLeve1Price())) {
ContentRow.createCell(9).setCellValue("");
} else {
ContentRow.createCell(9).setCellValue(excelDtos.get(i).getLeve1Price());
}
if (ObjectUtils.isEmpty(excelDtos.get(i).getLeve2Price())) {
ContentRow.createCell(10).setCellValue("");
} else {
ContentRow.createCell(10).setCellValue(excelDtos.get(i).getLeve2Price());
}
if (ObjectUtils.isEmpty(excelDtos.get(i).getLeve3Price())) {
ContentRow.createCell(11).setCellValue("");
} else {
ContentRow.createCell(11).setCellValue(excelDtos.get(i).getLeve3Price());
}
if (ObjectUtils.isEmpty(excelDtos.get(i).getLeve4Price())) {
ContentRow.createCell(12).setCellValue("");
} else {
ContentRow.createCell(12).setCellValue(excelDtos.get(i).getLeve4Price());
}
if (ObjectUtils.isEmpty(excelDtos.get(i).getAgentPrice())) {
ContentRow.createCell(13).setCellValue("");
} else {
ContentRow.createCell(13).setCellValue(excelDtos.get(i).getAgentPrice());
}
}
// 让列宽随着导出的列长自动适应
for (int colNum = 0; colNum < columnNum; colNum++) {
int columnWidth = sheet.getColumnWidth(colNum) / 256;
for (int rowNum = 0; rowNum < sheet.getLastRowNum(); rowNum++) {
HSSFRow currentRow;
// 当前行未被使用过
if (sheet.getRow(rowNum) == null) {
currentRow = sheet.createRow(rowNum);
} else {
currentRow = sheet.getRow(rowNum);
}
if (currentRow.getCell(colNum) != null) {
HSSFCell currentCell = currentRow.getCell(colNum);
if (currentCell.getCellType() == HSSFCell.CELL_TYPE_STRING) {
int length = currentCell.getStringCellValue().getBytes().length;
if (columnWidth < length) {
columnWidth = length;
}
}
}
}
if (colNum == 0) {
sheet.setColumnWidth(colNum, (columnWidth - 2) * 256);
} else {
sheet.setColumnWidth(colNum, (columnWidth + 4) * 256);
}
}
return workbook;
}
/**
* @param file
* @return
* @desc 特征值价格管理 上传文件更新
*/
@Override
public String batchUpdateByUpload(MultipartFile file) {
int result = 0;
//判断文件是否为空
if (null == file || file.isEmpty()) {
throw new BizException(ApiResult.API_REQ_DATA_IS_FAIL, "特征值价格上传文件批量更新-上传文件为空");
}
//读取文件内容
List<SuperCharacterPriceInfoDto> list = uploadExcl(file);
//非空校验
if (!CollectionUtils.isEmpty(list)) {
ArrayList<String> checkFileIsNull = checkFileIsNull(list);
if (!CollectionUtils.isEmpty(checkFileIsNull)) {
return String.valueOf(checkFileIsNull);
}
} else {
}
updateData(list);
return "更新附件内容成功";
}
/**
* @param list
*/
public void updateData(List<SuperCharacterPriceInfoDto> list) {
//更新数据库里数据
ArrayList<Characteristics> updateList = new ArrayList<>();
list.stream().forEach((dto) -> {
Characteristics vPrice = new Characteristics();
vPrice.setSuperBomCode(dto.getSuperBomCode());
vPrice.setCharacteristicCode(dto.getCharacterCode());
vPrice.setCharacteristicName(dto.getCharacterName());
vPrice.setCharacteristicValueCode(dto.getCharacterValueCode());
vPrice.setCharacteristicValueName(dto.getCharacterValueName());
if(!org.springframework.util.StringUtils.isEmpty(dto.getActualPrice())){
vPrice.setActualPrice(BigDecimal.valueOf(Double.valueOf(dto.getActualPrice())));
}
if(!org.springframework.util.StringUtils.isEmpty(dto.getLeve0Price())){
vPrice.setLeve0Price(BigDecimal.valueOf(Double.valueOf(dto.getLeve0Price())));
}
if(!org.springframework.util.StringUtils.isEmpty(dto.getLeve1Price())){
vPrice.setLeve1Price(BigDecimal.valueOf(Double.valueOf(dto.getLeve1Price())));
}
if(!org.springframework.util.StringUtils.isEmpty(dto.getLeve2Price())){
vPrice.setLeve2Price(BigDecimal.valueOf(Double.valueOf(dto.getLeve2Price())));
}
if(!org.springframework.util.StringUtils.isEmpty(dto.getLeve3Price())){
vPrice.setLeve3Price(BigDecimal.valueOf(Double.valueOf(dto.getLeve3Price())));
}
if(!org.springframework.util.StringUtils.isEmpty(dto.getLeve4Price())){
vPrice.setLeve4Price(BigDecimal.valueOf(Double.valueOf(dto.getLeve4Price())));
}
if(!org.springframework.util.StringUtils.isEmpty(dto.getAgentPrice())){
vPrice.setAgentPrice(BigDecimal.valueOf(Double.valueOf(dto.getAgentPrice())));
}
updateList.add(vPrice);
});
for (Characteristics info : updateList) {
superBomPriceCalculateMapper.updateCharacteristicInfo(info);
}
}
/**
* @param list
* @return
* @desc 对上传的数据做非空校验
*/
public ArrayList<String> checkFileIsNull(List<SuperCharacterPriceInfoDto> list) {
ArrayList<String> checkList = new ArrayList<>();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < list.size(); i++) {
SuperCharacterPriceInfoDto item = list.get(i);
if (StringUtils.isBlank(item.getSuperBomCode())) {
sb.append("SuperBom编号不能为空");
}
if (StringUtils.isBlank(item.getCharacterCode())) {
sb.append("特征编号不能为空");
}
if (StringUtils.isBlank(item.getCharacterValueCode())) {
sb.append("特征值编号不能为空");
}
if (StringUtils.isNotBlank(sb.toString())) {
sb.insert(0, "上传文件的第" + i + "行数据:");
checkList.add(sb.toString());
}
}
return checkList;
}
/**
* @param file
* @return List<SuperCharacterPriceInfoDto>
* @desc 解析上传文件
*/
public List<SuperCharacterPriceInfoDto> uploadExcl(MultipartFile file) {
long startDate = Calendar.getInstance().getTimeInMillis();
List<SuperCharacterPriceInfoDto> list = Lists.newArrayList();
Workbook wook = null;
try {
String filename = file.getOriginalFilename();
if (filename.endsWith("xls")) {
ZipSecureFile.setMinInflateRatio(-1.0d);
wook = new HSSFWorkbook(file.getInputStream());
} else if (filename.endsWith("xlsx")) {
ZipSecureFile.setMinInflateRatio(-1.0d);
wook = new XSSFWorkbook(file.getInputStream());
}
int numberOfSheets = wook.getNumberOfSheets();
for (int i = 0; i < numberOfSheets; i++) {
Sheet sheetAt = wook.getSheetAt(i);
int rows = sheetAt.getPhysicalNumberOfRows();
for (int j = 1; j < rows; j++) {
Row row = sheetAt.getRow(j);
int cells = row.getPhysicalNumberOfCells();
//把每条数据封装进对象里
SuperCharacterPriceInfoDto dto = setCharacteristicPriceExportDto(row, cells);
list.add(dto);
}
}
} catch (Exception e) {
e.printStackTrace();
}
long endDate = Calendar.getInstance().getTimeInMillis();
return list;
}
/**
* @param row
* @param cells
* @return SuperCharacterPriceInfoDto
* @desc 把excel每行数据返回一个对象
*/
public SuperCharacterPriceInfoDto setCharacteristicPriceExportDto(Row row, int cells) {
SuperCharacterPriceInfoDto dto = new SuperCharacterPriceInfoDto();
try {
for (int i = 0; i < cells; i++) {
//读取到内存的只保留有更新逻辑的字段
dto.setSuperBomCode(getCellValueByCell(row.getCell(0)));
dto.setSuperBomName(getCellValueByCell(row.getCell(1)));
dto.setPriceType(getCellValueByCell(row.getCell(2)));
dto.setCharacterCode(getCellValueByCell(row.getCell(3)));
dto.setCharacterName(getCellValueByCell(row.getCell(4)));
dto.setCharacterValueCode(getCellValueByCell(row.getCell(5)));
dto.setCharacterValueName(getCellValueByCell(row.getCell(6)));
dto.setActualPrice(getCellValueByCell(row.getCell(7)));
dto.setLeve0Price(getCellValueByCell(row.getCell(8)));
dto.setLeve1Price(getCellValueByCell(row.getCell(9)));
dto.setLeve2Price(getCellValueByCell(row.getCell(10)));
dto.setLeve3Price(getCellValueByCell(row.getCell(11)));
dto.setLeve4Price(getCellValueByCell(row.getCell(12)));
dto.setAgentPrice(getCellValueByCell(row.getCell(13)));
}
} catch (Exception e) {
e.printStackTrace();
}
return dto;
}
/**
* @param cell
* @return
* @desc 获取单元格各类型值,返回字符串类型
*/
private String getCellValueByCell(Cell cell) {
//判断是否为null或空串
if (cell == null || cell.toString().trim().equals("")) {
return "";
}
String cellValue = "";
int cellType = cell.getCellType();
switch (cellType) {
case Cell.CELL_TYPE_STRING: //字符串类型
cellValue = cell.getStringCellValue().trim();
break;
case Cell.CELL_TYPE_BOOLEAN: //布尔类型
cellValue = String.valueOf(cell.getBooleanCellValue());
break;
case Cell.CELL_TYPE_NUMERIC: //数值类型
if (HSSFDateUtil.isCellDateFormatted(cell)) { //判断日期类型
cellValue = DateFormatUtils.format(cell.getDateCellValue(), "yyyy-MM-dd");
} else { //否
cellValue = new DecimalFormat("#.######").format(cell.getNumericCellValue());
}
break;
default: //其它类型,取空串吧
cellValue = "";
break;
}
return cellValue;
}
} }
...@@ -21,7 +21,6 @@ import java.util.List; ...@@ -21,7 +21,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
@Service @Service
@Transactional
public class TempServiceImpl implements TempServer { public class TempServiceImpl implements TempServer {
@Autowired @Autowired
...@@ -37,6 +36,8 @@ public class TempServiceImpl implements TempServer { ...@@ -37,6 +36,8 @@ public class TempServiceImpl implements TempServer {
GetProductOutDto result = new GetProductOutDto(); GetProductOutDto result = new GetProductOutDto();
//获取未开始的信息进行操作 //获取未开始的信息进行操作
DeployTempParam deployTempParam = tempMapper.getTempList(); DeployTempParam deployTempParam = tempMapper.getTempList();
List<DeployTempItemParam> deployTempItemParamList = tempMapper.getTempListBySkuCode(deployTempParam.getOldSkuCode());
deployTempParam.setDeployTempItemParams(deployTempItemParamList);
if(!ObjectUtils.isEmpty(deployTempParam)){ if(!ObjectUtils.isEmpty(deployTempParam)){
//循环生成configid,保存sku信息,申请sku //循环生成configid,保存sku信息,申请sku
//构建生成配置参数 //构建生成配置参数
...@@ -103,6 +104,8 @@ public class TempServiceImpl implements TempServer { ...@@ -103,6 +104,8 @@ public class TempServiceImpl implements TempServer {
JSONObject data = (JSONObject) map.get("data"); JSONObject data = (JSONObject) map.get("data");
result.setCode(200); result.setCode(200);
result.setData(data); result.setData(data);
deployTempParam.setStatus("已完成");
tempMapper.updateTemp(deployTempParam);
} else { } else {
String msg = (String) map.get("msg"); String msg = (String) map.get("msg");
...@@ -120,11 +123,12 @@ public class TempServiceImpl implements TempServer { ...@@ -120,11 +123,12 @@ public class TempServiceImpl implements TempServer {
result.setMsg(msg); result.setMsg(msg);
} }
} }
getTempList();
}else{ }else{
result.setCode(200); result.setCode(200);
result.setMsg("数据初始化完成"); result.setMsg("数据初始化完成");
return result;
} }
getTempList();
return result; return result;
} }
} }
package cn.com.uitech.authorization.utils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class DateUitl {
public static final String PATTERN_DATE_1 = "yyyy-MM-dd";
public static final String PATTERN_DATE_2 = "HH:mm:ss";
public static final String PATTERN_DATE_3 = "yyyy-MM-dd HH:mm:ss";
private DateUitl() {
}
public static String getPreDay(String dateString, int i) throws ParseException{
Date day=parseDate(dateString,DateUitl.PATTERN_DATE_1);
Calendar cal=Calendar.getInstance();
cal.setTime(day);
cal.add(cal.DAY_OF_MONTH,-i);
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
String mDateTime = formatter.format(cal.getTime());
Date date = parseDate(mDateTime, DateUitl.PATTERN_DATE_1);
String str = format(date, DateUitl.PATTERN_DATE_1);
System.err.println(str);
return str;
}
public static String getNextDay(String dateString, int i) throws ParseException{
Date day=parseDate(dateString,DateUitl.PATTERN_DATE_1);
Calendar cal=Calendar.getInstance();
cal.setTime(day);
cal.add(cal.DAY_OF_MONTH,i);
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
String mDateTime = formatter.format(cal.getTime());
Date date = parseDate(mDateTime, DateUitl.PATTERN_DATE_1);
String str = format(date, DateUitl.PATTERN_DATE_1);
return str;
}
// 将字符串类型格式化为日期类型
public static Date parseDate(String dateString, String pattern) throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
Date date = null;
try {
date = sdf.parse(dateString);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
throw e;
}
return date;
}
// 将日期类型格式化为字符串类型
public static String format(Date date, String pattern) {
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
return sdf.format(date);
}
// 获取当前系统时间(字符串类型)
public static String getCurrentDate() {
return format(new Date(), DateUitl.PATTERN_DATE_3);
}
// 获取当前系统时间(字符串类型)
public static String getCurrentDate(String pattern) {
return format(new Date(), pattern);
}
// 得到当前系统时间,包含年、月、日、时、分、秒
public static Date getNowAll() throws ParseException {
return parseDate(getCurrentDate(), DateUitl.PATTERN_DATE_3);
}
// 得到当前系统时间,包含年、月、日
public static Date getNowDate() throws ParseException {
return parseDate(getCurrentDate(), DateUitl.PATTERN_DATE_1);
}
/**
* 得到当前日期的前一天
* @throws ParseException
* */
@SuppressWarnings("static-access")
public static Date getPreDay() throws ParseException {
Calendar cal = Calendar.getInstance();
cal.add(cal.DAY_OF_MONTH, -1);
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
String mDateTime = formatter.format(cal.getTime());
Date date = parseDate(mDateTime, DateUitl.PATTERN_DATE_1);
return date;
}
@SuppressWarnings("static-access")
public static String getPreDay(int i) throws ParseException {
Calendar cal = Calendar.getInstance();
cal.add(cal.DAY_OF_MONTH, i);
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
String mDateTime = formatter.format(cal.getTime());
Date date = parseDate(mDateTime, DateUitl.PATTERN_DATE_1);
String str = format(date, DateUitl.PATTERN_DATE_1);
return str;
}
/**
* 得到当前日期的 后一天
* @throws ParseException
* */
@SuppressWarnings("static-access")
public static Date getNextDay() throws ParseException {
Calendar cal = Calendar.getInstance();
cal.add(cal.DAY_OF_MONTH, 1);
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
String mDateTime = formatter.format(cal.getTime());
Date date = parseDate(mDateTime, DateUitl.PATTERN_DATE_1);
return date;
}
@SuppressWarnings("static-access")
public static String getNextDay(int i) throws ParseException {
Calendar cal = Calendar.getInstance();
cal.add(cal.DAY_OF_MONTH, i);
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
String mDateTime = formatter.format(cal.getTime());
Date date = parseDate(mDateTime, DateUitl.PATTERN_DATE_1);
String str = format(date, DateUitl.PATTERN_DATE_1);
return str;
}
/**
* 得到当天星期几,用(1234567)表示
* */
@SuppressWarnings("deprecation")
public static int getWeekDate() {
Date date = new Date();
int weekDate = date.getDay();
if (weekDate == 0) {
weekDate = 7;
}
return weekDate;
}
/**
* 得到当天星期几,用(1234567)表示
* @param handleDate 传入日期
* @return
* int
*/
@SuppressWarnings("deprecation")
public static int getWeekDate(Date handleDate) {
int weekDate = handleDate.getDay();
if (weekDate == 0) {
weekDate = 7;
}
return weekDate;
}
/***
* 比较两个时间相差的分钟数。
*
* @param:firstTime 比较小的时间 secondTime 比较大的时间
* @return:Integer :分钟数
* */
public static Long compare(Date firstTime, Date secondTime) {
Long minutes = (secondTime.getTime() - firstTime.getTime())
/ (1000 * 60);
return minutes;
}
/**
* 比较两个时间相差的天数
* @param firstTime
* @param secondTime
* @return
* Long
*/
public static Long compareOfDay(Date firstTime, Date secondTime) {
Long days = (secondTime.getTime() - firstTime.getTime())
/ (1000 * 60*60*24);
return days;
}
/**
* 获取当前日期所在的星期几
*
* @param currentDate
* @since 1.0.0
*/
public static int getDayOfWeek(Date currentDate) {
Calendar cal = Calendar.getInstance();
cal.setTime(currentDate);
// 获取当天所在的星期
int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK) - 1;
// 处理周日
if (dayOfWeek == 0) {
dayOfWeek = 7;
}
return dayOfWeek;
}
@SuppressWarnings("static-access")
public static String getDayOfWeekInfo(int i) {
String result = "";
switch (i) {
case 1:
result = "星期一";
break;
case 2:
result = "星期二";
break;
case 3:
result = "星期三";
break;
case 4:
result = "星期四";
break;
case 5:
result = "星期五";
break;
case 6:
result = "星期六";
break;
default:
result = "星期日";
break;
}
return result;
}
}
...@@ -12,6 +12,7 @@ import org.apache.poi.ss.util.CellRangeAddress; ...@@ -12,6 +12,7 @@ import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.CellRangeAddressList; import org.apache.poi.ss.util.CellRangeAddressList;
import org.apache.poi.xssf.streaming.SXSSFWorkbook; import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFDataValidation; import org.apache.poi.xssf.usermodel.XSSFDataValidation;
import org.springframework.util.ObjectUtils;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
...@@ -277,7 +278,7 @@ public class ProductExportUtils { ...@@ -277,7 +278,7 @@ public class ProductExportUtils {
* @param list 表中元素 * @param list 表中元素
* @return * @return
*/ */
public static SXSSFWorkbook getSXSSFWorkbook(String sheetName, ArrayList<String> titList,List<String[]> list){ public static SXSSFWorkbook getSXSSFWorkbook(String sheetName, ArrayList<String> titList,List<String[]> list,Integer temp){
//创建一个HSSFWorkbook,对应一个Excel文件 //创建一个HSSFWorkbook,对应一个Excel文件
SXSSFWorkbook sxssfWorkbook = new SXSSFWorkbook(); SXSSFWorkbook sxssfWorkbook = new SXSSFWorkbook();
//在workbook中添加一个sheet,对应Excel文件中的sheet //在workbook中添加一个sheet,对应Excel文件中的sheet
...@@ -288,13 +289,20 @@ public class ProductExportUtils { ...@@ -288,13 +289,20 @@ public class ProductExportUtils {
long timeInMillis = Calendar.getInstance().getTimeInMillis(); long timeInMillis = Calendar.getInstance().getTimeInMillis();
//给可卖可见增加下拉效果 if(!ObjectUtils.isEmpty(temp)){
String[] status = new String[]{"可卖","不可卖"}; if(temp == 1){
String[] visible = new String[]{"PM可见","全部可见","隐藏"}; //给可卖可见增加下拉效果
DataValidation dataValidation = getDataValidation(sheet,status,1, list.size(),5); String[] status = new String[]{"是","否"};
DataValidation dataValidation1 = getDataValidation(sheet,visible, 1, list.size(), 6); DataValidation dataValidation = getDataValidation(sheet,status,1, list.size(),5);
sheet.addValidationData(dataValidation); sheet.addValidationData(dataValidation);
sheet.addValidationData(dataValidation1); }else if(temp == 2){
//给可卖可见增加下拉效果
String[] status = new String[]{"可卖","不可卖"};
DataValidation dataValidation = getDataValidation(sheet,status,1, list.size(),6);
sheet.addValidationData(dataValidation);
}
}
//产生表头 //产生表头
Row row1 = sheet.createRow(0); Row row1 = sheet.createRow(0);
......
...@@ -233,4 +233,40 @@ ...@@ -233,4 +233,40 @@
<select id="getCharacteristicInfo" resultType="java.lang.Integer"> <select id="getCharacteristicInfo" resultType="java.lang.Integer">
select is_h3c isH3C from super_characteristic_info where characteristic_Code = #{characteristicCode} and super_bom_code = #{superBomCode} select is_h3c isH3C from super_characteristic_info where characteristic_Code = #{characteristicCode} and super_bom_code = #{superBomCode}
</select> </select>
<select id="exportCharacteristic" resultType="cn.com.uitech.authorization.pojo.dto.CharacteristicExportDto">
select
sort,
a.super_bom_code as superBomCode,
characteristic_code as characteristicCode,
characteristic_name as characteristicName,
unis_sales_c_name as unisSalesCName,
case when is_h3c = 0
then '否'
else '是'
end as isH3C
from
super_characteristic_info a
left join super_bom_info b on a.super_bom_code = b.super_bom_code
<where>
<if test="superBomCode!='' and superBomCode != null">
a.super_bom_code = #{superBomCode}
</if>
<if test="productClassCode!=null and productClassCode!=''">
AND b.product_class_code=#{productClassCode}
</if>
<if test="brand!=null and brand!=''">
AND b.brand=#{brand}
</if>
<if test="characteristicCode!=null and characteristicCode!=''">
AND a.characteristic_code=#{characteristicCode}
</if>
</where>
order by sort asc
</select>
<update id="updateCharacteristicInfo">
update super_characteristic_info set is_h3c = #{isH3C} , unis_sales_c_name = #{unisSalesCName} , sort = #{sort}
where super_bom_code = #{superBomCode} and characteristic_Code = #{characteristicCode}
</update>
</mapper> </mapper>
...@@ -162,53 +162,44 @@ ...@@ -162,53 +162,44 @@
<select id="exportCharacteristicValue" <select id="exportCharacteristicValue"
parameterType="cn.com.uitech.authorization.pojo.dto.CharacteristicValueRequestParamDto" parameterType="cn.com.uitech.authorization.pojo.dto.CharacteristicValueRequestParamDto"
resultType="cn.com.uitech.authorization.pojo.dto.CharacteristicValueExportDto"> resultType="cn.com.uitech.authorization.pojo.dto.CharacteristicValueExportDto">
SELECT * SELECT DISTINCT
FROM ( a.super_bom_code as superBomCode,
SELECT a.Characteristic_Code as CharacteristicCode,
c.super_bom_NAME AS "bomName", b.unis_Sales_C_Name as CharacteristicName,
a.Characteristic_Value_Code as CharacteristicValueCode, A.Characteristic_Value_Code AS CharacteristicValueCode,
c.super_bom_Code as superBomCode, A.Characteristic_Value_name AS CharacteristicValueName,
c.product_class_code as productClassCode, A.unis_Sales_V_Name AS unisSalesVName,
d.product_class_name as productClassName, CASE
case when a.is_sate=1 then '可卖' WHEN A.is_state = 1 THEN
else '不可卖' end as "isStatus", '可卖' ELSE'不可卖'
case when a.isShow=1 then '全部可见' END AS "isState",
when a.isShow=2 then 'PM可见' A.zph_Code AS zphCode,
when a.isShow=3 then '隐藏' A.zph_Name AS zphName,
end as "isShow", A.qualify_Date AS qualifyDate,
case when c.is_state=1 then '可卖' A.h3c_C_Value AS h3cCValue,
else '不可卖' end as "bomStatus", b.sort
a.characteristic_value_name as characteristicValueName, FROM
b.characteristic_name as characteristicName super_characteristic_value_info
FROM super_characteristic_value_info a A LEFT JOIN super_characteristic_info b ON A.Characteristic_Code = b.Characteristic_Code
LEFT JOIN super_characteristic_info b ON a.Characteristic_Code=b.Characteristic_Code LEFT JOIN super_bom_info C ON b.super_BOM_Code = c.super_BOM_Code
LEFT JOIN super_bom_info c ON characteristic.BOMCode=configurablebom.BOMCode
LEFT JOIN a_productclasscode d on d.product_class_code=c.product_class_code
<where> <where>
1=1
<if test="productClassCode!=null and productClassCode!=''"> <if test="productClassCode!=null and productClassCode!=''">
AND c.Product_class_Code=#{productClassCode} c.Product_class_Code=#{productClassCode}
</if> </if>
<if test="characteristicCode!=null and characteristicCode!=''"> <if test="characteristicCode!=null and characteristicCode!=''">
and a.Characteristic_Code=#{characteristicCode} and a.Characteristic_Code=#{characteristicCode}
</if> </if>
<if test="characteristicValueCode!=null and characteristicValueCode!=''"> <if test="characteristicValueCode!=null and characteristicValueCode!=''">
and a.Characteristic_Value_Code like CONCAT('%','${characteristicValueCode}','%') and a.Characteristic_Value_Code = #{characteristicValueCode}
</if> </if>
<if test="superBomCode!=null and superBomCode!=''"> <if test="superBomCode!=null and superBomCode!=''">
and c.super_bom_code=#{superBomCode} and a.super_bom_code=#{superBomCode}
</if> </if>
<if test="characteristicValueName!=null and characteristicValueName!=''"> <if test="brand!=null and brand!=''">
and a.characteristic_value_name like CONCAT('%','${characteristicValueName}','%') and c.brand = #{brand}
</if>
<if test="bomStatus!=null">
and c.is_state=#{bomStatus}
</if>
<if test="status!=null">
and a.is_state=#{status}
</if> </if>
</where> </where>
)a order by b.sort asc
</select> </select>
...@@ -346,4 +337,9 @@ ...@@ -346,4 +337,9 @@
where h3c_c_value = #{h3cVCode} where h3c_c_value = #{h3cVCode}
and super_bom_code = #{h3cPn} and super_bom_code = #{h3cPn}
</select> </select>
<update id="updateCharacteristicValue">
update super_characteristic_value_info set unis_sales_v_name = #{unisSalesVName},h3c_c_value = #{h3cCValue}, h3c_Deliver_Code = #{h3cDeliverCode}
where super_bom_code = #{superBomCode} and characteristic_Code = #{characteristicCode} and characteristic_Value_Code = #{characteristicValueCode}
</update>
</mapper> </mapper>
...@@ -136,4 +136,70 @@ ...@@ -136,4 +136,70 @@
</if> </if>
</where> </where>
</select> </select>
<select id="exportCharacteristicValuePrice"
resultType="cn.com.uitech.authorization.pojo.dto.SuperCharacterPriceInfoDto">
select a.super_bom_name as superBomName,
a.super_bom_code as superBomCode,
b.characteristic_code AS characterCode,
b.characteristic_name AS characterName,
c.characteristic_value_name AS characterValueName,
c.characteristic_value_code AS characterValueCode,
case when d.price_type = 1
then '成本定价法'
else '市场定价法'
end as priceType,
e.actual_price AS actualPrice,
e.leve0_price AS leve0Price,
e.leve1_price AS leve1Price,
e.leve2_price AS leve2Price,
e.leve3_price AS leve3Price,
e.leve4_price AS leve4Price,
e.agent_price AS agentprice,
b.sort
from super_bom_info a
inner join super_characteristic_info b
on a.super_bom_code = b.super_bom_code
inner join super_characteristic_value_info c
on a.super_bom_code = c.super_bom_code and b.characteristic_code = c.characteristic_code
-- 查系数
inner join basics_price_info d on a.super_bom_code = d.super_bom_code
and a.brand = d.brand
and a.product_class_code = d.product_class_code
left join super_character_price_info e on a.super_bom_code = e.super_bom_code
and b.characteristic_code = e.character_code and c.characteristic_value_code = e.character_value_code
<where>
<if test="superBomCode != null and superBomCode != ''.toString()">
a.super_bom_code = #{superBomCode}
</if>
<if test="characteristicValueCode != null and characteristicValueCode != ''.toString()">
and c.characteristic_value_code like CONCAT('%','${characteristicValueCode}','%')
</if>
<if test="characteristicCode != null and characteristicCode != ''.toString()">
and b.characteristic_code = #{characteristicCode}
</if>
<if test="brand != null and brand != ''.toString()">
and a.brand = #{brand}
</if>
<if test="productClassCode != null and productClassCode != ''.toString()">
and a.product_class_code = #{productClassCode}
</if>
</where>
order by b.sort asc
</select>
<update id="updateCharacteristicInfo">
update super_character_price_info set
agent_Price = #{agentPrice} ,
actual_Price = #{actualPrice} ,
leve0_price =#{leve0Price},
leve1_price = #{leve1Price},
leve2_price = #{leve2Price},
leve3_price = #{leve3Price},
leve4_price = #{leve4Price},
update_time = now()
where super_bom_code = #{superBomCode}
and character_Code = #{characteristicCode}
and character_Value_Code = #{characteristicValueCode}
</update>
</mapper> </mapper>
...@@ -21,12 +21,16 @@ ...@@ -21,12 +21,16 @@
<result property="characteristicValueName" column="characteristic_value_name"/> <result property="characteristicValueName" column="characteristic_value_name"/>
</collection> </collection>
</resultMap> </resultMap>
<select id="getTempList" resultMap="DeployTempMap"> <select id="getTempList" resultType="cn.com.uitech.authorization.pojo.dto.DeployTempParam">
select * from deploy_temp a left join deploy_temp_item b on a.old_sku_code = b.old_sku_code select * from deploy_temp
where a.status = '未开始' where status = '未开始' limit 1
</select> </select>
<update id="updateTemp"> <update id="updateTemp">
update deploy_temp set description = #{description} , status = #{status} where old_sku_code = #{oldSkuCode} update deploy_temp set description = #{description} , status = #{status} where old_sku_code = #{oldSkuCode}
</update> </update>
<select id="getTempListBySkuCode" resultType="cn.com.uitech.authorization.pojo.dto.DeployTempItemParam">
select * from deploy_temp_item where old_sku_code = #{oldSkuCode}
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<mapper namespace="cn.com.uitech.authorization.mapper.UserInfoMapper"> <mapper namespace="cn.com.uitech.authorization.mapper.UserInfoMapper">
<select id="getUser" resultType="cn.com.uitech.authorization.pojo.entity.UserInfo"> <select id="getUser" resultType="cn.com.uitech.authorization.pojo.entity.UserInfo">
select * from user_info where user_code = #{userCode} and pass_word = #{passWord} select * from user_info where user_code = #{userCode} and pass_word = #{password}
</select> </select>
<select id="getUserDimension" resultType="cn.com.uitech.authorization.pojo.entity.MenuInfo"> <select id="getUserDimension" resultType="cn.com.uitech.authorization.pojo.entity.MenuInfo">
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
user_menu_info user_menu_info
A LEFT JOIN menu_info b ON A.menu_id = b.menu_id A LEFT JOIN menu_info b ON A.menu_id = b.menu_id
WHERE WHERE
A.user_code = #{userCode} upper(A.user_code) = upper(#{userCode})
</select> </select>
<select id="getUserOne" resultType="cn.com.uitech.authorization.pojo.entity.UserInfo"> <select id="getUserOne" resultType="cn.com.uitech.authorization.pojo.entity.UserInfo">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment