|
|
@@ -28,6 +28,8 @@ import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
|
|
|
import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType;
|
|
|
import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@@ -47,6 +49,10 @@ import java.util.stream.Stream;
|
|
|
*/
|
|
|
@Service
|
|
|
public class HxpChemicalServiceImpl implements IHxpChemicalService {
|
|
|
+
|
|
|
+
|
|
|
+ private Logger logger = LoggerFactory.getLogger(HxpChemicalServiceImpl.class);
|
|
|
+
|
|
|
@Autowired
|
|
|
private HxpChemicalMapper hxpChemicalMapper;
|
|
|
@Autowired
|
|
|
@@ -85,24 +91,23 @@ public class HxpChemicalServiceImpl implements IHxpChemicalService {
|
|
|
@Override
|
|
|
@DataScope(deptAlias = "su", userAlias = "su", permi = PerPrefix.HPX_CHEMICAL)
|
|
|
public List<HxpChemicalVo> selectHxpChemicalList(HxpChemicalSearch hxpChemicalSearch) {
|
|
|
- List<HxpChemicalVo> hxpChemicalList = hxpChemicalMapper.selectHxpChemicalList(hxpChemicalSearch);
|
|
|
- return hxpChemicalList;
|
|
|
+ return hxpChemicalMapper.selectHxpChemicalList(hxpChemicalSearch);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List <HxpChemicalByExcel> importUserByChemical(List <HxpChemicalByExcel> chemicalList, String operName, HxpChemicalByExcel hxpChemicalByExcel) {
|
|
|
- if (StringUtils.isNull(chemicalList) || chemicalList.size() == 0) {
|
|
|
+ public List<HxpChemicalByExcel> importUserByChemical(List<HxpChemicalByExcel> chemicalList, String operName, HxpChemicalByExcel hxpChemicalByExcel) {
|
|
|
+ if (StringUtils.isNull(chemicalList) || chemicalList.isEmpty()) {
|
|
|
throw new ServiceException("导入危险品数据不能为空!");
|
|
|
}
|
|
|
List<HxpChemicalByExcel> failChemicalList = new ArrayList<>();
|
|
|
for (HxpChemicalByExcel chemical : chemicalList) {
|
|
|
//流水线验证
|
|
|
- flowLineCheck(chemical,failChemicalList, hxpChemicalByExcel);
|
|
|
+ flowLineCheck(chemical, failChemicalList, hxpChemicalByExcel);
|
|
|
}
|
|
|
return failChemicalList;
|
|
|
}
|
|
|
|
|
|
- private void flowLineCheck(HxpChemicalByExcel chemical, List<HxpChemicalByExcel> failChemicalList, HxpChemicalByExcel hxpChemicalByExcel){
|
|
|
+ private void flowLineCheck(HxpChemicalByExcel chemical, List<HxpChemicalByExcel> failChemicalList, HxpChemicalByExcel hxpChemicalByExcel) {
|
|
|
// 校验是否装入错误数据
|
|
|
boolean checkBox = true;
|
|
|
|
|
|
@@ -110,61 +115,61 @@ public class HxpChemicalServiceImpl implements IHxpChemicalService {
|
|
|
HxpChemical hxpChemical = new HxpChemical();
|
|
|
|
|
|
//验证化学品名称不能为空
|
|
|
- if(StringUtils.isEmpty(chemical.getChemicalName())){
|
|
|
- if(checkBox){
|
|
|
+ if (StringUtils.isEmpty(chemical.getChemicalName())) {
|
|
|
+ if (checkBox) {
|
|
|
chemical.getFailRemark().append("失败:");
|
|
|
failChemicalList.add(chemical);
|
|
|
checkBox = false;
|
|
|
}
|
|
|
chemical.getFailRemark().append("化学品名称不能为空、");
|
|
|
- }else{
|
|
|
- if(chemical.getChemicalName().length()>150){
|
|
|
- if(checkBox){
|
|
|
+ } else {
|
|
|
+ if (chemical.getChemicalName().length() > 30) {
|
|
|
+ if (checkBox) {
|
|
|
chemical.getFailRemark().append("失败:");
|
|
|
failChemicalList.add(chemical);
|
|
|
checkBox = false;
|
|
|
}
|
|
|
- chemical.getFailRemark().append("化学品名称最多一百五十个字符、");
|
|
|
+ chemical.getFailRemark().append("化学品名称最多三十个字符、");
|
|
|
}
|
|
|
}
|
|
|
hxpChemical.setChemicalName(chemical.getChemicalName());
|
|
|
|
|
|
//分类名称
|
|
|
- if(StringUtils.isEmpty(chemical.getClassifyName())){
|
|
|
- if(checkBox){
|
|
|
+ if (StringUtils.isEmpty(chemical.getClassifyName())) {
|
|
|
+ if (checkBox) {
|
|
|
chemical.getFailRemark().append("失败:");
|
|
|
failChemicalList.add(chemical);
|
|
|
checkBox = false;
|
|
|
}
|
|
|
chemical.getFailRemark().append("分类名称不能为空、");
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
//化学品分类配置读取
|
|
|
List<HxpChemicalClassify> classifyList = redisService.getCacheObject("chemical_classify");
|
|
|
- if (classifyList==null || classifyList.size()==0){
|
|
|
+ if (classifyList == null || classifyList.isEmpty()) {
|
|
|
HxpChemicalClassify hxpChemicalClassify = new HxpChemicalClassify();
|
|
|
classifyList = hxpChemicalClassifyMapper.selectHxpChemicalClassifyList(hxpChemicalClassify);
|
|
|
- redisService.setCacheObject("chemical_classify",classifyList, 60L, TimeUnit.SECONDS);
|
|
|
+ redisService.setCacheObject("chemical_classify", classifyList, 60L, TimeUnit.SECONDS);
|
|
|
classifyList = redisService.getCacheObject("chemical_classify");
|
|
|
}
|
|
|
|
|
|
- if(classifyList!=null && classifyList.size()>0){
|
|
|
+ if (classifyList != null && !classifyList.isEmpty()) {
|
|
|
//化学品分类是否匹配到
|
|
|
- Boolean flg=false;
|
|
|
- for (HxpChemicalClassify chemicalClassify:classifyList) {
|
|
|
+ Boolean flg = false;
|
|
|
+ for (HxpChemicalClassify chemicalClassify : classifyList) {
|
|
|
if (chemicalClassify.getClassifyName().equals(chemical.getClassifyName())) {
|
|
|
hxpChemical.setChemicalClassify(chemicalClassify.getId());
|
|
|
- flg=true;
|
|
|
+ flg = true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(checkBox && !flg){
|
|
|
+ if (checkBox && !flg) {
|
|
|
chemical.getFailRemark().append("失败:");
|
|
|
failChemicalList.add(chemical);
|
|
|
checkBox = false;
|
|
|
chemical.getFailRemark().append("分类名称不存在、");
|
|
|
}
|
|
|
- }else{
|
|
|
- if(checkBox){
|
|
|
+ } else {
|
|
|
+ if (checkBox) {
|
|
|
chemical.getFailRemark().append("失败:");
|
|
|
failChemicalList.add(chemical);
|
|
|
checkBox = false;
|
|
|
@@ -174,25 +179,25 @@ public class HxpChemicalServiceImpl implements IHxpChemicalService {
|
|
|
}
|
|
|
|
|
|
//形态
|
|
|
- if(StringUtils.isEmpty(chemical.getChemicalShapeInfo())){
|
|
|
- if(checkBox){
|
|
|
+ if (StringUtils.isEmpty(chemical.getChemicalShapeInfo())) {
|
|
|
+ if (checkBox) {
|
|
|
chemical.getFailRemark().append("失败:");
|
|
|
failChemicalList.add(chemical);
|
|
|
checkBox = false;
|
|
|
}
|
|
|
chemical.getFailRemark().append("形态不能为空、");
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
List<SysDictData> proDictDatas = DictUtils.getDictCache("chemical_shape");
|
|
|
//化学品形态比对标识
|
|
|
- boolean flgshape= false;
|
|
|
- for(SysDictData dictData : proDictDatas){
|
|
|
- if(dictData.getDictLabel().equals(chemical.getChemicalShapeInfo().trim())){
|
|
|
+ boolean flgshape = false;
|
|
|
+ for (SysDictData dictData : proDictDatas) {
|
|
|
+ if (dictData.getDictLabel().equals(chemical.getChemicalShapeInfo().trim())) {
|
|
|
hxpChemical.setChemicalShape(Integer.parseInt(dictData.getDictValue()));
|
|
|
- flgshape=true;
|
|
|
+ flgshape = true;
|
|
|
}
|
|
|
}
|
|
|
- if(StringUtils.isNull(hxpChemical.getChemicalShape())){
|
|
|
- if(checkBox && !flgshape){
|
|
|
+ if (StringUtils.isNull(hxpChemical.getChemicalShape())) {
|
|
|
+ if (checkBox && !flgshape) {
|
|
|
chemical.getFailRemark().append("失败:");
|
|
|
failChemicalList.add(chemical);
|
|
|
checkBox = false;
|
|
|
@@ -202,11 +207,11 @@ public class HxpChemicalServiceImpl implements IHxpChemicalService {
|
|
|
}
|
|
|
|
|
|
//计量单位
|
|
|
- if(StringUtils.isNotEmpty(chemical.getChemicalUnit())){
|
|
|
+ if (StringUtils.isNotEmpty(chemical.getChemicalUnit())) {
|
|
|
if (chemical.getChemicalUnit().length() > 8) {
|
|
|
chemical.getFailRemark().append("失败:");
|
|
|
failChemicalList.add(chemical);
|
|
|
- if(checkBox) {
|
|
|
+ if (checkBox) {
|
|
|
chemical.getFailRemark().append("计量单位过长、");
|
|
|
checkBox = false;
|
|
|
}
|
|
|
@@ -214,14 +219,14 @@ public class HxpChemicalServiceImpl implements IHxpChemicalService {
|
|
|
|
|
|
//获取化学品单位集合
|
|
|
List<SysDictData> dictDataList = DictUtils.getDictCache("chemicals_measuring_unit");
|
|
|
- boolean flgunit=false;
|
|
|
- for (SysDictData sysdic: dictDataList) {
|
|
|
- if(chemical.getChemicalUnit().equals(sysdic.getDictValue())){
|
|
|
- flgunit=true;
|
|
|
+ boolean flgunit = false;
|
|
|
+ for (SysDictData sysdic : dictDataList) {
|
|
|
+ if (chemical.getChemicalUnit().equals(sysdic.getDictValue())) {
|
|
|
+ flgunit = true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(checkBox && !flgunit){
|
|
|
+ if (checkBox && !flgunit) {
|
|
|
chemical.getFailRemark().append("失败:");
|
|
|
failChemicalList.add(chemical);
|
|
|
chemical.getFailRemark().append("字典表未配置单位、");
|
|
|
@@ -229,8 +234,8 @@ public class HxpChemicalServiceImpl implements IHxpChemicalService {
|
|
|
}
|
|
|
|
|
|
hxpChemical.setChemicalUnit(chemical.getChemicalUnit());
|
|
|
- }else{
|
|
|
- if(checkBox) {
|
|
|
+ } else {
|
|
|
+ if (checkBox) {
|
|
|
chemical.getFailRemark().append("失败:");
|
|
|
failChemicalList.add(chemical);
|
|
|
checkBox = false;
|
|
|
@@ -239,69 +244,44 @@ public class HxpChemicalServiceImpl implements IHxpChemicalService {
|
|
|
}
|
|
|
|
|
|
//计量方式
|
|
|
- if(StringUtils.isNotEmpty(chemical.getMeasuringMethod())){
|
|
|
- if("重量".equals(chemical.getMeasuringMethod())){
|
|
|
+ if (StringUtils.isNotEmpty(chemical.getMeasuringMethod())) {
|
|
|
+ if ("重量".equals(chemical.getMeasuringMethod())) {
|
|
|
hxpChemical.setMeasuringMethod(1);
|
|
|
- }else if("体积".equals(chemical.getMeasuringMethod())){
|
|
|
+ } else if ("体积".equals(chemical.getMeasuringMethod())) {
|
|
|
hxpChemical.setMeasuringMethod(2);
|
|
|
- }else if("个数".equals(chemical.getMeasuringMethod())){
|
|
|
+ } else if ("个数".equals(chemical.getMeasuringMethod())) {
|
|
|
hxpChemical.setMeasuringMethod(3);
|
|
|
- }else{
|
|
|
- if(checkBox) {
|
|
|
+ } else {
|
|
|
+ if (checkBox) {
|
|
|
chemical.getFailRemark().append("失败:");
|
|
|
failChemicalList.add(chemical);
|
|
|
checkBox = false;
|
|
|
}
|
|
|
chemical.getFailRemark().append("计量方式不存在、");
|
|
|
}
|
|
|
- }else {
|
|
|
- if(checkBox) {
|
|
|
+ } else {
|
|
|
+ if (checkBox) {
|
|
|
chemical.getFailRemark().append("失败:");
|
|
|
failChemicalList.add(chemical);
|
|
|
checkBox = false;
|
|
|
}
|
|
|
chemical.getFailRemark().append("计量方式不能为空、");
|
|
|
}
|
|
|
-
|
|
|
-// Map<String,Integer> labelMap = new HashMap<>();
|
|
|
-// labelMap.put("RFID",1);
|
|
|
-// labelMap.put("二维码",2);
|
|
|
-// //标签类型
|
|
|
-// if(StringUtils.isEmpty(chemical.getLabelContent())){
|
|
|
-// if(checkBox){
|
|
|
-// chemical.getFailRemark().append("失败:");
|
|
|
-// failChemicalList.add(chemical);
|
|
|
-// checkBox = false;
|
|
|
-// }
|
|
|
-// chemical.getFailRemark().append("标签类型不能为空、");
|
|
|
-// }else{
|
|
|
-// if(StringUtils.isNotNull(labelMap.get(chemical.getLabelContent()))){
|
|
|
-// hxpChemical.setLabelType(labelMap.get(chemical.getLabelContent()));
|
|
|
-// }else{
|
|
|
-// if(checkBox){
|
|
|
-// chemical.getFailRemark().append("失败:");
|
|
|
-// failChemicalList.add(chemical);
|
|
|
-// checkBox = false;
|
|
|
-// }
|
|
|
-// chemical.getFailRemark().append("标签类型不存在、");
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
//属性
|
|
|
- if(StringUtils.isNotEmpty(chemical.getClassifyAttribute())){
|
|
|
+ if (StringUtils.isNotEmpty(chemical.getClassifyAttribute())) {
|
|
|
Optional.ofNullable(DictUtils.getDictCache("hxp_classifyattribute")).orElseGet(Collections::emptyList).stream()
|
|
|
- .forEach(a->Optional.ofNullable(chemical.getClassifyAttribute().split(",")).map(b->{
|
|
|
- for(int i=0;i<b.length;i++){
|
|
|
- if(a.getDictLabel().equals(b[i])){
|
|
|
- hxpChemical.setClassifyAttribute(hxpChemical.getClassifyAttribute()==null?","+a.getDictValue():hxpChemical.getClassifyAttribute()+","+a.getDictValue());
|
|
|
+ .forEach(a -> Optional.ofNullable(chemical.getClassifyAttribute().split(",")).map(b -> {
|
|
|
+ for (int i = 0; i < b.length; i++) {
|
|
|
+ if (a.getDictLabel().equals(b[i])) {
|
|
|
+ hxpChemical.setClassifyAttribute(hxpChemical.getClassifyAttribute() == null ? "," + a.getDictValue() : hxpChemical.getClassifyAttribute() + "," + a.getDictValue());
|
|
|
}
|
|
|
}
|
|
|
return a;
|
|
|
}));
|
|
|
- if(StringUtils.isNotEmpty(hxpChemical.getClassifyAttribute())){
|
|
|
+ if (StringUtils.isNotEmpty(hxpChemical.getClassifyAttribute())) {
|
|
|
hxpChemical.setClassifyAttribute(hxpChemical.getClassifyAttribute().substring(1));
|
|
|
- }else{
|
|
|
- if(checkBox){
|
|
|
+ } else {
|
|
|
+ if (checkBox) {
|
|
|
chemical.getFailRemark().append("失败:");
|
|
|
failChemicalList.add(chemical);
|
|
|
checkBox = false;
|
|
|
@@ -311,12 +291,12 @@ public class HxpChemicalServiceImpl implements IHxpChemicalService {
|
|
|
}
|
|
|
|
|
|
//cas号
|
|
|
- if(StringUtils.isNotEmpty(chemical.getCasNum())){
|
|
|
+ if (StringUtils.isNotEmpty(chemical.getCasNum())) {
|
|
|
HxpChemicalSearch hxpChemicalSearch = new HxpChemicalSearch();
|
|
|
hxpChemicalSearch.setCasNum(chemical.getCasNum());
|
|
|
List<HxpChemicalVo> hxpChemicalVoList = hxpChemicalMapper.selectHxpChemicalList(hxpChemicalSearch);
|
|
|
- if(hxpChemicalVoList.size()>0){
|
|
|
- if(checkBox){
|
|
|
+ if (hxpChemicalVoList!=null && !hxpChemicalVoList.isEmpty()) {
|
|
|
+ if (checkBox) {
|
|
|
chemical.getFailRemark().append("失败:");
|
|
|
failChemicalList.add(chemical);
|
|
|
checkBox = false;
|
|
|
@@ -333,8 +313,8 @@ public class HxpChemicalServiceImpl implements IHxpChemicalService {
|
|
|
hxpChemical.setPurity(chemical.getPurity());
|
|
|
|
|
|
//生产厂家
|
|
|
- if(chemical.getFactory().length()>30){
|
|
|
- if(checkBox){
|
|
|
+ if (chemical.getFactory().length() > 30) {
|
|
|
+ if (checkBox) {
|
|
|
chemical.getFailRemark().append("失败:");
|
|
|
failChemicalList.add(chemical);
|
|
|
checkBox = false;
|
|
|
@@ -343,20 +323,13 @@ public class HxpChemicalServiceImpl implements IHxpChemicalService {
|
|
|
}
|
|
|
hxpChemical.setFactory(chemical.getFactory());
|
|
|
|
|
|
- //是否管控
|
|
|
- if(StringUtils.isNotEmpty(chemical.getIsControl())){
|
|
|
- hxpChemical.setIsControl(1);
|
|
|
- }
|
|
|
|
|
|
- if(StringUtils.isNotEmpty(chemical.getFailRemark())){
|
|
|
- chemical.getFailRemark().deleteCharAt(chemical.getFailRemark().length()-1);
|
|
|
+ if (StringUtils.isNotEmpty(chemical.getFailRemark())) {
|
|
|
+ chemical.getFailRemark().deleteCharAt(chemical.getFailRemark().length() - 1);
|
|
|
}
|
|
|
|
|
|
- if(StringUtils.isEmpty(chemical.getFailRemark())){
|
|
|
+ if (StringUtils.isEmpty(chemical.getFailRemark())) {
|
|
|
//这里目前先写死
|
|
|
- //hxpChemical.setMeasuringMethod(1);
|
|
|
- //hxpChemical.setChemicalUnit("");
|
|
|
- // hxpChemical.setChemicalUnit("g");
|
|
|
hxpChemicalService.insertHxpChemical(hxpChemical);
|
|
|
}
|
|
|
}
|
|
|
@@ -371,22 +344,15 @@ public class HxpChemicalServiceImpl implements IHxpChemicalService {
|
|
|
public int insertHxpChemical(HxpChemical hxpChemical) {
|
|
|
//这里需要查询危险品分类的级别
|
|
|
HxpChemicalClassify hxpChemicalClassify = hxpChemicalClassifyMapper.selectHxpChemicalClassifyById(hxpChemical.getChemicalClassify());
|
|
|
- if(StringUtils.isNull(hxpChemicalClassify)){
|
|
|
+ if (StringUtils.isNull(hxpChemicalClassify)) {
|
|
|
throw new ServiceException("危险品分类级别未配置,请联系管理员!!");
|
|
|
}
|
|
|
- if(hxpChemicalClassify.getClassifyName().length()<2){
|
|
|
+ if (hxpChemicalClassify.getClassifyName().length() < 2) {
|
|
|
throw new ServiceException("分类名称错误,请联系管理员");
|
|
|
}
|
|
|
- String classifyName = hxpChemicalClassify.getClassifyName().substring(0,2);
|
|
|
+ String classifyName = hxpChemicalClassify.getClassifyName().substring(0, 2);
|
|
|
StringBuffer hxpNum = new StringBuffer();
|
|
|
hxpNum.append(generateLetter(classifyName));
|
|
|
-// if(hxpChemicalClassify.getHazardLevel().equals(1)){
|
|
|
-// hxpNum.append("WX");
|
|
|
-// }else if(hxpChemicalClassify.getHazardLevel().equals(2)){
|
|
|
-// hxpNum.append("PT");
|
|
|
-// }else if(hxpChemicalClassify.getHazardLevel().equals(3)){
|
|
|
-// hxpNum.append("QT");
|
|
|
-// }
|
|
|
hxpChemical.setChemicalNum(generateNumber(hxpNum));
|
|
|
//设置其他公共字段
|
|
|
SaveUtil.setCommonAttr(hxpChemical);
|
|
|
@@ -398,26 +364,26 @@ public class HxpChemicalServiceImpl implements IHxpChemicalService {
|
|
|
return hxpChemicalMapper.insertHxpChemical(hxpChemical);
|
|
|
}
|
|
|
|
|
|
- public String generateNumber(StringBuffer hxpNum){
|
|
|
+ public String generateNumber(StringBuffer hxpNum) {
|
|
|
HxpChemical hxpChemical = hxpChemicalMapper.selectHxpChemicalMaxById(hxpNum.toString());
|
|
|
- if(StringUtils.isNull(hxpChemical)){
|
|
|
- synthesisNumber("1",hxpNum);
|
|
|
- }else{
|
|
|
- String chemicalNum = hxpChemical.getChemicalNum().substring(2,hxpChemical.getChemicalNum().length());
|
|
|
- chemicalNum = (Integer.parseInt(chemicalNum)+1)+"";
|
|
|
- synthesisNumber(chemicalNum,hxpNum);
|
|
|
+ if (StringUtils.isNull(hxpChemical)) {
|
|
|
+ synthesisNumber("1", hxpNum);
|
|
|
+ } else {
|
|
|
+ String chemicalNum = hxpChemical.getChemicalNum().substring(2, hxpChemical.getChemicalNum().length());
|
|
|
+ chemicalNum = (Integer.parseInt(chemicalNum) + 1) + "";
|
|
|
+ synthesisNumber(chemicalNum, hxpNum);
|
|
|
}
|
|
|
return hxpNum.toString();
|
|
|
}
|
|
|
|
|
|
- public void synthesisNumber(String num,StringBuffer hxpNum){
|
|
|
- for(int i=0;i<6-num.length();i++){
|
|
|
+ public void synthesisNumber(String num, StringBuffer hxpNum) {
|
|
|
+ for (int i = 0; i < 6 - num.length(); i++) {
|
|
|
hxpNum.append("0");
|
|
|
}
|
|
|
hxpNum.append(num);
|
|
|
}
|
|
|
|
|
|
- public String generateLetter(String china){
|
|
|
+ public String generateLetter(String china) {
|
|
|
HanyuPinyinOutputFormat formart = new HanyuPinyinOutputFormat();
|
|
|
formart.setCaseType(HanyuPinyinCaseType.LOWERCASE);
|
|
|
formart.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
|
|
|
@@ -425,12 +391,12 @@ public class HxpChemicalServiceImpl implements IHxpChemicalService {
|
|
|
char[] arrays = china.trim().toCharArray();
|
|
|
String result = "";
|
|
|
try {
|
|
|
- for (int i=0;i<2;i++) {
|
|
|
+ for (int i = 0; i < 2; i++) {
|
|
|
char ti = arrays[i];
|
|
|
- if(Character.toString(ti).matches("[\\u4e00-\\u9fa5]")){ //匹配是否是中文
|
|
|
- String[] temp = PinyinHelper.toHanyuPinyinStringArray(ti,formart);
|
|
|
- result += temp[0].substring(0,1).toUpperCase();
|
|
|
- }else{
|
|
|
+ if (Character.toString(ti).matches("[\\u4e00-\\u9fa5]")) { //匹配是否是中文
|
|
|
+ String[] temp = PinyinHelper.toHanyuPinyinStringArray(ti, formart);
|
|
|
+ result += temp[0].substring(0, 1).toUpperCase();
|
|
|
+ } else {
|
|
|
result += ti;
|
|
|
}
|
|
|
}
|
|
|
@@ -469,7 +435,7 @@ public class HxpChemicalServiceImpl implements IHxpChemicalService {
|
|
|
public int editChemicalByJoinHazard(HxpChemical hxpChemical) {
|
|
|
hxpChemical.setUpdateTime(DateUtils.getNowDate());
|
|
|
hxpChemical.setUpdateBy(SecurityUtils.getUsername());
|
|
|
- if(StringUtils.isNull(hxpChemical.getJoinHazardId())){
|
|
|
+ if (StringUtils.isNull(hxpChemical.getJoinHazardId())) {
|
|
|
hxpChemicalMapper.clearHxpChemicalByJoinHazard(hxpChemical);
|
|
|
}
|
|
|
return hxpChemicalMapper.updateHxpChemical(hxpChemical);
|
|
|
@@ -543,24 +509,24 @@ public class HxpChemicalServiceImpl implements IHxpChemicalService {
|
|
|
*/
|
|
|
@Override
|
|
|
@DataScope(deptAlias = "ur", userAlias = "ur", permi = PerPrefix.HPX_HOMEPAGE)
|
|
|
- public List<LinkedHashMap <String,String>> chemicalClassifyMix(HxpChemical hxpChemical) {
|
|
|
- List<LinkedHashMap <String,String>> chemicalList = hxpChemicalMapper.chemicalClassifyMix(hxpChemical);
|
|
|
+ public List<LinkedHashMap<String, String>> chemicalClassifyMix(HxpChemical hxpChemical) {
|
|
|
+ List<LinkedHashMap<String, String>> chemicalList = hxpChemicalMapper.chemicalClassifyMix(hxpChemical);
|
|
|
DoubleAdder doubleAdder = new DoubleAdder();
|
|
|
Optional.ofNullable(chemicalList).orElseGet(Collections::emptyList).stream()
|
|
|
- .forEach(a->{
|
|
|
- a.forEach((key,value)->{
|
|
|
- if(key.equals("chemicalMix")){
|
|
|
+ .forEach(a -> {
|
|
|
+ a.forEach((key, value) -> {
|
|
|
+ if (key.equals("chemicalMix")) {
|
|
|
doubleAdder.add(Long.parseLong(value));
|
|
|
}
|
|
|
|
|
|
});
|
|
|
});
|
|
|
Double sumMix = doubleAdder.sum();
|
|
|
- List<LinkedHashMap <String,String>> linkedList = Optional.ofNullable(chemicalList).orElseGet(Collections::emptyList).stream()
|
|
|
- .map(a->{
|
|
|
- a.forEach((key,value)->{
|
|
|
- if(key.equals("chemicalMix")){
|
|
|
- a.put(key,(Math.round(Double.parseDouble(value)/sumMix.doubleValue()*100))+"%");
|
|
|
+ List<LinkedHashMap<String, String>> linkedList = Optional.ofNullable(chemicalList).orElseGet(Collections::emptyList).stream()
|
|
|
+ .map(a -> {
|
|
|
+ a.forEach((key, value) -> {
|
|
|
+ if (key.equals("chemicalMix")) {
|
|
|
+ a.put(key, (Math.round(Double.parseDouble(value) / sumMix.doubleValue() * 100)) + "%");
|
|
|
}
|
|
|
});
|
|
|
return a;
|
|
|
@@ -572,7 +538,7 @@ public class HxpChemicalServiceImpl implements IHxpChemicalService {
|
|
|
|
|
|
@Override
|
|
|
@DataScope(deptAlias = "ur", userAlias = "ur", permi = PerPrefix.HPX_HOMEPAGE)
|
|
|
- public Long stockTotal(HxpChemical hxpChemical){
|
|
|
+ public Long stockTotal(HxpChemical hxpChemical) {
|
|
|
return hxpChemicalMapper.stockTotal(hxpChemical);
|
|
|
}
|
|
|
|
|
|
@@ -585,16 +551,15 @@ public class HxpChemicalServiceImpl implements IHxpChemicalService {
|
|
|
*/
|
|
|
@Override
|
|
|
@DataScope(deptAlias = "ur", userAlias = "ur", permi = PerPrefix.HPX_HOMEPAGE)
|
|
|
- public List<LinkedHashMap <String,String>> joinOutCount(HxpStock hxpStock) {
|
|
|
- List<LinkedHashMap <String,String>> stockCountList = hxpChemicalMapper.joinOutCount(hxpStock);
|
|
|
- return stockCountList;
|
|
|
+ public List<LinkedHashMap<String, String>> joinOutCount(HxpStock hxpStock) {
|
|
|
+ return hxpChemicalMapper.joinOutCount(hxpStock);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<Map<String, Object>> queryCriticaliBySubId(List<Long> subIds) {
|
|
|
List<Map<String, Object>> list = hxpChemicalMapper.queryCriticaliBySubId(subIds);
|
|
|
- if(CollectionUtils.isNotEmpty(list)){
|
|
|
- if(list.get(0) == null){
|
|
|
+ if (CollectionUtils.isNotEmpty(list)) {
|
|
|
+ if (list.get(0) == null) {
|
|
|
list.remove(0);
|
|
|
}
|
|
|
}
|
|
|
@@ -604,18 +569,18 @@ public class HxpChemicalServiceImpl implements IHxpChemicalService {
|
|
|
@Override
|
|
|
public void indicatorMonitoring() {
|
|
|
List<Map<String, Object>> list = hxpChemicalMapper.queryCriticaliBySubId(new ArrayList<>());
|
|
|
- if(!list.isEmpty()){
|
|
|
- if(list.get(0) == null){
|
|
|
+ if (list!=null && !list.isEmpty()) {
|
|
|
+ if (list.get(0) == null) {
|
|
|
list.remove(0);
|
|
|
}
|
|
|
|
|
|
list.forEach(map -> {
|
|
|
- if(BigDecimal.valueOf(1L).compareTo(BigDecimal.valueOf(Double.parseDouble(map.get("criticali")+""))) < 0){
|
|
|
+ if (BigDecimal.valueOf(1L).compareTo(BigDecimal.valueOf(Double.parseDouble(map.get("criticali") + ""))) < 0) {
|
|
|
|
|
|
- Map<String,Object> subInfo = hxpUserecordMapper.selectSubInfoById(Long.parseLong(map.get("subId") + ""));
|
|
|
+ Map<String, Object> subInfo = hxpUserecordMapper.selectSubInfoById(Long.parseLong(map.get("subId") + ""));
|
|
|
String safeUserId = "";
|
|
|
- if(subInfo != null){
|
|
|
- safeUserId = subInfo.get("safeUserId")==null?"":String.valueOf(subInfo.get("safeUserId"));
|
|
|
+ if (subInfo != null) {
|
|
|
+ safeUserId = subInfo.get("safeUserId") == null ? "" : String.valueOf(subInfo.get("safeUserId"));
|
|
|
}
|
|
|
|
|
|
HxpAlarmRecord hxpAlarmRecord = new HxpAlarmRecord();
|
|
|
@@ -632,21 +597,22 @@ public class HxpChemicalServiceImpl implements IHxpChemicalService {
|
|
|
|
|
|
// 此处需要发送短信通知
|
|
|
|
|
|
- String[] strings = Stream.of(new String[]{subInfo.get("phones")+""})
|
|
|
+ String[] strings = Stream.of(new String[]{subInfo.get("phones") + ""})
|
|
|
.filter(a -> StrUtil.isNotBlank(a))
|
|
|
.collect(Collectors.joining(","))
|
|
|
.split(",");
|
|
|
|
|
|
- String subName = subInfo.get("name")==null?"":subInfo.get("name")+"";
|
|
|
+ String subName = subInfo.get("name") == null ? "" : subInfo.get("name") + "";
|
|
|
String content = subName + "房间内危化品已定为重大危险源,请确认安全存放量!";
|
|
|
- if(HxpStockServiceImpl.phoneMode == 0){
|
|
|
+ if (HxpStockServiceImpl.phoneMode == 0) {
|
|
|
|
|
|
- AlarmEntrty alarmEntrty = new AlarmEntrty(Routes.NoticePush, strings,content);
|
|
|
+ AlarmEntrty alarmEntrty = new AlarmEntrty(Routes.NoticePush, strings, content);
|
|
|
remoteAlarmService.send(alarmEntrty);
|
|
|
- }else if(HxpStockServiceImpl.phoneMode == 1){
|
|
|
+ } else if (HxpStockServiceImpl.phoneMode == 1) {
|
|
|
try {
|
|
|
smsSydUtil.sendSydSms(content, 1, null, strings);
|
|
|
} catch (Exception e) {
|
|
|
+ logger.error("indicatorMonitoring 异常:"+e);
|
|
|
}
|
|
|
}
|
|
|
}
|