Commit f3f2b5ef authored by wujiang's avatar wujiang

提交修改bug

parent 0a860fb3
......@@ -82,10 +82,10 @@ public class CylinderInfoDto extends BaseDto {
@ApiModelProperty(value = "数据完整度")
private Double integrity;
@ApiModelProperty(value = "???")
@ApiModelProperty(value = "精度")
private String longitude;
@ApiModelProperty(value = "γ?")
@ApiModelProperty(value = "纬度")
private String latitude;
@ApiModelProperty(value = "统一社会信用代码")
......@@ -110,10 +110,10 @@ public class CylinderInfoDto extends BaseDto {
private String typeExperiments;
@ApiModelProperty(value = "阀门制造单位")
private Double valveManufacturUnit;
private String valveManufacturUnit;
@ApiModelProperty(value = "公称工作压力(MPa)")
private String nominalWorkPressure;
private Double nominalWorkPressure;
@ApiModelProperty(value = "设备品种名称")
private String cylinderVarietyName;
......@@ -145,5 +145,14 @@ public class CylinderInfoDto extends BaseDto {
* 检验状态(已超期、即将超期)
*/
private String inspectionStatusDesc;
private int isWarn = 0;
private String qrCode;
private String electronicLabelCode;
private String cylinderStatusStr;
}
......@@ -103,5 +103,8 @@ public class CylinderUnitDto extends BaseDto {
* 星级 (写死的★★★★★)
*/
private String evaluate;
private boolean outOfDate = false;
}
......@@ -33,7 +33,7 @@ public class TzCylinderInfoDto {
/**
* 设备品种
*/
private Integer cylinderVariety;
private String cylinderVariety;
@ApiModelProperty(value = "产品名称")
/**
......@@ -75,7 +75,7 @@ public class TzCylinderInfoDto {
/**
* 气瓶状态
*/
private Integer cylinderStatus;
private String cylinderStatus;
@ApiModelProperty(value = "阀门制造单位")
/**
......
......@@ -109,10 +109,10 @@ public class CylinderInfo extends BaseEntity {
private String typeExperiments;
@ApiModelProperty(value = "阀门制造单位")
private Double valveManufacturUnit;
private String valveManufacturUnit;
@ApiModelProperty(value = "公称工作压力(MPa)")
private String nominalWorkPressure;
private Double nominalWorkPressure;
@ApiModelProperty(value = "设备品种名称")
private String cylinderVarietyName;
......
......@@ -23,6 +23,9 @@ public interface CylinderInfoMapper extends BaseMapper<CylinderInfo> {
* @return
*/
Map<String, String> queryNumAndOutOfDateNum(@Param("sequenceNbr") Long sequenceNbr);
Integer getMonthInfoTotal(@Param("regionCode") String regionCode);
/**
* 获取上个月气瓶总量
......@@ -46,7 +49,9 @@ public interface CylinderInfoMapper extends BaseMapper<CylinderInfo> {
Double queryIntegirtyByAppId(@Param("appId") String appId);
Integer getWarnNum(String code);
Integer getMonthInfoTotalUnit(@Param("appId") String appId);
/**
* 获取上个月气瓶总量-APPID
* @return
......
package com.yeejoin.amos.boot.module.tzs.flc.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.tzs.flc.api.entity.CylinderInfo;
import com.yeejoin.amos.boot.module.tzs.flc.api.entity.CylinderInspection;
/**
......@@ -10,5 +12,7 @@ import com.yeejoin.amos.boot.module.tzs.flc.api.entity.CylinderInspection;
* @date 2022-03-04
*/
public interface CylinderInspectionMapper extends BaseMapper<CylinderInspection> {
Page<CylinderInfo> queryOutOfDateCylinder(Page<CylinderInfo> pageBean,String appId);
}
......@@ -32,4 +32,6 @@ public interface CylinderUnitMapper extends BaseMapper<CylinderUnit> {
Integer getUnitTotalByRegionCode(@Param("regionCode") String regionCode);
Integer getWarnNum(String code);
Integer getWarnNumByAppId(String appId);
}
......@@ -16,7 +16,7 @@
IFNULL(
sum(
case c.within_scope+c.sealed_state+c.defective+c.abnormal_temperature+c.warning_sign
when 5 then 1
when 15730 then 1
else
0 end ), 0) from tz_cylinder_filling_check c where date_format(c.inspection_date,'%Y-%m') = date_format(#{time},'%Y-%m') and app_id = #{appId}
</select>
......
......@@ -15,7 +15,7 @@
IFNULL(
sum(
case f.is_valid+f.same+f.is_regulations+f.is_compliance_withGBT+f.have_still_pressure+f.is_complete+f.have_security_documents
when 7 then 1
when 21920 then 1
else
0 end ),0) from tz_cylinder_filling f where date_format(f.inspection_date,'%Y-%m') = date_format(#{time},'%Y-%m') and app_id = #{appId}
</select>
......
......@@ -21,6 +21,11 @@
<sql id="selectAPPIdByRegionCode">
select u.app_id from tz_cylinder_unit u where u.region_code like CONCAT('%',#{regionCode},'%')
</sql>
<select id="getMonthInfoTotal" resultType="java.lang.Integer">
select IFNULL(count(sequence_nbr), 0) from tz_cylinder_info where PERIOD_DIFF( date_format( now( ) , '%Y%m' ) ,
date_format( sync_date, '%Y%m' ) ) =0 AND app_id in (<include refid="selectAPPIdByRegionCode"/>)
</select>
<select id="getLastMonthInfoTotal" resultType="java.lang.Integer">
select IFNULL(count(sequence_nbr), 0) from tz_cylinder_info where PERIOD_DIFF( date_format( now( ) , '%Y%m' ) ,
......@@ -43,7 +48,11 @@
<select id="getWarnNum" resultType="java.lang.Integer">
select count(1) from view_cylider_outofdate v where v.app_id in (<include refid="selectAPPIdByRegionCode"/>)
</select>
<select id="getMonthInfoTotalUnit" resultType="java.lang.Integer">
select IFNULL(count(sequence_nbr), 0) from tz_cylinder_info where PERIOD_DIFF( date_format( now( ) , '%Y%m' ) , date_format( sync_date, '%Y%m' ) ) =0 AND app_id = #{appId}
</select>
<select id="getLastMonthInfoTotalUnit" resultType="java.lang.Integer">
select IFNULL(count(sequence_nbr), 0) from tz_cylinder_info where PERIOD_DIFF( date_format( now( ) , '%Y%m' ) , date_format( sync_date, '%Y%m' ) ) =1 AND app_id = #{appId}
</select>
......
......@@ -2,4 +2,14 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.tzs.flc.api.mapper.CylinderInspectionMapper">
<select id="queryOutOfDateCylinder" resultType="com.yeejoin.amos.boot.module.tzs.flc.api.entity.CylinderInfo">
SELECT
*
FROM
tz_cylinder_info info
LEFT JOIN tz_cylinder_inspection ins ON ins.sequence_code = info.sequence_code
WHERE TO_DAYS(ins.next_inspection_date) - TO_DAYS(NOW()) &lt;= 20
AND info.app_id = #{appId}
</select>
</mapper>
......@@ -19,5 +19,9 @@
select u.app_id from tz_cylinder_unit u where u.region_code like CONCAT('%',#{regionCode},'%')
)
</select>
<select id="getWarnNumByAppId" resultType="java.lang.Integer">
select count(1) from view_cylider_outofdate v where v.app_id =#{appId}
</select>
</mapper>
......@@ -104,22 +104,6 @@ public class AmosTzsApplication {
@Bean
public void initToken() {
new Thread(new Runnable() {
@Override
public void run() {
cylinderInfoServiceImpl.synFillingUnloadData();
cylinderInfoServiceImpl.synAreaData();
cylinderInfoServiceImpl.addIntegrityData();
cylinderInfoServiceImpl.getCylinderUnitInfo();
cylinderInfoServiceImpl.getCylinderInfo();
cylinderInfoServiceImpl.synUnitCylinderInfoData();
cylinderInfoServiceImpl.synUnitCylinderFillingData();
cylinderInfoServiceImpl.synUnitCylinderTagsData();
cylinderInfoServiceImpl.synUnitIntegrityData();
cylinderInfoServiceImpl.synUnitFillingCheckData();
cylinderInfoServiceImpl.synFillingUnloadUnitData();
}
}).start();
startPlatformTokenService.getToken();
}
}
package com.yeejoin.amos.boot.module.tzs.biz.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.entity.DataDictionary;
import com.yeejoin.amos.boot.biz.common.utils.Menu;
import com.yeejoin.amos.boot.biz.common.utils.TreeParser;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.yeejoin.amos.boot.module.tzs.biz.service.impl.EquipmentCategoryServiceImpl;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
......@@ -12,8 +17,13 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel;
import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.tzs.api.dto.EquipmentCategoryDto;
import com.yeejoin.amos.boot.module.tzs.api.entity.EquipmentCategory;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
......@@ -28,76 +38,100 @@ import org.typroject.tyboot.core.foundation.enumeration.UserType;
@RequestMapping(value = "/equipment-category")
public class EquipmentCategoryController extends BaseController {
@Autowired
EquipmentCategoryServiceImpl equipmentCategoryServiceImpl;
@Autowired
EquipmentCategoryServiceImpl equipmentCategoryServiceImpl;
/**
* 新增装备分类
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
/**
* 新增装备分类
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/save")
@ApiOperation(httpMethod = "POST", value = "新增装备分类", notes = "新增装备分类")
public ResponseModel<EquipmentCategoryDto> save(@RequestBody EquipmentCategoryDto model) {
model = equipmentCategoryServiceImpl.createWithModel(model);
return ResponseHelper.buildResponse(model);
model = equipmentCategoryServiceImpl.createWithModel(model);
return ResponseHelper.buildResponse(model);
}
/**
* 根据sequenceNbr删除
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@DeleteMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "DELETE", value = "根据sequenceNbr删除装备分类", notes = "根据sequenceNbr删除装备分类")
public ResponseModel<Boolean> deleteBySequenceNbr(HttpServletRequest request, @PathVariable(value = "sequenceNbr") Long sequenceNbr){
return ResponseHelper.buildResponse(equipmentCategoryServiceImpl.removeById(sequenceNbr));
}
* 根据sequenceNbr删除
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@DeleteMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "DELETE", value = "根据sequenceNbr删除装备分类", notes = "根据sequenceNbr删除装备分类")
public ResponseModel<Boolean> deleteBySequenceNbr(HttpServletRequest request,
@PathVariable(value = "sequenceNbr") Long sequenceNbr) {
return ResponseHelper.buildResponse(equipmentCategoryServiceImpl.removeById(sequenceNbr));
}
/**
* 根据sequenceNbr查询
*
* @param sequenceNbr 主键
* @return
*/
/**
* 根据sequenceNbr查询
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "GET",value = "根据sequenceNbr查询单个装备分类", notes = "根据sequenceNbr查询单个装备分类")
@ApiOperation(httpMethod = "GET", value = "根据sequenceNbr查询单个装备分类", notes = "根据sequenceNbr查询单个装备分类")
public ResponseModel<EquipmentCategoryDto> selectOne(@PathVariable Long sequenceNbr) {
return ResponseHelper.buildResponse(equipmentCategoryServiceImpl.queryBySeq(sequenceNbr));
return ResponseHelper.buildResponse(equipmentCategoryServiceImpl.queryBySeq(sequenceNbr));
}
/**
* 列表分页查询
*
* @param current 当前页
* @param current 每页大小
* @return
*/
* 列表分页查询
*
* @param current 当前页
* @param current 每页大小
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/page")
@ApiOperation(httpMethod = "GET",value = "装备分类分页查询", notes = "装备分类分页查询")
public ResponseModel<Page<EquipmentCategoryDto>> queryForPage(@RequestParam(value = "current") int current,@RequestParam
(value = "size") int size) {
Page<EquipmentCategoryDto> page = new Page<EquipmentCategoryDto>();
page.setCurrent(current);
page.setSize(size);
return ResponseHelper.buildResponse(equipmentCategoryServiceImpl.queryForEquipmentCategoryPage(page));
@ApiOperation(httpMethod = "GET", value = "装备分类分页查询", notes = "装备分类分页查询")
public ResponseModel<Page<EquipmentCategoryDto>> queryForPage(@RequestParam(value = "current") int current,
@RequestParam(value = "size") int size) {
Page<EquipmentCategoryDto> page = new Page<EquipmentCategoryDto>();
page.setCurrent(current);
page.setSize(size);
return ResponseHelper.buildResponse(equipmentCategoryServiceImpl.queryForEquipmentCategoryPage(page));
}
/**
* 列表全部数据查询
*
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = "装备分类列表全部数据查询", notes = "装备分类列表全部数据查询")
@ApiOperation(httpMethod = "GET", value = "装备分类列表全部数据查询", notes = "装备分类列表全部数据查询")
@GetMapping(value = "/list")
public ResponseModel<List<EquipmentCategoryDto>> selectForList() {
return ResponseHelper.buildResponse(equipmentCategoryServiceImpl.queryForEquipmentCategoryList());
return ResponseHelper.buildResponse(equipmentCategoryServiceImpl.queryForEquipmentCategoryList());
}
/**
* 树
*
* @return
* @throws Exception
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "装备分类列表全部数据查询", notes = "装备分类列表全部数据查询")
@GetMapping(value = "/tree")
public ResponseModel<Object> tree(@RequestParam Long code) throws Exception {
EquipmentCategory root = equipmentCategoryServiceImpl
.getOne(new LambdaQueryWrapper<EquipmentCategory>().eq(EquipmentCategory::getCode, code));
QueryWrapper<EquipmentCategory> queryWrapper = new QueryWrapper<>();
queryWrapper.likeRight("code", code.toString().replaceAll("0+$", ""));
Collection<EquipmentCategory> list = equipmentCategoryServiceImpl.list(queryWrapper);
Menu menu = new Menu(root.getId(), root.getName(), 0L, 0);
List<Menu> menus = TreeParser.getTree(root.getId(), list, EquipmentCategory.class.getName(), "getId", 0, "getName",
"getParentId", null, "getCode");
menu.setChildren(menus);
List<Menu> tree = new ArrayList<>();
tree.add(menu);
return ResponseHelper.buildResponse(tree);
}
}
......@@ -93,10 +93,10 @@ public class WechatController extends BaseController {
@Value("${tzs.wechat.ticketurl}")
private String WECHAT_TICKETURL;
@Autowired
private EmqKeeper emqKeeper;
@Value("${mqtt.topic.task.personinfo}")
private String personInfoTopic;
@Autowired
private EmqKeeper emqKeeper;
@Value("${mqtt.topic.task.personinfo}")
private String personInfoTopic;
@Autowired
RedisUtils redisUtils;
......@@ -124,62 +124,62 @@ public class WechatController extends BaseController {
private Long TOKEN_TIME = 1209600l;
/**
* 获取微信回调信息返回验证是否通过
*
* @param signature
* @param timestamp
* @param nonce
* @param echostr
* @return
*/
@TycloudOperation(ApiLevel = UserType.ANONYMOUS , needAuth = false)
@TycloudOperation(ApiLevel = UserType.ANONYMOUS, needAuth = false)
@GetMapping(value = "/getInfo")
@ApiOperation(httpMethod = "GET", value = "获取微信传回的get信息", notes = "获取微信传回的get信息")
public String getWechatInfo(@RequestParam String signature,@RequestParam String timestamp,@RequestParam String nonce,@RequestParam String echostr) {
public String getWechatInfo(@RequestParam String signature, @RequestParam String timestamp,
@RequestParam String nonce, @RequestParam String echostr) {
List<String> params = new ArrayList<String>();
params.add(WECHAT_TOKEN);
params.add(timestamp);
params.add(nonce);
Collections.sort(params);
String tokenStr = StringUtils.join(params,"");
String tokenStr = StringUtils.join(params, "");
tokenStr = DigestUtils.sha1Hex(tokenStr);
System.out.println("=============回调get消息start=============");
System.out.println(echostr);
System.out.println("=============回调get消息end=============");
if(tokenStr.equals(signature)) {
if (tokenStr.equals(signature)) {
return echostr;
} else {
return "";
}
}
@TycloudOperation(ApiLevel = UserType.ANONYMOUS , needAuth = false)
@TycloudOperation(ApiLevel = UserType.ANONYMOUS, needAuth = false)
@PostMapping(value = "/getSignature")
@ApiOperation(httpMethod = "POST", value = "获取微信签名", notes = "获取微信签名")
public ResponseModel<String> getSignature(@RequestBody SignatureDto signatureDto) {
public ResponseModel<String> getSignature(@RequestBody SignatureDto signatureDto) {
List<String> params = new ArrayList<String>();
try {
String ticket = null;
if(redisUtils.hasKey(RedisKey.WECHAT_JS_TOKEN)) {
ticket = redisUtils.get(RedisKey.WECHAT_JS_TOKEN).toString();
} else {
if(!redisUtils.hasKey(RedisKey.WECHAT_TOKEN)){
this.getAccessToken();
}
String token = redisUtils.get(RedisKey.WECHAT_TOKEN).toString();
String result = HttpUtils.doGet(WECHAT_TICKETURL+token+"&type=jsapi");
JSONObject jsonObject = JSONObject.parseObject(result);
ticket = jsonObject.get("ticket").toString();
redisUtils.set(RedisKey.WECHAT_JS_TOKEN,ticket, 600l);
}
params.add("jsapi_ticket="+ticket);
String ticket = null;
if (redisUtils.hasKey(RedisKey.WECHAT_JS_TOKEN)) {
ticket = redisUtils.get(RedisKey.WECHAT_JS_TOKEN).toString();
} else {
if (!redisUtils.hasKey(RedisKey.WECHAT_TOKEN)) {
this.getAccessToken();
}
String token = redisUtils.get(RedisKey.WECHAT_TOKEN).toString();
String result = HttpUtils.doGet(WECHAT_TICKETURL + token + "&type=jsapi");
JSONObject jsonObject = JSONObject.parseObject(result);
ticket = jsonObject.get("ticket").toString();
redisUtils.set(RedisKey.WECHAT_JS_TOKEN, ticket, 600l);
}
params.add("jsapi_ticket=" + ticket);
params.add("noncestr=" + signatureDto.getNoncestr());
params.add("timestamp=" + signatureDto.getTimestamp());
params.add("url=" + signatureDto.getUrl());
logger.error("jsapi_ticket="+ticket);
logger.error("jsapi_ticket=" + ticket);
logger.error("noncestr=" + signatureDto.getNoncestr());
logger.error("timestamp=" + signatureDto.getTimestamp());
logger.error("url=" + signatureDto.getUrl());
......@@ -187,29 +187,29 @@ public class WechatController extends BaseController {
Collections.sort(params, new Comparator<String>() {
@Override
public int compare(String o1, String o2) {
char[] chars1=o1.toCharArray();
char[] chars2=o2.toCharArray();
int i=0;
while(i<chars1.length && i<chars2.length){
if(chars1[i]>chars2[i]){
char[] chars1 = o1.toCharArray();
char[] chars2 = o2.toCharArray();
int i = 0;
while (i < chars1.length && i < chars2.length) {
if (chars1[i] > chars2[i]) {
return 1;
}else if(chars1[i]<chars2[i]){
} else if (chars1[i] < chars2[i]) {
return -1;
}else{
} else {
i++;
}
}
if(i==chars1.length){ //o1到头
if (i == chars1.length) { // o1到头
return -1;
}
if(i== chars2.length){ //o2到头
if (i == chars2.length) { // o2到头
return 1;
}
return 0;
}
});
String tokenStr = StringUtils.join(params,"&");
String tokenStr = StringUtils.join(params, "&");
logger.error(tokenStr);
tokenStr = DigestUtils.sha1Hex(tokenStr);
return ResponseHelper.buildResponse(tokenStr);
......@@ -218,14 +218,14 @@ public class WechatController extends BaseController {
}
}
/**
* 获取微信推送的操作通知
*
* @param xml
* @param resp
* @return
*/
@TycloudOperation(ApiLevel = UserType.ANONYMOUS , needAuth = false)
@TycloudOperation(ApiLevel = UserType.ANONYMOUS, needAuth = false)
@PostMapping(value = "/getInfo")
@ApiOperation(httpMethod = "POST", value = "获取微信传回的post信息", notes = "获取微信传回的post信息")
public String getWechatInfoPost(@RequestBody String xml, HttpServletResponse resp) {
......@@ -236,7 +236,6 @@ public class WechatController extends BaseController {
return "1";
}
/**
* XML格式字符串转换为Map
*
......@@ -283,6 +282,7 @@ public class WechatController extends BaseController {
/**
* 根据手机号发送短信验证码
*
* @param tel
* @return
*/
......@@ -291,9 +291,9 @@ public class WechatController extends BaseController {
@ApiOperation(httpMethod = "GET", value = "根据手机号发送短信验证码", notes = "根据手机号发送短信验证码")
public ResponseModel<Boolean> sendSmsCode(@PathVariable String tel) {
Boolean flag = false;
HashMap<String, String> params = new HashMap<>();
params.put("smsType","MOBILE_REGISTER");
params.put("mobile",tel);
HashMap<String, String> params = new HashMap<>();
params.put("smsType", "MOBILE_REGISTER");
params.put("mobile", tel);
FeignClientResult<SmsRecordModel> result = Systemctl.smsClient.sendVerifyCode(params);
return ResponseHelper.buildResponse(flag);
}
......@@ -308,12 +308,11 @@ public class WechatController extends BaseController {
@ApiOperation(httpMethod = "POST", value = "新增微信公众号openid与电话号对应关系表", notes = "新增微信公众号openid与电话号对应关系表")
@Transactional
public ResponseModel<WechatAccessDto> addUser(@RequestBody WechatRelationDto model) {
if (ValidationUtil.isEmpty(model.getOpenId())
|| ValidationUtil.isEmpty(model.getPhone())
if (ValidationUtil.isEmpty(model.getOpenId()) || ValidationUtil.isEmpty(model.getPhone())
|| ValidationUtil.isEmpty(model.getCode()))
throw new BadRequest("参数校验失败.");
AgencyUserModel agencyUserModel = new AgencyUserModel();
String passwd = DesUtil.encode("a_"+model.getPhone(), "qaz");
String passwd = DesUtil.encode("a_" + model.getPhone(), "qaz");
agencyUserModel.setUserName(model.getPhone());
agencyUserModel.setRealName(model.getPhone());
agencyUserModel.setLockStatus("UNLOCK");
......@@ -324,7 +323,7 @@ public class WechatController extends BaseController {
agencyUserModel.setVerifyCode(model.getCode());
FeignClientResult<AgencyUserModel> result = Privilege.agencyUserClient.mobileRegister(agencyUserModel);
agencyUserModel = result.getResult();
if(agencyUserModel != null && StringUtils.isNotBlank(agencyUserModel.getUserId())) {
if (agencyUserModel != null && StringUtils.isNotBlank(agencyUserModel.getUserId())) {
model.setUserId(agencyUserModel.getUserId());
wechatRelationServiceImpl.createWithModel(model);
} else {
......@@ -337,10 +336,10 @@ public class WechatController extends BaseController {
loninData.setLoginId(model.getPhone());
loninData.setPassword(passwd);
FeignClientResult loginResult = Privilege.authClient.idpassword(loninData);
if(loginResult.getStatus() == 200) {
if (loginResult.getStatus() == 200) {
HashMap resultMap = (HashMap) loginResult.getResult();
dto.setToken(resultMap.get("token").toString());
redisUtils.set(model.getPhone() + "_token", resultMap.get("token").toString(), TOKEN_TIME);
redisUtils.set(model.getPhone() + "_token", resultMap.get("token").toString(), TOKEN_TIME);
}
return ResponseHelper.buildResponse(dto);
......@@ -353,10 +352,10 @@ public class WechatController extends BaseController {
String passwd = DesUtil.encode("a_" + tel, "qaz");
loninData.setPassword(passwd);
FeignClientResult loginResult = Privilege.authClient.idpassword(loninData);
if(loginResult.getStatus() == 200) {
if (loginResult.getStatus() == 200) {
HashMap resultMap = (HashMap) loginResult.getResult();
token = resultMap.get("token").toString();
redisUtils.set(tel + "_token", resultMap.get("token").toString(), TOKEN_TIME);
token = resultMap.get("token").toString();
redisUtils.set(tel + "_token", resultMap.get("token").toString(), TOKEN_TIME);
}
return token;
}
......@@ -370,30 +369,43 @@ public class WechatController extends BaseController {
@GetMapping(value = "/getOpenIdTel/{code}")
@ApiOperation(httpMethod = "GET", value = "根据微信code获取openId和手机号接口", notes = "根据微信code获取openId和手机号接口")
public ResponseModel<WechatAccessDto> getOpenIdTel(@PathVariable String code) {
logger.info("公众号登录"+code);
System.out.println("公众号登录"+code);
logger.info("公众号登录" + code);
System.out.println("公众号登录" + code);
WechatAccessDto wechatAccessDto = new WechatAccessDto();
String openId = wechatService.getOpenId(code);
logger.info("公众号登录openId"+openId);
System.out.println("公众号登录openId"+openId);
if(StringUtils.isNotEmpty(openId)) {
logger.info("公众号登录openId" + openId);
System.out.println("公众号登录openId" + openId);
if (StringUtils.isNotEmpty(openId)) {
JSONObject userInfo = wechatService.getUserInfo(openId);
wechatAccessDto.setOpenId(openId);
if(userInfo != null && userInfo.get("nickname") != null && userInfo.get("sex") != null) {
if (userInfo != null && userInfo.get("nickname") != null && userInfo.get("sex") != null) {
wechatAccessDto.setNickname(userInfo.getString("nickname"));
wechatAccessDto.setSex(userInfo.getString("sex"));
}
WechatRelation temp = wechatRelationServiceImpl.getOne(new LambdaQueryWrapper<WechatRelation>().eq(WechatRelation::getOpenId,openId));
if(temp != null ) {
WechatRelation temp = wechatRelationServiceImpl
.getOne(new LambdaQueryWrapper<WechatRelation>().eq(WechatRelation::getOpenId, openId));
System.out.println("公众号登录temp" + temp);
logger.info("公众号登录temp" + temp);
if (temp != null) {
wechatAccessDto.setTel(temp.getPhone());
if(redisUtils.hasKey(temp.getPhone() + "_token") && redisUtils.getExpire(temp.getPhone() + "_token") > 1) {
if (redisUtils.hasKey(temp.getPhone() + "_token")
&& redisUtils.getExpire(temp.getPhone() + "_token") > 1) {
System.out.println(
temp.getPhone() + "_token redis: " + redisUtils.get(temp.getPhone() + "_token").toString());
wechatAccessDto.setToken(redisUtils.get(temp.getPhone() + "_token").toString());
} else {
wechatAccessDto.setToken(this.login(temp.getPhone()));
String token = this.login(temp.getPhone());
System.out.println(temp.getPhone() + "_token login: " + token);
wechatAccessDto.setToken(token);
}
}
else
{
wechatAccessDto.setToken("");
}
}
logger.info("公众号登录wechatAccessDto"+wechatAccessDto);
System.out.println("公众号登录wechatAccessDto" + wechatAccessDto);
logger.info("公众号登录wechatAccessDto" + wechatAccessDto);
return ResponseHelper.buildResponse(wechatAccessDto);
}
......@@ -405,36 +417,32 @@ public class WechatController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@PostMapping(value = "/returnDistance")
@ApiOperation(httpMethod = "POST", value = "根据任务id 经纬度 返回现在距离任务距离", notes = "根据任务id 经纬度 返回现在距离任务距离")
public ResponseModel<String> returnDistance(@RequestBody WechatTaskLatLonDto dto ) {
if (ValidationUtil.isEmpty(dto)
|| ValidationUtil.isEmpty(dto.getTaskId())
|| ValidationUtil.isEmpty(dto.getLatitude())
|| ValidationUtil.isEmpty(dto.getLongitude())){
public ResponseModel<String> returnDistance(@RequestBody WechatTaskLatLonDto dto) {
if (ValidationUtil.isEmpty(dto) || ValidationUtil.isEmpty(dto.getTaskId())
|| ValidationUtil.isEmpty(dto.getLatitude()) || ValidationUtil.isEmpty(dto.getLongitude())) {
throw new BadRequest("参数校验失败.");
}
// 推送经纬度 人员姓名 电话 警情id
JSONObject jsonObject = new JSONObject();
DispatchTask task = dispatchTaskServiceImpl.getById(dto.getTaskId());
jsonObject.put("personName",task.getResponseUserName());
jsonObject.put("personTel",task.getResponseUserTel());
jsonObject.put("latitude",dto.getLatitude());
jsonObject.put("longitude",dto.getLongitude());
jsonObject.put("alertId",task.getAlertId());
// 推送经纬度 人员姓名 电话 警情id
JSONObject jsonObject = new JSONObject();
DispatchTask task = dispatchTaskServiceImpl.getById(dto.getTaskId());
jsonObject.put("personName", task.getResponseUserName());
jsonObject.put("personTel", task.getResponseUserTel());
jsonObject.put("latitude", dto.getLatitude());
jsonObject.put("longitude", dto.getLongitude());
jsonObject.put("alertId", task.getAlertId());
try {
emqKeeper.getMqttClient().publish(personInfoTopic, jsonObject.toString().getBytes("UTF-8"), 1, false);
} catch (MqttException e) {
logger.error("mqtt发送失败" +jsonObject );
logger.error("mqtt发送失败" + jsonObject);
} catch (UnsupportedEncodingException e) {
logger.error("mqtt发送失败" +jsonObject );
logger.error("mqtt发送失败" + jsonObject);
}
String distance = dispatchTaskService.returnDistanceByTaskId(dto.getTaskId(),dto.getLongitude(),dto.getLatitude());
String distance = dispatchTaskService.returnDistanceByTaskId(dto.getTaskId(), dto.getLongitude(),
dto.getLatitude());
return ResponseHelper.buildResponse(distance);
}
/**
* 获取业务详情
*
......@@ -444,13 +452,12 @@ public class WechatController extends BaseController {
@GetMapping(value = "/getBussinessInfo/{bussinessId}")
@ApiOperation(httpMethod = "GET", value = "获取业务详情", notes = "获取业务详情")
public ResponseModel<WechatMyBussinessDto> getBussinessInfo(@PathVariable Long bussinessId) {
if (ValidationUtil.isEmpty(bussinessId)){
if (ValidationUtil.isEmpty(bussinessId)) {
throw new BadRequest("参数校验失败.");
}
return ResponseHelper.buildResponse(getBussinessDtoById(bussinessId));
}
/**
* 获取任务列表
*
......@@ -459,18 +466,16 @@ public class WechatController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@GetMapping(value = "/getTaskList")
@ApiOperation(httpMethod = "GET", value = "根据用户手机号获取任务列表", notes = "根据用户手机号获取任务列表")
public ResponseModel<List<WechatMyTaskListDto>> getTaskList(@ApiParam(value = "电话号码", required = true) @RequestParam String phone,
@ApiParam(value = "任务类别", required = true) @RequestParam String taskType,
@ApiParam(value = "当前页码", required = true) @RequestParam Long currentPage) {
if (ValidationUtil.isEmpty(phone) ||
ValidationUtil.isEmpty(taskType) ||
ValidationUtil.isEmpty(currentPage)){
public ResponseModel<List<WechatMyTaskListDto>> getTaskList(
@ApiParam(value = "电话号码", required = true) @RequestParam String phone,
@ApiParam(value = "任务类别", required = true) @RequestParam String taskType,
@ApiParam(value = "当前页码", required = true) @RequestParam Long currentPage) {
if (ValidationUtil.isEmpty(phone) || ValidationUtil.isEmpty(taskType) || ValidationUtil.isEmpty(currentPage)) {
throw new BadRequest("参数校验失败.");
}
return ResponseHelper.buildResponse(dispatchTaskService.getTaskListByPhonePager(phone, taskType, currentPage));
}
/**
* 获取我的业务列表
*
......@@ -479,15 +484,16 @@ public class WechatController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@GetMapping(value = "/getBussinessList")
@ApiOperation(httpMethod = "GET", value = "根据用户手机号获取业务列表", notes = "根据用户手机号获取业务列表")
public ResponseModel<List<WechatMyBusinessListDto>> getBussinessList(@ApiParam(value = "电话号码", required = true) @RequestParam String phone,
@ApiParam(value = "业务类别", required = true) @RequestParam String businessType,
@ApiParam(value = "当前页码", required = true) @RequestParam Long currentPage) {
if (ValidationUtil.isEmpty(phone) ||
ValidationUtil.isEmpty(businessType) ||
ValidationUtil.isEmpty(currentPage)){
public ResponseModel<List<WechatMyBusinessListDto>> getBussinessList(
@ApiParam(value = "电话号码", required = true) @RequestParam String phone,
@ApiParam(value = "业务类别", required = true) @RequestParam String businessType,
@ApiParam(value = "当前页码", required = true) @RequestParam Long currentPage) {
if (ValidationUtil.isEmpty(phone) || ValidationUtil.isEmpty(businessType)
|| ValidationUtil.isEmpty(currentPage)) {
throw new BadRequest("参数校验失败.");
}
return ResponseHelper.buildResponse(iAlertCalledService.getBussinessListByPhonePager(phone, businessType, currentPage));
return ResponseHelper
.buildResponse(iAlertCalledService.getBussinessListByPhonePager(phone, businessType, currentPage));
}
/**
......@@ -498,19 +504,19 @@ public class WechatController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/uploadImage")
@ApiOperation(httpMethod = "POST", value = "微信公众号上传图片", notes = "微信公众号上传图片")
public ResponseModel<String> uploadImage(@ApiParam(value = "图片", required = true)@RequestParam MultipartFile file
) {
if (ValidationUtil.isEmpty(file)){
public ResponseModel<String> uploadImage(
@ApiParam(value = "图片", required = true) @RequestParam MultipartFile file) {
if (ValidationUtil.isEmpty(file)) {
throw new BadRequest("参数校验失败.");
}
FeignClientResult<Map<String, String>> date = Systemctl.fileStorageClient.updateCommonFile(file);
String urlString="";
String urlString = "";
if (date != null) {
Map<String, String> map = date.getResult();
Iterator<String> it = map.keySet().iterator();
while (it.hasNext()) {
urlString=it.next();
urlString = it.next();
}
}
return ResponseHelper.buildResponse(urlString);
......@@ -525,10 +531,10 @@ public class WechatController extends BaseController {
@GetMapping(value = "/downloadWechatPic/{mediaId}")
@ApiOperation(httpMethod = "GET", value = "微信公众号从微信服务器下载图片到自己服务器", notes = "微信公众号从微信服务器下载图片到自己服务器")
public ResponseModel<String> uploadImage(@PathVariable String mediaId) {
if (ValidationUtil.isEmpty(mediaId)){
if (ValidationUtil.isEmpty(mediaId)) {
throw new BadRequest("参数校验失败.");
}
String urlString = wechatService.getWechatPicByMediaId(mediaId);
String urlString = wechatService.getWechatPicByMediaId(mediaId);
return ResponseHelper.buildResponse(urlString);
}
......@@ -542,142 +548,141 @@ public class WechatController extends BaseController {
List<AttachmentDto> feedbackDtos = null;
LambdaQueryWrapper<AlertFormValue> queryWrapper = new LambdaQueryWrapper<>();
switch (temp.getTaskTypeCode()) {
case "960" : // 困人救援
temp.setHasDeadHurt("无");
queryWrapper.eq(AlertFormValue::getAlertCalledId, temp.getSequenceNbr());
// 警情动态表单数据
List<AlertFormValue> alertList = iAlertFormValueService.list(queryWrapper);
alertList.stream().forEach(t -> {
String value = t.getFieldValue();
if("trapped_floor_num".equals(t.getFieldCode())) {
// 被困楼层
temp.setTrappedFloorNum(value);
} else if("trapped_num".equals(t.getFieldCode())) {
// 被困人数
temp.setTrappedNum(value);
} else if("injured_num".equals(t.getFieldCode())) {
// 受伤人数
if(StringUtils.isNotEmpty(value)) {
temp.setHasDeadHurt("有");
}
} else if("die_num".equals(t.getFieldCode())) {
// 死亡人数
if(StringUtils.isNotEmpty(value)) {
temp.setHasDeadHurt("有");
}
case "960": // 困人救援
temp.setHasDeadHurt("无");
queryWrapper.eq(AlertFormValue::getAlertCalledId, temp.getSequenceNbr());
// 警情动态表单数据
List<AlertFormValue> alertList = iAlertFormValueService.list(queryWrapper);
alertList.stream().forEach(t -> {
String value = t.getFieldValue();
if ("trapped_floor_num".equals(t.getFieldCode())) {
// 被困楼层
temp.setTrappedFloorNum(value);
} else if ("trapped_num".equals(t.getFieldCode())) {
// 被困人数
temp.setTrappedNum(value);
} else if ("injured_num".equals(t.getFieldCode())) {
// 受伤人数
if (StringUtils.isNotEmpty(value)) {
temp.setHasDeadHurt("有");
}
});
queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(AlertFormValue::getAlertCalledId, temp.getPaperId());
// 派遣动态表单
paperList = iAlertFormValueService.list(queryWrapper);
paperList.stream().forEach(t -> {
String value = t.getFieldValue();
if("error_result".equals(t.getFieldCode())) {
// 故障原因
temp.setErrorResult(value);
} else if("fix_result".equals(t.getFieldCode())) {
// 维修结果
temp.setFixResult(value);
} else if("fix_remark".equals(t.getFieldCode())) {
// 维修备注
temp.setRemark(value);
} else if ("die_num".equals(t.getFieldCode())) {
// 死亡人数
if (StringUtils.isNotEmpty(value)) {
temp.setHasDeadHurt("有");
}
});
imgMap = sourceFileService.getAttachments(temp.getPaperId());
imgDtos = imgMap.get("imgs");
temp.setFixImgs(imgDtos);
break;
case "961" : // 故障维修
queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(AlertFormValue::getAlertCalledId, temp.getPaperId());
// 派遣动态表单
paperList = iAlertFormValueService.list(queryWrapper);
paperList.stream().forEach(t -> {
String value = t.getFieldValue();
if("error_result".equals(t.getFieldCode())) {
// 故障原因
temp.setErrorResult(value);
} else if("fix_result".equals(t.getFieldCode())) {
// 维修结果
temp.setFixResult(value);
} else if("fix_remark".equals(t.getFieldCode())) {
// 维修备注
temp.setRemark(value);
} else if("feedback_result".equals(t.getFieldCode())) {
// 反馈结果
temp.setFeedbackResult(value);
}
});
imgMap = sourceFileService.getAttachments(temp.getPaperId());
imgDtos = imgMap.get("imgs");
temp.setFixImgs(imgDtos);
errorImgMap = sourceFileService.getAttachments(temp.getSequenceNbr());
errorImgDtos = errorImgMap.get("imgs");
temp.setErrorImgs(errorImgDtos);
feedbackDtos = errorImgMap.get("feedbacks");
temp.setFeedBackImgs(feedbackDtos);
break;
case "962" : // 投诉建议
queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(AlertFormValue::getAlertCalledId, temp.getPaperId());
// 派遣动态表单
paperList = iAlertFormValueService.list(queryWrapper);
paperList.stream().forEach(t -> {
String value = t.getFieldValue();
if("action_result".equals(t.getFieldCode())) {
// 处置结果
temp.setActionResult(value);
} else if("main_feedback_result".equals(t.getFieldCode())) {
// 维修结果
temp.setRemark(value);
} else if("feedback_result".equals(t.getFieldCode())) {
// 维修结果
temp.setFeedbackResult(value);
}
});
imgMap = sourceFileService.getAttachments(temp.getPaperId());
imgDtos = imgMap.get("imgs");
temp.setFixImgs(imgDtos);
errorImgMap = sourceFileService.getAttachments(temp.getSequenceNbr());
errorImgDtos = errorImgMap.get("imgs");
temp.setErrorImgs(errorImgDtos);
feedbackDtos = errorImgMap.get("feedbacks");
temp.setFeedBackImgs(feedbackDtos);
break;
}
});
queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(AlertFormValue::getAlertCalledId, temp.getPaperId());
// 派遣动态表单
paperList = iAlertFormValueService.list(queryWrapper);
paperList.stream().forEach(t -> {
String value = t.getFieldValue();
if ("error_result".equals(t.getFieldCode())) {
// 故障原因
temp.setErrorResult(value);
} else if ("fix_result".equals(t.getFieldCode())) {
// 维修结果
temp.setFixResult(value);
} else if ("fix_remark".equals(t.getFieldCode())) {
// 维修备注
temp.setRemark(value);
}
});
imgMap = sourceFileService.getAttachments(temp.getPaperId());
imgDtos = imgMap.get("imgs");
temp.setFixImgs(imgDtos);
break;
case "961": // 故障维修
queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(AlertFormValue::getAlertCalledId, temp.getPaperId());
// 派遣动态表单
paperList = iAlertFormValueService.list(queryWrapper);
paperList.stream().forEach(t -> {
String value = t.getFieldValue();
if ("error_result".equals(t.getFieldCode())) {
// 故障原因
temp.setErrorResult(value);
} else if ("fix_result".equals(t.getFieldCode())) {
// 维修结果
temp.setFixResult(value);
} else if ("fix_remark".equals(t.getFieldCode())) {
// 维修备注
temp.setRemark(value);
} else if ("feedback_result".equals(t.getFieldCode())) {
// 反馈结果
temp.setFeedbackResult(value);
}
});
imgMap = sourceFileService.getAttachments(temp.getPaperId());
imgDtos = imgMap.get("imgs");
temp.setFixImgs(imgDtos);
errorImgMap = sourceFileService.getAttachments(temp.getSequenceNbr());
errorImgDtos = errorImgMap.get("imgs");
temp.setErrorImgs(errorImgDtos);
feedbackDtos = errorImgMap.get("feedbacks");
temp.setFeedBackImgs(feedbackDtos);
break;
case "962": // 投诉建议
queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(AlertFormValue::getAlertCalledId, temp.getPaperId());
// 派遣动态表单
paperList = iAlertFormValueService.list(queryWrapper);
paperList.stream().forEach(t -> {
String value = t.getFieldValue();
if ("action_result".equals(t.getFieldCode())) {
// 处置结果
temp.setActionResult(value);
} else if ("main_feedback_result".equals(t.getFieldCode())) {
// 维修结果
temp.setRemark(value);
} else if ("feedback_result".equals(t.getFieldCode())) {
// 维修结果
temp.setFeedbackResult(value);
}
});
imgMap = sourceFileService.getAttachments(temp.getPaperId());
imgDtos = imgMap.get("imgs");
temp.setFixImgs(imgDtos);
errorImgMap = sourceFileService.getAttachments(temp.getSequenceNbr());
errorImgDtos = errorImgMap.get("imgs");
temp.setErrorImgs(errorImgDtos);
feedbackDtos = errorImgMap.get("feedbacks");
temp.setFeedBackImgs(feedbackDtos);
break;
}
return temp;
}
/**
* 微信端图片上传
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/testWechatFile")
@ApiOperation(httpMethod = "POST", value = "微信公众号上传图片", notes = "微信公众号上传图片")
public ResponseModel<String> testWechatFile(@ApiParam(value = "图片", required = true)@RequestParam MultipartFile file) {
if (ValidationUtil.isEmpty(file)){
throw new BadRequest("参数校验失败.");
}
String accessToken = wechatService.getAccessToken();
String getPicUrl = "https://api.weixin.qq.com/cgi-bin/media/upload?access_token=" + accessToken + "&type=image";
String url = HttpUtils.doPostWithFile(getPicUrl,file,"media",accessToken,"image");
return ResponseHelper.buildResponse(url);
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@GetMapping(value = "/test/templateMsg/warning")
@ApiOperation(httpMethod = "GET", value = "测试发送公众号预警消息", notes = "测试发送公众号预警消息")
public ResponseModel testSendTemplateMsgWarning() {
return ResponseHelper.buildResponse(wechatService.sendTestTemplateMsgWarning());
}
/**
* 微信端图片上传
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/testWechatFile")
@ApiOperation(httpMethod = "POST", value = "微信公众号上传图片", notes = "微信公众号上传图片")
public ResponseModel<String> testWechatFile(
@ApiParam(value = "图片", required = true) @RequestParam MultipartFile file) {
if (ValidationUtil.isEmpty(file)) {
throw new BadRequest("参数校验失败.");
}
String accessToken = wechatService.getAccessToken();
String getPicUrl = "https://api.weixin.qq.com/cgi-bin/media/upload?access_token=" + accessToken + "&type=image";
String url = HttpUtils.doPostWithFile(getPicUrl, file, "media", accessToken, "image");
return ResponseHelper.buildResponse(url);
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@GetMapping(value = "/test/templateMsg/warning")
@ApiOperation(httpMethod = "GET", value = "测试发送公众号预警消息", notes = "测试发送公众号预警消息")
public ResponseModel testSendTemplateMsgWarning() {
return ResponseHelper.buildResponse(wechatService.sendTestTemplateMsgWarning());
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@GetMapping(value = "/test/templateMsg/supervise")
......
......@@ -23,6 +23,7 @@ import com.yeejoin.amos.boot.module.tzs.api.dto.TzsJgProduceInfoDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.TzsJgRegistrationInfoDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.TzsJgSuperviseInfoDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.TzsJgUseInfoDto;
import com.yeejoin.amos.boot.module.tzs.api.entity.EquipmentCategory;
import com.yeejoin.amos.boot.module.tzs.api.entity.PageParam;
import com.yeejoin.amos.boot.module.tzs.api.entity.TzsJgConstructionInfo;
import com.yeejoin.amos.boot.module.tzs.api.entity.TzsJgDesignInfo;
......@@ -98,6 +99,8 @@ public class TzsJgServiceImpl implements ITzsJgService {
@Autowired
ITzsJgEnclosureInfoService iTzsJgEnclosureInfoService;
@Autowired
EquipmentCategoryServiceImpl equipmentCategoryServiceImpl;
/**
* 文件服务器地址
*/
......@@ -113,6 +116,15 @@ public class TzsJgServiceImpl implements ITzsJgService {
tzsJgBasicInfoDto.setOrgBranchCode(result.getResult().getOrgCode());
}
}
if (tzsJgBasicInfoDto.getEquCategory() != null) {
EquipmentCategory equipmentCategory = equipmentCategoryServiceImpl
.getOne(new LambdaQueryWrapper<EquipmentCategory>().eq(EquipmentCategory::getId,
tzsJgBasicInfoDto.getEquCategory()));
if (equipmentCategory != null) {
tzsJgBasicInfoDto.setEquCategory(equipmentCategory.getCode().toString().replaceAll("0+$", ""));
}
}
Page<TzsJgBasicInfoDto> page = new Page<>(pageParam.getCurrent(), pageParam.getSize());
return tzsJgMapper.page(page, tzsJgBasicInfoDto);
}
......@@ -302,14 +314,14 @@ public class TzsJgServiceImpl implements ITzsJgService {
.list(new LambdaQueryWrapper<TzsJgEnclosureInfo>().eq(TzsJgEnclosureInfo::getSequenceCode, code));
List<TzsJgEnclosureInfoDto> enclosureInfoDtoList = new ArrayList<TzsJgEnclosureInfoDto>();
if (!enclosureInfoList.isEmpty()) {
for (TzsJgEnclosureInfo enclosureInfo : enclosureInfoList) {
for (TzsJgEnclosureInfo enclosureInfo : enclosureInfoList) {
TzsJgEnclosureInfoDto enclosureInfoDtoOne = new TzsJgEnclosureInfoDto();
BeanUtils.copyProperties( enclosureInfo, enclosureInfoDtoOne);
//repairInform.forEach(e -> e.setFileUrl(fileServerUrl + e.getFileUrl()));
BeanUtils.copyProperties(enclosureInfo, enclosureInfoDtoOne);
// repairInform.forEach(e -> e.setFileUrl(fileServerUrl + e.getFileUrl()));
enclosureInfoDtoList.add(enclosureInfoDtoOne);
}
}
dto.setSequenceCode(code);
if (superviseInfo != null) {
dto.setSuperviseCode(superviseInfo.getSuperviseCode());
......
package com.yeejoin.amos.boot.module.tzs.flc.biz.controller;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.entity.DataDictionary;
import com.yeejoin.amos.boot.biz.common.service.impl.DataDictionaryServiceImpl;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.module.common.api.dto.AttachmentDto;
import com.yeejoin.amos.boot.module.common.biz.service.impl.SourceFileServiceImpl;
......@@ -15,41 +44,19 @@ import com.yeejoin.amos.boot.module.tzs.flc.api.dto.CylinderFillingRecordDto;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.CylinderInfoDto;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.CylinderUnitDto;
import com.yeejoin.amos.boot.module.tzs.flc.api.entity.CylinderInfo;
import com.yeejoin.amos.boot.module.tzs.flc.api.entity.CylinderTags;
import com.yeejoin.amos.boot.module.tzs.flc.api.entity.CylinderUnit;
import com.yeejoin.amos.boot.module.tzs.flc.biz.service.impl.CylinderFillingRecordServiceImpl;
import com.yeejoin.amos.boot.module.tzs.flc.biz.service.impl.CylinderInfoServiceImpl;
import com.yeejoin.amos.boot.module.tzs.flc.biz.service.impl.CylinderInspectionServiceImpl;
import com.yeejoin.amos.boot.module.tzs.flc.biz.service.impl.CylinderTagsServiceImpl;
import com.yeejoin.amos.boot.module.tzs.flc.biz.service.impl.CylinderUnitServiceImpl;
import com.yeejoin.amos.boot.module.tzs.flc.biz.service.impl.ScheduleService;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.RegionModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 气瓶基本信息
......@@ -62,105 +69,115 @@ import java.util.Map;
@RequestMapping(value = "/cylinder-info")
public class CylinderInfoController extends BaseController {
@Autowired
CylinderInfoServiceImpl cylinderInfoServiceImpl;
@Autowired
CylinderUnitServiceImpl cylinderUnitServiceImpl;
@Autowired
CylinderFillingRecordServiceImpl cylinderFillingRecordServiceImpl;
@Autowired
ESCylinderServiceImpl esCylinderService;
private Map<Integer, String> regionMap;
@Autowired
private SourceFileServiceImpl sourceFileService;
/**
* 新增气瓶基本信息
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/save")
@ApiOperation(httpMethod = "POST", value = "新增气瓶基本信息", notes = "新增气瓶基本信息")
public ResponseModel<CylinderInfoDto> save(@RequestBody CylinderInfoDto model) {
model = cylinderInfoServiceImpl.createWithModel(model);
return ResponseHelper.buildResponse(model);
}
/**
* 根据sequenceNbr更新
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PutMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "PUT", value = "根据sequenceNbr更新气瓶基本信息", notes = "根据sequenceNbr更新气瓶基本信息")
public ResponseModel<CylinderInfoDto> updateBySequenceNbrCylinderInfo(@RequestBody CylinderInfoDto model, @PathVariable(value = "sequenceNbr") Long sequenceNbr) {
model.setSequenceNbr(sequenceNbr);
return ResponseHelper.buildResponse(cylinderInfoServiceImpl.updateWithModel(model));
}
/**
* 根据sequenceNbr删除
*
* @param sequenceNbr 主键
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@DeleteMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "DELETE", value = "根据sequenceNbr删除气瓶基本信息", notes = "根据sequenceNbr删除气瓶基本信息")
public ResponseModel<Boolean> deleteBySequenceNbr(HttpServletRequest request, @PathVariable(value = "sequenceNbr") Long sequenceNbr) {
return ResponseHelper.buildResponse(cylinderInfoServiceImpl.removeById(sequenceNbr));
}
/**
* 根据sequenceNbr查询
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "GET", value = "根据sequenceNbr查询单个气瓶基本信息", notes = "根据sequenceNbr查询单个气瓶基本信息")
public ResponseModel<CylinderInfoDto> selectOne(@PathVariable Long sequenceNbr) {
return ResponseHelper.buildResponse(cylinderInfoServiceImpl.queryBySeq(sequenceNbr));
}
/**
* 列表分页查询
*
* @param current 当前页
* @param current 每页大小
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/page")
@ApiOperation(httpMethod = "GET", value = "气瓶基本信息分页查询", notes = "气瓶基本信息分页查询")
public ResponseModel<Page<CylinderInfoDto>> queryForPage(@RequestParam(value = "current") int current, @RequestParam
(value = "size") int size) {
Page<CylinderInfoDto> page = new Page<CylinderInfoDto>();
page.setCurrent(current);
page.setSize(size);
return ResponseHelper.buildResponse(cylinderInfoServiceImpl.queryForCylinderInfoPage(page));
}
/**
* 列表全部数据查询
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "气瓶基本信息列表全部数据查询", notes = "气瓶基本信息列表全部数据查询")
@GetMapping(value = "/list")
public ResponseModel<List<CylinderInfoDto>> selectForList() {
return ResponseHelper.buildResponse(cylinderInfoServiceImpl.queryForCylinderInfoList());
}
@Autowired
CylinderInfoServiceImpl cylinderInfoServiceImpl;
@Autowired
CylinderUnitServiceImpl cylinderUnitServiceImpl;
@Autowired
CylinderInspectionServiceImpl cylinderInspectionServiceImpl;
@Autowired
CylinderFillingRecordServiceImpl cylinderFillingRecordServiceImpl;
@Autowired
ESCylinderServiceImpl esCylinderService;
private Map<Integer, String> regionMap;
@Autowired
private SourceFileServiceImpl sourceFileService;
@Autowired
DataDictionaryServiceImpl iDataDictionaryService;
@Autowired
CylinderTagsServiceImpl cylinderTagsServiceImpl;
/**
* 新增气瓶基本信息
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/save")
@ApiOperation(httpMethod = "POST", value = "新增气瓶基本信息", notes = "新增气瓶基本信息")
public ResponseModel<CylinderInfoDto> save(@RequestBody CylinderInfoDto model) {
model = cylinderInfoServiceImpl.createWithModel(model);
return ResponseHelper.buildResponse(model);
}
/**
* 根据sequenceNbr更新
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PutMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "PUT", value = "根据sequenceNbr更新气瓶基本信息", notes = "根据sequenceNbr更新气瓶基本信息")
public ResponseModel<CylinderInfoDto> updateBySequenceNbrCylinderInfo(@RequestBody CylinderInfoDto model,
@PathVariable(value = "sequenceNbr") Long sequenceNbr) {
model.setSequenceNbr(sequenceNbr);
return ResponseHelper.buildResponse(cylinderInfoServiceImpl.updateWithModel(model));
}
/**
* 根据sequenceNbr删除
*
* @param sequenceNbr 主键
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@DeleteMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "DELETE", value = "根据sequenceNbr删除气瓶基本信息", notes = "根据sequenceNbr删除气瓶基本信息")
public ResponseModel<Boolean> deleteBySequenceNbr(HttpServletRequest request,
@PathVariable(value = "sequenceNbr") Long sequenceNbr) {
return ResponseHelper.buildResponse(cylinderInfoServiceImpl.removeById(sequenceNbr));
}
/**
* 根据sequenceNbr查询
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "GET", value = "根据sequenceNbr查询单个气瓶基本信息", notes = "根据sequenceNbr查询单个气瓶基本信息")
public ResponseModel<CylinderInfoDto> selectOne(@PathVariable Long sequenceNbr) {
return ResponseHelper.buildResponse(cylinderInfoServiceImpl.queryBySeq(sequenceNbr));
}
/**
* 列表分页查询
*
* @param current 当前页
* @param current 每页大小
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/page")
@ApiOperation(httpMethod = "GET", value = "气瓶基本信息分页查询", notes = "气瓶基本信息分页查询")
public ResponseModel<Page<CylinderInfoDto>> queryForPage(@RequestParam(value = "current") int current,
@RequestParam(value = "size") int size) {
Page<CylinderInfoDto> page = new Page<CylinderInfoDto>();
page.setCurrent(current);
page.setSize(size);
return ResponseHelper.buildResponse(cylinderInfoServiceImpl.queryForCylinderInfoPage(page));
}
/**
* 列表全部数据查询
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "气瓶基本信息列表全部数据查询", notes = "气瓶基本信息列表全部数据查询")
@GetMapping(value = "/list")
public ResponseModel<List<CylinderInfoDto>> selectForList() {
return ResponseHelper.buildResponse(cylinderInfoServiceImpl.queryForCylinderInfoList());
}
// /**
// * 获取气瓶增加减少总量及环比
......@@ -212,32 +229,31 @@ public class CylinderInfoController extends BaseController {
// return ResponseHelper.buildResponse(result);
// }
/**
* 获取气瓶增加减少总量及环比
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/getCylinderInfo")
@ApiOperation(httpMethod = "GET", value = "获取气瓶增加减少总量及环比", notes = "获取气瓶增加减少总量及环比")
public ResponseModel<Boolean> getCylinderInfo1() {
cylinderInfoServiceImpl.getCylinderInfo();
return ResponseHelper.buildResponse(true);
}
/**
* 获取企业增加减少总量及环比
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/getCylinderUnitInfo")
@ApiOperation(httpMethod = "GET", value = "获取企业增加减少总量及环比", notes = "获取企业增加减少总量及环比")
public ResponseModel<Boolean> getCylinderUnitInfo() {
cylinderInfoServiceImpl.getCylinderUnitInfo();
return ResponseHelper.buildResponse(true);
}
/**
* 获取气瓶增加减少总量及环比
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/getCylinderInfo")
@ApiOperation(httpMethod = "GET", value = "获取气瓶增加减少总量及环比", notes = "获取气瓶增加减少总量及环比")
public ResponseModel<Boolean> getCylinderInfo1() {
cylinderInfoServiceImpl.getCylinderInfo();
return ResponseHelper.buildResponse(true);
}
/**
* 获取企业增加减少总量及环比
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/getCylinderUnitInfo")
@ApiOperation(httpMethod = "GET", value = "获取企业增加减少总量及环比", notes = "获取企业增加减少总量及环比")
public ResponseModel<Boolean> getCylinderUnitInfo() {
cylinderInfoServiceImpl.getCylinderUnitInfo();
return ResponseHelper.buildResponse(true);
}
// // 数据完整性计算 气瓶企业信息 气瓶基本信息 标签 检验 充装 充装审核
// /**
......@@ -375,194 +391,218 @@ public class CylinderInfoController extends BaseController {
// return ResponseHelper.buildResponse(true);
// }
/**
* 数据完整性同步
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/addIntegrityData")
@ApiOperation(httpMethod = "GET", value = "数据完整性同步", notes = "数据完整性同步")
public ResponseModel<Boolean> addIntegrityData() {
cylinderInfoServiceImpl.addIntegrityData();
return ResponseHelper.buildResponse(true);
}
/**
* 数据完整性同步
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/synAreaData")
@ApiOperation(httpMethod = "GET", value = "同步区域数据", notes = "同步区域数据")
public ResponseModel<Boolean> synAreaData() {
cylinderInfoServiceImpl.synAreaData();
return ResponseHelper.buildResponse(true);
}
/**
* 装卸液体数据同步
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/synFillingUnloadData")
@ApiOperation(httpMethod = "GET", value = "装卸液体数据同步", notes = "装卸液体数据同步")
public ResponseModel<Boolean> synFillingUnloadData() {
cylinderInfoServiceImpl.synFillingUnloadData();
return ResponseHelper.buildResponse(true);
}
/**
* 列表分页查询
*
* @param pageNum 当前页
* @param pageSize 每页大小
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/cyinderRecordList")
@ApiOperation(httpMethod = "GET", value = "获取登陆人所在气瓶充装信息", notes = "获取登陆人所在气瓶充装信息")
public ResponseModel<IPage<CylinderFillingRecordDto>> cyinderRecordList(@RequestParam(value = "pageNum") int pageNum, @RequestParam(value = "pageSize") int pageSize, String sort, CylinderFillingRecordDto cylinderFillingRecordDto) {
Page<CylinderFillingRecordDto> page = new Page<>();
page.setCurrent(pageNum);
page.setSize(pageSize);
String sortParam = "";
String sortRule = "";
if (sort != null) { // 排序失效
String[] date = sort.split(",");
if (date[1].equals("ascend")) {
sortParam = "r." + RedisKey.humpToLine(date[0]);
sortRule = "asc";
} else {
sortParam = "r." + RedisKey.humpToLine(date[0]);
sortRule = "desc";
}
} else {
sortParam = "r.sync_date";
sortRule = "desc";
}
if (StringUtils.isEmpty(cylinderFillingRecordDto.getSequenceCode())) {
cylinderFillingRecordDto.setAppId("9B150BB7D0C21A7A62BD6837E14A44BF");
}
Page<CylinderFillingRecordDto> pageBean = cylinderFillingRecordServiceImpl.queryListByQueryDto(page, cylinderFillingRecordDto, sortParam, sortRule);
Page<CylinderFillingRecordDto> result = new Page<>(pageNum, pageSize);
long totle = pageBean.getTotal();
result.setRecords(pageBean.getRecords());
result.setTotal(totle);
return ResponseHelper.buildResponse(result);
}
/**
* 气瓶基本信息
*
* @param pageNum 当前页
* @param pageSize 每页大小
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/cyinderInfoList")
@ApiOperation(httpMethod = "GET", value = "获取登陆人所在气瓶基本信息", notes = "获取登陆人所在气瓶基本信息")
public ResponseModel<IPage<CylinderInfoDto>> cyinderInfoList(@RequestParam(value = "pageNum") String pageNum, @RequestParam(value = "pageSize") String pageSize, String sort, CylinderInfoDto cylinderInfoDto) {
QueryWrapper<CylinderInfo> cylinderInfoQueryWrapper = new QueryWrapper<>();
if (StringUtils.isNotEmpty(cylinderInfoDto.getRegionCode())) {
List<String> appids = new ArrayList<>();
List<CylinderUnit> unitList = cylinderUnitServiceImpl.list(new LambdaQueryWrapper<CylinderUnit>().like(CylinderUnit::getRegionCode, cylinderInfoDto.getRegionCode()));
unitList.forEach(u -> {
appids.add(u.getAppId());
});
if (appids.size() == 0) {
appids.add("-1");
}
cylinderInfoDto.setAppIds(appids);
}
setQueryWrapper(cylinderInfoQueryWrapper, cylinderInfoDto, sort);
Page<CylinderInfo> pageBean;
if (StringUtils.isBlank(pageNum) || StringUtils.isBlank(pageSize)) {
pageBean = new Page<>(0, Long.MAX_VALUE);
} else {
pageBean = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
}
IPage<CylinderInfo> page = cylinderInfoServiceImpl.page(pageBean, cylinderInfoQueryWrapper);
int num = cylinderInfoServiceImpl.count(cylinderInfoQueryWrapper);
pageBean.setTotal(num);
IPage<CylinderInfoDto> result = BeanDtoVoUtils.cyinderInfoIPageDto(page);
return ResponseHelper.buildResponse(result);
}
private QueryWrapper<CylinderInfo> setQueryWrapper(QueryWrapper<CylinderInfo> queryWrapper, CylinderInfoDto cylinderInfo, String sort) {
if (cylinderInfo.getAppIds() != null && cylinderInfo.getAppIds().size() > 0) {
queryWrapper.in("app_id", cylinderInfo.getAppIds());
}
if (sort != null) { // 排序失效
String[] date = sort.split(",");
if ("ascend".equals(date[1])) {
queryWrapper.orderByAsc(RedisKey.humpToLine(date[0]));
} else {
queryWrapper.orderByDesc(RedisKey.humpToLine(date[0]));
}
} else {
queryWrapper.orderByDesc("sync_date");
}
if (!ValidationUtil.isEmpty(cylinderInfo.getAppId())) {
queryWrapper.eq("app_id", cylinderInfo.getAppId());
}
/**
* 数据完整性同步
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/addIntegrityData")
@ApiOperation(httpMethod = "GET", value = "数据完整性同步", notes = "数据完整性同步")
public ResponseModel<Boolean> addIntegrityData() {
cylinderInfoServiceImpl.addIntegrityData();
return ResponseHelper.buildResponse(true);
}
/**
* 数据完整性同步
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/synAreaData")
@ApiOperation(httpMethod = "GET", value = "同步区域数据", notes = "同步区域数据")
public ResponseModel<Boolean> synAreaData() {
cylinderInfoServiceImpl.synAreaData();
return ResponseHelper.buildResponse(true);
}
/**
* 装卸液体数据同步
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/synFillingUnloadData")
@ApiOperation(httpMethod = "GET", value = "装卸液体数据同步", notes = "装卸液体数据同步")
public ResponseModel<Boolean> synFillingUnloadData() {
cylinderInfoServiceImpl.synFillingUnloadData();
return ResponseHelper.buildResponse(true);
}
/**
* 列表分页查询
*
* @param pageNum 当前页
* @param pageSize 每页大小
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/cyinderRecordList")
@ApiOperation(httpMethod = "GET", value = "获取登陆人所在气瓶充装信息", notes = "获取登陆人所在气瓶充装信息")
public ResponseModel<IPage<CylinderFillingRecordDto>> cyinderRecordList(
@RequestParam(value = "pageNum") int pageNum, @RequestParam(value = "pageSize") int pageSize, String sort,
CylinderFillingRecordDto cylinderFillingRecordDto) {
Page<CylinderFillingRecordDto> page = new Page<>();
page.setCurrent(pageNum);
page.setSize(pageSize);
String sortParam = "";
String sortRule = "";
if (sort != null) { // 排序失效
String[] date = sort.split(",");
if (date[1].equals("ascend")) {
sortParam = "r." + RedisKey.humpToLine(date[0]);
sortRule = "asc";
} else {
sortParam = "r." + RedisKey.humpToLine(date[0]);
sortRule = "desc";
}
} else {
sortParam = "r.sync_date";
sortRule = "desc";
}
if (StringUtils.isEmpty(cylinderFillingRecordDto.getSequenceCode())) {
cylinderFillingRecordDto.setAppId("9B150BB7D0C21A7A62BD6837E14A44BF");
}
Page<CylinderFillingRecordDto> pageBean = cylinderFillingRecordServiceImpl.queryListByQueryDto(page,
cylinderFillingRecordDto, sortParam, sortRule);
Page<CylinderFillingRecordDto> result = new Page<>(pageNum, pageSize);
long totle = pageBean.getTotal();
result.setRecords(pageBean.getRecords());
result.setTotal(totle);
return ResponseHelper.buildResponse(result);
}
/**
* 气瓶基本信息
*
* @param pageNum 当前页
* @param pageSize 每页大小
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/cyinderInfoList")
@ApiOperation(httpMethod = "GET", value = "获取登陆人所在气瓶基本信息", notes = "获取登陆人所在气瓶基本信息")
public ResponseModel<IPage<CylinderInfoDto>> cyinderInfoList(@RequestParam(value = "pageNum") String pageNum,
@RequestParam(value = "pageSize") String pageSize, String sort, CylinderInfoDto cylinderInfoDto) {
QueryWrapper<CylinderInfo> cylinderInfoQueryWrapper = new QueryWrapper<>();
if (StringUtils.isNotEmpty(cylinderInfoDto.getRegionCode())) {
List<String> appids = new ArrayList<>();
List<CylinderUnit> unitList = cylinderUnitServiceImpl.list(new LambdaQueryWrapper<CylinderUnit>()
.like(CylinderUnit::getRegionCode, cylinderInfoDto.getRegionCode()));
unitList.forEach(u -> {
appids.add(u.getAppId());
});
if (appids.size() == 0) {
appids.add("-1");
}
cylinderInfoDto.setAppIds(appids);
}
setQueryWrapper(cylinderInfoQueryWrapper, cylinderInfoDto, sort);
Page<CylinderInfo> pageBean;
if (StringUtils.isBlank(pageNum) || StringUtils.isBlank(pageSize)) {
pageBean = new Page<>(0, Long.MAX_VALUE);
} else {
pageBean = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
}
IPage<CylinderInfo> page;
if (cylinderInfoDto.getIsWarn() == 0) {
page = cylinderInfoServiceImpl.page(pageBean, cylinderInfoQueryWrapper);
} else {
page = cylinderInspectionServiceImpl.queryOutOfDateCylinder(pageBean, cylinderInfoDto.getAppId());
}
// int num = cylinderInfoServiceImpl.count(cylinderInfoQueryWrapper);
// pageBean.setTotal(num);
IPage<CylinderInfoDto> result = BeanDtoVoUtils.cyinderInfoIPageDto(page);
result.getRecords().forEach(i -> {
DataDictionary fillingMedia = iDataDictionaryService.getOne(new LambdaQueryWrapper<DataDictionary>()
.eq(DataDictionary::getCode, i.getFillingMedia()).eq(DataDictionary::getType, "CZJZMC"));
i.setFillingMediaName(fillingMedia != null ? fillingMedia.getName() : null);
DataDictionary cylinderVariety = iDataDictionaryService.getOne(new LambdaQueryWrapper<DataDictionary>()
.eq(DataDictionary::getSequenceNbr, i.getCylinderVariety()));
i.setCylinderVarietyName(cylinderVariety != null ? cylinderVariety.getName() : null);
DataDictionary cylinderStatus = iDataDictionaryService.getOne(
new LambdaQueryWrapper<DataDictionary>().eq(DataDictionary::getSequenceNbr, i.getCylinderStatus()));
i.setCylinderStatusStr(cylinderStatus != null ? cylinderStatus.getName() : null);
CylinderTags cylinderTags = cylinderTagsServiceImpl.getOne(
new LambdaQueryWrapper<CylinderTags>().eq(CylinderTags::getSequenceCode, i.getSequenceCode()));
i.setQrCode(cylinderTags != null ? cylinderTags.getQrCode() : null);
i.setElectronicLabelCode(cylinderTags != null ? cylinderTags.getElectronicLabelCode() : null);
});
return ResponseHelper.buildResponse(result);
}
private QueryWrapper<CylinderInfo> setQueryWrapper(QueryWrapper<CylinderInfo> queryWrapper,
CylinderInfoDto cylinderInfo, String sort) {
if (cylinderInfo.getAppIds() != null && cylinderInfo.getAppIds().size() > 0) {
queryWrapper.in("app_id", cylinderInfo.getAppIds());
}
if (sort != null) { // 排序失效
String[] date = sort.split(",");
if ("ascend".equals(date[1])) {
queryWrapper.orderByAsc(RedisKey.humpToLine(date[0]));
} else {
queryWrapper.orderByDesc(RedisKey.humpToLine(date[0]));
}
} else {
queryWrapper.orderByDesc("sync_date");
}
if (!ValidationUtil.isEmpty(cylinderInfo.getAppId())) {
queryWrapper.eq("app_id", cylinderInfo.getAppId());
}
// if (!ValidationUtil.isEmpty(cylinderInfo.getInspectionDateStart())) {
// queryWrapper.ge("inspection_date", cylinderInfo.getInspectionDateStart());
// }
// if (!ValidationUtil.isEmpty(cylinderInfo.getInspectionDateEnd())) {
// queryWrapper.le("inspection_date", cylinderInfo.getInspectionDateEnd());
// }
if (!ValidationUtil.isEmpty(cylinderInfo.getUnitName())) { // 产权单位
queryWrapper.like("unit_name", cylinderInfo.getUnitName());
}
if (!ValidationUtil.isEmpty(cylinderInfo.getFactoryNum())) {// 出厂编号
queryWrapper.like("factory_num", cylinderInfo.getFactoryNum());
}
if (!ValidationUtil.isEmpty(cylinderInfo.getCylinderVariety())) {// 气瓶品种
queryWrapper.eq("cylinder_variety", cylinderInfo.getCylinderVariety());
}
if (!ValidationUtil.isEmpty(cylinderInfo.getUnitName())) { // 产权单位
queryWrapper.like("unit_name", cylinderInfo.getUnitName());
}
if (!ValidationUtil.isEmpty(cylinderInfo.getFactoryNum())) {// 出厂编号
queryWrapper.like("factory_num", cylinderInfo.getFactoryNum());
}
if (!ValidationUtil.isEmpty(cylinderInfo.getCylinderVariety())) {// 气瓶品种
queryWrapper.eq("cylinder_variety", cylinderInfo.getCylinderVariety());
}
// if (!ValidationUtil.isEmpty(cylinderInfo.getQrCode())) {// 二维码编号
// queryWrapper.like("qrCode", cylinderInfo.getQrCode());
// }
// if (!ValidationUtil.isEmpty(cylinderInfo.getElectronicLabelCode())) {// 电子标签编号
// queryWrapper.like("electronic_label_code", cylinderInfo.getElectronicLabelCode());
// }
if (!ValidationUtil.isEmpty(cylinderInfo.getSequenceCode())) {// 气瓶唯一标识码
queryWrapper.like("sequence_code", cylinderInfo.getSequenceCode());
}
if (!ValidationUtil.isEmpty(cylinderInfo.getUnitInnerCode())) {// 单位内部编号
queryWrapper.like("unit_inner_code", cylinderInfo.getUnitInnerCode());
}
if (!ValidationUtil.isEmpty(cylinderInfo.getCylinderStatus())) {// 气瓶状态
queryWrapper.eq("cylinder_status", cylinderInfo.getCylinderStatus());
}
if (!ValidationUtil.isEmpty(cylinderInfo.getManufacturingUnit())) {// 制造单位
queryWrapper.like("manufacturing_unit", cylinderInfo.getManufacturingUnit());
}
return queryWrapper;
}
/**
* 获取气瓶详细信息
*
* @param sequenceNbr
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/cyinderInfo/{sequenceNbr}")
@ApiOperation(httpMethod = "GET", value = "获取气瓶详细信息", notes = "获取气瓶详细信息")
public ResponseModel<CylinderInfoDto> cyinderInfoList(@PathVariable Long sequenceNbr) {
CylinderInfo cylinderInfo = cylinderInfoServiceImpl.getById(sequenceNbr);
Map<String, List<AttachmentDto>> imgMap = sourceFileService.getAttachments(cylinderInfo.getSequenceNbr());
CylinderInfoDto target = new CylinderInfoDto();
// 把原对象数据拷贝到新对象
BeanUtils.copyProperties(cylinderInfo, target);
if (!ValidationUtil.isEmpty(cylinderInfo.getSequenceCode())) {// 气瓶唯一标识码
queryWrapper.like("sequence_code", cylinderInfo.getSequenceCode());
}
if (!ValidationUtil.isEmpty(cylinderInfo.getUnitInnerCode())) {// 单位内部编号
queryWrapper.like("unit_inner_code", cylinderInfo.getUnitInnerCode());
}
if (!ValidationUtil.isEmpty(cylinderInfo.getCylinderStatus())) {// 气瓶状态
queryWrapper.eq("cylinder_status", cylinderInfo.getCylinderStatus());
}
if (!ValidationUtil.isEmpty(cylinderInfo.getManufacturingUnit())) {// 制造单位
queryWrapper.like("manufacturing_unit", cylinderInfo.getManufacturingUnit());
}
return queryWrapper;
}
/**
* 获取气瓶详细信息
*
* @param sequenceNbr
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/cyinderInfo/{sequenceNbr}")
@ApiOperation(httpMethod = "GET", value = "获取气瓶详细信息", notes = "获取气瓶详细信息")
public ResponseModel<CylinderInfoDto> cyinderInfoList(@PathVariable Long sequenceNbr) {
CylinderInfo cylinderInfo = cylinderInfoServiceImpl.getById(sequenceNbr);
Map<String, List<AttachmentDto>> imgMap = sourceFileService.getAttachments(cylinderInfo.getSequenceNbr());
CylinderInfoDto target = new CylinderInfoDto();
// 把原对象数据拷贝到新对象
BeanUtils.copyProperties(cylinderInfo, target);
// if (0 == cylinderInfo.getCylinderStatus()) {
// target.setCylinderStatusStr("在用");
// } else if (1 == cylinderInfo.getCylinderStatus()) {
......@@ -599,67 +639,66 @@ public class CylinderInfoController extends BaseController {
// }
// target.setAttachments(imgMap);
return ResponseHelper.buildResponse(target);
}
/**
* 获取登陆人所在气瓶充装单位信息
*
* @param pageNum 当前页
* @param pageSize 每页大小
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/cyinderUnitList")
@ApiOperation(httpMethod = "GET", value = "获取登陆人所在气瓶充装单位信息", notes = "获取登陆人所在气瓶充装单位信息")
public ResponseModel<IPage<CylinderUnitDto>> cyinderUnitList(@RequestParam(value = "pageNum") String pageNum, @RequestParam(value = "pageSize") String pageSize, String sort, CylinderUnitDto cylinderUnitDto) {
Page<CylinderUnit> pageBean;
IPage<CylinderUnit> page;
QueryWrapper<CylinderUnit> cylinderUnitQueryWrapper = new QueryWrapper<>();
setQueryWrapper(cylinderUnitQueryWrapper, cylinderUnitDto, sort);
if (StringUtils.isBlank(pageNum) || StringUtils.isBlank(pageSize)) {
pageBean = new Page<>(0, Long.MAX_VALUE);
} else {
pageBean = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
}
page = cylinderUnitServiceImpl.page(pageBean, cylinderUnitQueryWrapper);
int num = cylinderUnitServiceImpl.count(cylinderUnitQueryWrapper);
pageBean.setTotal(num);
IPage<CylinderUnitDto> result = this.cyinderInfoIPageDto(page);
return ResponseHelper.buildResponse(result);
}
/**
* 获取气瓶充装单位详情
*
* @param sequenceNbr
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/cylinderUnit/{sequenceNbr}")
@ApiOperation(httpMethod = "GET", value = "获取气瓶充装单位详情", notes = "获取气瓶充装单位详情")
public ResponseModel<CylinderUnitDto> cyinderUnitList(@PathVariable Long sequenceNbr) {
CylinderUnit cylinderUnit = cylinderUnitServiceImpl.getById(sequenceNbr);
if (this.regionMap == null) {
this.regionMap = new HashMap<>();
Collection<RegionModel> regions = Systemctl.regionClient.queryForTree(null).getResult();
regions.stream().forEach(t -> {
this.addRegionsMap(regionMap, t);
});
}
CylinderUnitDto target = new CylinderUnitDto();
// 把原对象数据拷贝到新对象
BeanUtils.copyProperties(cylinderUnit, target);
String regionCode = cylinderUnit.getRegionCode();
String[] regionCodes = regionCode.split("#");
regionCode = "";
for (int i = 0; i < regionCodes.length; i++) {
regionCode += this.regionMap.get(Integer.parseInt(regionCodes[i]));
}
target.setRegionCode(regionCode);
return ResponseHelper.buildResponse(target);
}
/**
* 获取登陆人所在气瓶充装单位信息
*
* @param pageNum 当前页
* @param pageSize 每页大小
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/cyinderUnitList")
@ApiOperation(httpMethod = "GET", value = "获取登陆人所在气瓶充装单位信息", notes = "获取登陆人所在气瓶充装单位信息")
public ResponseModel<IPage<CylinderUnitDto>> cyinderUnitList(@RequestParam(value = "pageNum") String pageNum,
@RequestParam(value = "pageSize") String pageSize, String sort, CylinderUnitDto cylinderUnitDto) {
Page<CylinderUnit> pageBean;
IPage<CylinderUnit> page;
QueryWrapper<CylinderUnit> cylinderUnitQueryWrapper = new QueryWrapper<>();
setQueryWrapper(cylinderUnitQueryWrapper, cylinderUnitDto, sort);
if (StringUtils.isBlank(pageNum) || StringUtils.isBlank(pageSize)) {
pageBean = new Page<>(0, Long.MAX_VALUE);
} else {
pageBean = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
}
page = cylinderUnitServiceImpl.page(pageBean, cylinderUnitQueryWrapper);
int num = cylinderUnitServiceImpl.count(cylinderUnitQueryWrapper);
pageBean.setTotal(num);
IPage<CylinderUnitDto> result = this.cyinderInfoIPageDto(page);
return ResponseHelper.buildResponse(result);
}
/**
* 获取气瓶充装单位详情
*
* @param sequenceNbr
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/cylinderUnit/{sequenceNbr}")
@ApiOperation(httpMethod = "GET", value = "获取气瓶充装单位详情", notes = "获取气瓶充装单位详情")
public ResponseModel<CylinderUnitDto> cyinderUnitList(@PathVariable Long sequenceNbr) {
CylinderUnit cylinderUnit = cylinderUnitServiceImpl.getById(sequenceNbr);
if (this.regionMap == null) {
this.regionMap = new HashMap<>();
Collection<RegionModel> regions = Systemctl.regionClient.queryForTree(null).getResult();
regions.stream().forEach(t -> {
this.addRegionsMap(regionMap, t);
});
}
CylinderUnitDto target = new CylinderUnitDto();
// 把原对象数据拷贝到新对象
BeanUtils.copyProperties(cylinderUnit, target);
String regionCode = cylinderUnit.getRegionCode();
String[] regionCodes = regionCode.split("#");
regionCode = "";
for (int i = 0; i < regionCodes.length; i++) {
regionCode += this.regionMap.get(Integer.parseInt(regionCodes[i]));
}
target.setRegionCode(regionCode);
// if (1 == cylinderUnit.getUnitType()) {
// target.setUnitTypeStr("液化石油气瓶充装单位");
// } else if (2 == cylinderUnit.getUnitType()) {
......@@ -670,7 +709,11 @@ public class CylinderInfoController extends BaseController {
// target.setUnitTypeStr("");
// }
// target.setCylinderNumber((long) cylinderInfoServiceImpl.count(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getAppId, target.getAppId())));
// target.setCylinderOutOfDate((long) cylinderInfoServiceImpl.count(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getAppId, target.getAppId()).le(CylinderInfo::getNextInspectionDate, new Date())));
Page<CylinderInfo> pageBean = new Page<>(0, Long.MAX_VALUE);
Page<CylinderInfo> page = cylinderInspectionServiceImpl.queryOutOfDateCylinder(pageBean,
cylinderUnit.getAppId());
long outOfDate = page.getTotal();
target.setCylinderOutOfDate(String.valueOf(outOfDate));
// Date nextDate = target.getFillingPermitDate();
// long dates = nextDate.getTime() - System.currentTimeMillis();
// if (dates >= 1000 * 60 * 60 * 24 * 200) {
......@@ -681,21 +724,21 @@ public class CylinderInfoController extends BaseController {
// target.setLicenseStatus(0);
// }
return ResponseHelper.buildResponse(target);
}
private QueryWrapper<CylinderUnit> setQueryWrapper(QueryWrapper<CylinderUnit> queryWrapper, CylinderUnitDto cylinderUnitDto, String sort) {
if (sort != null) { // 排序失效
String[] date = sort.split(",");
if (date[1].equals("ascend")) {
queryWrapper.orderByAsc(RedisKey.humpToLine(date[0]));
} else {
queryWrapper.orderByDesc(RedisKey.humpToLine(date[0]));
}
} else {
queryWrapper.orderByDesc("sync_date");
}
return ResponseHelper.buildResponse(target);
}
private QueryWrapper<CylinderUnit> setQueryWrapper(QueryWrapper<CylinderUnit> queryWrapper,
CylinderUnitDto cylinderUnitDto, String sort) {
if (sort != null) { // 排序失效
String[] date = sort.split(",");
if (date[1].equals("ascend")) {
queryWrapper.orderByAsc(RedisKey.humpToLine(date[0]));
} else {
queryWrapper.orderByDesc(RedisKey.humpToLine(date[0]));
}
} else {
queryWrapper.orderByDesc("sync_date");
}
// if (!ValidationUtil.isEmpty(cylinderUnitDto.getFillingPermitDateStart())) { // 许可有效期
// queryWrapper.ge("filling_permit_date", cylinderUnitDto.getFillingPermitDateStart());
......@@ -705,61 +748,60 @@ public class CylinderInfoController extends BaseController {
// queryWrapper.le("filling_permit_date", cylinderUnitDto.getFillingPermitDateEnd());
// }
if (!ValidationUtil.isEmpty(cylinderUnitDto.getUnitName())) { // 企业名称
queryWrapper.like("unit_name", cylinderUnitDto.getUnitName());
}
if (!ValidationUtil.isEmpty(cylinderUnitDto.getUnitName())) { // 企业名称
queryWrapper.like("unit_name", cylinderUnitDto.getUnitName());
}
// if (!ValidationUtil.isEmpty(cylinderUnitDto.getUnitType())) {// 企业类型
// queryWrapper.eq("unit_type", cylinderUnitDto.getUnitType());
// }
if (!ValidationUtil.isEmpty(cylinderUnitDto.getCreditCode())) {// 统一社会信用代码
queryWrapper.like("credit_code", cylinderUnitDto.getCreditCode());
}
if (!ValidationUtil.isEmpty(cylinderUnitDto.getAddress())) {// 详细地址
queryWrapper.like("address", cylinderUnitDto.getAddress());
}
if (!ValidationUtil.isEmpty(cylinderUnitDto.getUnitPerson())) {// 企业负责人
queryWrapper.like("unit_person", cylinderUnitDto.getUnitPerson());
}
if (!ValidationUtil.isEmpty(cylinderUnitDto.getPersonMobilePhone())) {// 负责人手机
queryWrapper.like("person_mobile_phone", cylinderUnitDto.getPersonMobilePhone());
}
if (!ValidationUtil.isEmpty(cylinderUnitDto.getCreditCode())) {// 统一社会信用代码
queryWrapper.like("credit_code", cylinderUnitDto.getCreditCode());
}
if (!ValidationUtil.isEmpty(cylinderUnitDto.getAddress())) {// 详细地址
queryWrapper.like("address", cylinderUnitDto.getAddress());
}
if (!ValidationUtil.isEmpty(cylinderUnitDto.getUnitPerson())) {// 企业负责人
queryWrapper.like("unit_person", cylinderUnitDto.getUnitPerson());
}
if (!ValidationUtil.isEmpty(cylinderUnitDto.getPersonMobilePhone())) {// 负责人手机
queryWrapper.like("person_mobile_phone", cylinderUnitDto.getPersonMobilePhone());
}
// if (!ValidationUtil.isEmpty(cylinderUnitDto.getFillingLicense())) {// 许可证号
// queryWrapper.like("filling_license", cylinderUnitDto.getFillingLicense());
// }
// if (!ValidationUtil.isEmpty(cylinderUnitDto.getFillingPermScope())) {// 许可范围
// queryWrapper.like("filling_perm_scope", cylinderUnitDto.getFillingPermScope());
// }
if (!ValidationUtil.isEmpty(cylinderUnitDto.getRegionCode())) {// 所属区域
queryWrapper.like("region_code", cylinderUnitDto.getRegionCode());
}
return queryWrapper;
}
private IPage<CylinderUnitDto> cyinderInfoIPageDto(IPage<CylinderUnit> page) {
if (this.regionMap == null) {
this.regionMap = new HashMap<>();
Collection<RegionModel> regions = Systemctl.regionClient.queryForTree(null).getResult();
regions.stream().forEach(t -> {
this.addRegionsMap(regionMap, t);
});
}
return page.convert(item -> {
try {
CylinderUnitDto target = new CylinderUnitDto();
// 把原对象数据拷贝到新对象
BeanUtils.copyProperties(item, target);
String regionCode = item.getRegionCode();
String[] regionCodes = regionCode.split("#");
regionCode = "";
for (int i = 0; i < regionCodes.length; i++) {
regionCode += this.regionMap.get(Integer.parseInt(regionCodes[i]));
}
target.setRegionCode(regionCode);
if (!ValidationUtil.isEmpty(cylinderUnitDto.getRegionCode())) {// 所属区域
queryWrapper.like("region_code", cylinderUnitDto.getRegionCode());
}
return queryWrapper;
}
private IPage<CylinderUnitDto> cyinderInfoIPageDto(IPage<CylinderUnit> page) {
if (this.regionMap == null) {
this.regionMap = new HashMap<>();
Collection<RegionModel> regions = Systemctl.regionClient.queryForTree(null).getResult();
regions.stream().forEach(t -> {
this.addRegionsMap(regionMap, t);
});
}
return page.convert(item -> {
try {
CylinderUnitDto target = new CylinderUnitDto();
// 把原对象数据拷贝到新对象
BeanUtils.copyProperties(item, target);
String regionCode = item.getRegionCode();
String[] regionCodes = regionCode.split("#");
regionCode = "";
for (int i = 0; i < regionCodes.length; i++) {
regionCode += this.regionMap.get(Integer.parseInt(regionCodes[i]));
}
target.setRegionCode(regionCode);
// if (1 == item.getUnitType()) {
// target.setUnitTypeStr("液化石油气瓶充装单位");
// } else if (2 == item.getUnitType()) {
......@@ -769,183 +811,209 @@ public class CylinderInfoController extends BaseController {
// } else {
// target.setUnitTypeStr("");
// }
target.setCylinderNumber( cylinderInfoServiceImpl.count(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getAppId, target.getAppId())));
return target;
} catch (Exception e) {
return null;
}
});
}
private void addRegionsMap(Map<Integer, String> regionMap, RegionModel region) {
regionMap.put(region.getRegionCode(), region.getRegionName());
if (region.getChildren() != null) {
region.getChildren().stream().forEach(c -> {
addRegionsMap(regionMap, c);
});
}
}
/**
* 企业气瓶总量数据同步
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/synUnitCylinderInfoData")
@ApiOperation(httpMethod = "GET", value = "企业气瓶总量数据同步", notes = "企业气瓶总量数据同步")
public ResponseModel<Boolean> synUnitCylinderInfoData() {
cylinderInfoServiceImpl.synUnitCylinderInfoData();
return ResponseHelper.buildResponse(true);
}
/**
* 企业气瓶充装数据同步
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/synUnitCylinderFillingData")
@ApiOperation(httpMethod = "GET", value = "企业气瓶充装数据同步", notes = "企业气瓶充装数据同步")
public ResponseModel<Boolean> synUnitCylinderFillingData() {
cylinderInfoServiceImpl.synUnitCylinderFillingData();
return ResponseHelper.buildResponse(true);
}
/**
* 企业气瓶标签数量比同步
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/synUnitCylinderTagsData")
@ApiOperation(httpMethod = "GET", value = "企业气瓶标签数量比同步", notes = "企业气瓶标签数量比同步")
public ResponseModel<Boolean> synUnitCylinderTagsData() {
cylinderInfoServiceImpl.synUnitCylinderTagsData();
return ResponseHelper.buildResponse(true);
}
/**
* 企业数据完整度同步
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/synUnitIntegrityData")
@ApiOperation(httpMethod = "GET", value = "企业数据完整度同步", notes = "企业数据完整度同步")
public ResponseModel<Boolean> synUnitIntegrityData() {
cylinderInfoServiceImpl.synUnitIntegrityData();
return ResponseHelper.buildResponse(true);
}
/**
* 气瓶充装检查情况同步
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/synUnitFillingCheckData")
@ApiOperation(httpMethod = "GET", value = "气瓶充装检查情况同步", notes = "气瓶充装检查情况同步")
public ResponseModel<Boolean> synUnitFillingCheckData() {
cylinderInfoServiceImpl.synUnitFillingCheckData();
return ResponseHelper.buildResponse(true);
}
/**
* 装卸液体企业数据同步
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/synFillingUnloadUnitData")
@ApiOperation(httpMethod = "GET", value = "装卸液体企业数据同步", notes = "装卸液体企业数据同步")
public ResponseModel<Boolean> synFillingUnloadUnitData() {
cylinderInfoServiceImpl.synFillingUnloadUnitData();
return ResponseHelper.buildResponse(true);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = "气瓶超期数量统计")
@GetMapping(value = "/{earlyWarningLevel}/statistics")
public ResponseModel<Integer> getOverDateStatisticsNumber(@PathVariable String earlyWarningLevel){
return ResponseHelper.buildResponse(cylinderInfoServiceImpl.getOverDateStatisticsNumber(earlyWarningLevel));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = "按照预警类型查询气瓶分页列表",notes = "按照预警类型查询气瓶分页列表")
@GetMapping(value = "/{earlyWarningLevel}/page")
public ResponseModel<Page<CylinderInfoDto>> getOverDateStatisticsNumber(
@RequestParam(value = "current") int current,
@RequestParam(value = "size") int size,
@PathVariable String earlyWarningLevel){
Page<CylinderInfoDto> page = new Page<>();
page.setCurrent(current);
page.setSize(size);
return ResponseHelper.buildResponse(cylinderInfoServiceImpl.earlyWarningLevelPageList(page,earlyWarningLevel));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = "气瓶详情")
@GetMapping(value = "/{sequenceCode}/detail")
public ResponseModel<CylinderInfoDto> getDetail(@PathVariable String sequenceCode){
return ResponseHelper.buildResponse(cylinderInfoServiceImpl.getDetail(sequenceCode));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = "气瓶处置日志")
@GetMapping(value = "/msg/{sequenceCode}/list")
public ResponseModel<List<MsgLog>> getMsgList(@PathVariable String sequenceCode,
@RequestParam(value = "terminalType",required = false) String terminalType){
return ResponseHelper.buildResponse(cylinderInfoServiceImpl.getMsgList(sequenceCode, terminalType));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "PUT",value = "下次检验日期更新",notes = "下次检验日期更新")
@PutMapping(value = "/nextInspectionDate/update")
public ResponseModel<Boolean> nextInspectionDateUpdate(@RequestBody List<CylinderInfoDto> cylinderInfoDtos){
return ResponseHelper.buildResponse(cylinderInfoServiceImpl.nextInspectionDateUpdate(cylinderInfoDtos));
}
/**
* 气瓶信息放入es
*
* @return
*/
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/init", method = RequestMethod.PUT)
@ApiOperation(httpMethod = "PUT", value = "气瓶信息放入es", notes = "气瓶信息放入es")
public void init(Integer num) {
IPage<CylinderInfo> cylinderInfoPage = new Page<>();
Integer count = cylinderInfoServiceImpl.count();
Integer times = 0;
if (ValidationUtil.isEmpty(num) && count != 0) {
times = count / 500;
int last = count % 500;
if (last > 0) {
times++;
}
} else if (count != 0) {
times = num;
}
for (int i = 0; i < times; i++) {
cylinderInfoPage.setCurrent(i);
cylinderInfoPage.setSize(500);
cylinderInfoPage = cylinderInfoServiceImpl.page(cylinderInfoPage);
esCylinderService.saveEsCylinderToES(cylinderInfoPage.getRecords());
}
}
@Autowired
private ScheduleService scheduleService;
@TycloudOperation(ApiLevel = UserType.AGENCY , needAuth = false)
@ApiOperation(httpMethod = "GET",value = "气瓶/设备/许可预警测试接口(实际应为定时任务)")
@GetMapping(value = "/test")
public void test(){
scheduleService.calEarlyWarningLevel();
}
target.setCylinderNumber(cylinderInfoServiceImpl
.count(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getAppId, target.getAppId())));
return target;
} catch (Exception e) {
return null;
}
});
}
private void addRegionsMap(Map<Integer, String> regionMap, RegionModel region) {
regionMap.put(region.getRegionCode(), region.getRegionName());
if (region.getChildren() != null) {
region.getChildren().stream().forEach(c -> {
addRegionsMap(regionMap, c);
});
}
}
/**
* 企业气瓶总量数据同步
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/synUnitCylinderInfoData")
@ApiOperation(httpMethod = "GET", value = "企业气瓶总量数据同步", notes = "企业气瓶总量数据同步")
public ResponseModel<Boolean> synUnitCylinderInfoData() {
cylinderInfoServiceImpl.synUnitCylinderInfoData();
return ResponseHelper.buildResponse(true);
}
/**
* 企业气瓶充装数据同步
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/synUnitCylinderFillingData")
@ApiOperation(httpMethod = "GET", value = "企业气瓶充装数据同步", notes = "企业气瓶充装数据同步")
public ResponseModel<Boolean> synUnitCylinderFillingData() {
cylinderInfoServiceImpl.synUnitCylinderFillingData();
return ResponseHelper.buildResponse(true);
}
/**
* 企业气瓶标签数量比同步
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/synUnitCylinderTagsData")
@ApiOperation(httpMethod = "GET", value = "企业气瓶标签数量比同步", notes = "企业气瓶标签数量比同步")
public ResponseModel<Boolean> synUnitCylinderTagsData() {
cylinderInfoServiceImpl.synUnitCylinderTagsData();
return ResponseHelper.buildResponse(true);
}
/**
* 企业数据完整度同步
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/synUnitIntegrityData")
@ApiOperation(httpMethod = "GET", value = "企业数据完整度同步", notes = "企业数据完整度同步")
public ResponseModel<Boolean> synUnitIntegrityData() {
cylinderInfoServiceImpl.synUnitIntegrityData();
return ResponseHelper.buildResponse(true);
}
/**
* 气瓶充装检查情况同步
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/synUnitFillingCheckData")
@ApiOperation(httpMethod = "GET", value = "气瓶充装检查情况同步", notes = "气瓶充装检查情况同步")
public ResponseModel<Boolean> synUnitFillingCheckData() {
cylinderInfoServiceImpl.synUnitFillingCheckData();
return ResponseHelper.buildResponse(true);
}
/**
* 装卸液体企业数据同步
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/synFillingUnloadUnitData")
@ApiOperation(httpMethod = "GET", value = "装卸液体企业数据同步", notes = "装卸液体企业数据同步")
public ResponseModel<Boolean> synFillingUnloadUnitData() {
cylinderInfoServiceImpl.synFillingUnloadUnitData();
return ResponseHelper.buildResponse(true);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "气瓶超期数量统计")
@GetMapping(value = "/{earlyWarningLevel}/statistics")
public ResponseModel<Integer> getOverDateStatisticsNumber(@PathVariable String earlyWarningLevel) {
return ResponseHelper.buildResponse(cylinderInfoServiceImpl.getOverDateStatisticsNumber(earlyWarningLevel));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "按照预警类型查询气瓶分页列表", notes = "按照预警类型查询气瓶分页列表")
@GetMapping(value = "/{earlyWarningLevel}/page")
public ResponseModel<Page<CylinderInfoDto>> getOverDateStatisticsNumber(
@RequestParam(value = "current") int current, @RequestParam(value = "size") int size,
@PathVariable String earlyWarningLevel) {
Page<CylinderInfoDto> page = new Page<>();
page.setCurrent(current);
page.setSize(size);
return ResponseHelper.buildResponse(cylinderInfoServiceImpl.earlyWarningLevelPageList(page, earlyWarningLevel));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "气瓶详情")
@GetMapping(value = "/{sequenceCode}/detail")
public ResponseModel<CylinderInfoDto> getDetail(@PathVariable String sequenceCode) {
return ResponseHelper.buildResponse(cylinderInfoServiceImpl.getDetail(sequenceCode));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "气瓶处置日志")
@GetMapping(value = "/msg/{sequenceCode}/list")
public ResponseModel<List<MsgLog>> getMsgList(@PathVariable String sequenceCode,
@RequestParam(value = "terminalType", required = false) String terminalType) {
return ResponseHelper.buildResponse(cylinderInfoServiceImpl.getMsgList(sequenceCode, terminalType));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "PUT", value = "下次检验日期更新", notes = "下次检验日期更新")
@PutMapping(value = "/nextInspectionDate/update")
public ResponseModel<Boolean> nextInspectionDateUpdate(@RequestBody List<CylinderInfoDto> cylinderInfoDtos) {
return ResponseHelper.buildResponse(cylinderInfoServiceImpl.nextInspectionDateUpdate(cylinderInfoDtos));
}
/**
* 气瓶信息放入es
*
* @return
*/
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/init", method = RequestMethod.PUT)
@ApiOperation(httpMethod = "PUT", value = "气瓶信息放入es", notes = "气瓶信息放入es")
public void init(Integer num) {
IPage<CylinderInfo> cylinderInfoPage = new Page<>();
Integer count = cylinderInfoServiceImpl.count();
Integer times = 0;
if (ValidationUtil.isEmpty(num) && count != 0) {
times = count / 500;
int last = count % 500;
if (last > 0) {
times++;
}
} else if (count != 0) {
times = num;
}
for (int i = 0; i < times; i++) {
cylinderInfoPage.setCurrent(i);
cylinderInfoPage.setSize(500);
cylinderInfoPage = cylinderInfoServiceImpl.page(cylinderInfoPage);
esCylinderService.saveEsCylinderToES(cylinderInfoPage.getRecords());
}
}
@Autowired
private ScheduleService scheduleService;
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "气瓶/设备/许可预警测试接口(实际应为定时任务)")
@GetMapping(value = "/test")
public void test() {
scheduleService.calEarlyWarningLevel();
}
/**
* 企业数据完整度同步
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/addAll")
@ApiOperation(httpMethod = "GET", value = "企业数据完整度同步", notes = "企业数据完整度同步")
public ResponseModel<Boolean> addAll() {
new Thread(new Runnable() {
@Override
public void run() {
cylinderInfoServiceImpl.synFillingUnloadData();
cylinderInfoServiceImpl.synAreaData();
cylinderInfoServiceImpl.addIntegrityData();
cylinderInfoServiceImpl.getCylinderUnitInfo();
cylinderInfoServiceImpl.getCylinderInfo();
cylinderInfoServiceImpl.synUnitCylinderInfoData();
cylinderInfoServiceImpl.synUnitCylinderFillingData();
cylinderInfoServiceImpl.synUnitCylinderTagsData();
cylinderInfoServiceImpl.synUnitIntegrityData();
cylinderInfoServiceImpl.synUnitFillingCheckData();
cylinderInfoServiceImpl.synFillingUnloadUnitData();
}
}).start();
return ResponseHelper.buildResponse(true);
}
}
......@@ -6,6 +6,7 @@ import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.CylinderUnitDto;
import com.yeejoin.amos.boot.module.tzs.flc.api.entity.CylinderUnit;
import com.yeejoin.amos.boot.module.tzs.flc.api.service.ICylinderInfoService;
import com.yeejoin.amos.boot.module.tzs.flc.api.service.ICylinderUnitService;
import com.yeejoin.amos.boot.module.tzs.flc.biz.service.impl.CylinderUnitServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -36,8 +37,8 @@ import java.util.Map;
@RequestMapping(value = "/cylinder-unit")
public class CylinderUnitController extends BaseController {
@Autowired
CylinderUnitServiceImpl cylinderUnitServiceImpl;
@Autowired
CylinderUnitServiceImpl cylinderUnitServiceImpl;
@Autowired
ICylinderInfoService iCylinderInfoService;
......@@ -50,68 +51,72 @@ public class CylinderUnitController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/queryCylinderUnitList", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "通过regionCode查询气瓶企业", notes = "通过regionCode查询气瓶企业")
public ResponseModel<List<CylinderUnitDto>> querySpecialEquipmentList(@RequestParam String regionCode){
List<CylinderUnit> unitList = cylinderUnitServiceImpl.list(new LambdaQueryWrapper<CylinderUnit>().like(CylinderUnit::getRegionCode,regionCode));
public ResponseModel<List<CylinderUnitDto>> querySpecialEquipmentList(@RequestParam String regionCode) {
List<CylinderUnit> unitList = cylinderUnitServiceImpl
.list(new LambdaQueryWrapper<CylinderUnit>().like(CylinderUnit::getRegionCode, regionCode));
List<CylinderUnitDto> result = new ArrayList<>();
unitList.stream().forEach(t -> {
CylinderUnitDto temp = new CylinderUnitDto();
BeanUtils.copyProperties(t,temp);
// if(t.getFillingPermitDate() != null && t.getFillingPermitDate().getTime() < System.currentTimeMillis()) {
// temp.setOutOfDate(true);
// } else {
// temp.setOutOfDate(false);
// }
BeanUtils.copyProperties(t, temp);
int num = cylinderUnitServiceImpl.getWarnNumByAppId(t.getAppId());
if (num > 0) {
temp.setOutOfDate(true);
} else {
temp.setOutOfDate(false);
}
result.add(temp);
});
return ResponseHelper.buildResponse(result);
}
/**
* 根据sequenceNbr查询
*
* @param id 主键
* @return
*/
/**
* 根据sequenceNbr查询
*
* @param id 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/getUnitInfo")
@ApiOperation(httpMethod = "GET",value = "根据sequenceNbr查询单个气瓶企业信息", notes = "根据sequenceNbr查询单个气瓶企业信息")
@ApiOperation(httpMethod = "GET", value = "根据sequenceNbr查询单个气瓶企业信息", notes = "根据sequenceNbr查询单个气瓶企业信息")
public ResponseModel<CylinderUnitDto> selectOne(@RequestParam Long id) {
CylinderUnitDto unit = cylinderUnitServiceImpl.queryBySeq(id);
unit.setEvaluate("★★★★★");
// 查询气瓶数量以及过期数量
Map<String, String> cylinderInfo = iCylinderInfoService.queryNumAndOutOfDateNum(unit.getSequenceNbr());
if(cylinderInfo != null) {
if(cylinderInfo.get("cylinderNum") != null) {
int num = cylinderUnitServiceImpl.getWarnNumByAppId(unit.getAppId());
if (cylinderInfo != null) {
if (cylinderInfo.get("cylinderNum") != null) {
unit.setCylinderNumber(Integer.valueOf(String.valueOf(cylinderInfo.get("cylinderNum"))));
}
if(cylinderInfo.get("outOfDateNum") != null) {
unit.setCylinderOutOfDate(String.valueOf(cylinderInfo.get("outOfDateNum")));
}
if(cylinderInfo.get("fillingPermitDate") != null){
// if (cylinderInfo.get("outOfDateNum") != null) {
// unit.setCylinderOutOfDate(String.valueOf(cylinderInfo.get("outOfDateNum")));
// }
unit.setCylinderOutOfDate(String.valueOf(num));
if (cylinderInfo.get("fillingPermitDate") != null) {
unit.setFillingPermitDate(String.valueOf(cylinderInfo.get("fillingPermitDate")));
}
}
return ResponseHelper.buildResponse(unit);
return ResponseHelper.buildResponse(unit);
}
/**
* 列表分页查询
*
* @param current 当前页
* @param current 每页大小
* @return
*/
* 列表分页查询
*
* @param current 当前页
* @param current 每页大小
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/page")
@ApiOperation(httpMethod = "GET",value = "气瓶企业信息分页查询", notes = "气瓶企业信息分页查询")
public ResponseModel<Page<CylinderUnitDto>> queryForPage(@RequestParam(value = "current") int current,@RequestParam
(value = "size") int size) {
Page<CylinderUnitDto> page = new Page<CylinderUnitDto>();
page.setCurrent(current);
page.setSize(size);
return ResponseHelper.buildResponse(cylinderUnitServiceImpl.queryForCylinderUnitPage(page));
@ApiOperation(httpMethod = "GET", value = "气瓶企业信息分页查询", notes = "气瓶企业信息分页查询")
public ResponseModel<Page<CylinderUnitDto>> queryForPage(@RequestParam(value = "current") int current,
@RequestParam(value = "size") int size) {
Page<CylinderUnitDto> page = new Page<CylinderUnitDto>();
page.setCurrent(current);
page.setSize(size);
return ResponseHelper.buildResponse(cylinderUnitServiceImpl.queryForCylinderUnitPage(page));
}
}
......@@ -75,688 +75,733 @@ import lombok.extern.slf4j.Slf4j;
*/
@Service
@Slf4j
public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, CylinderInfo, CylinderInfoMapper> implements ICylinderInfoService {
public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, CylinderInfo, CylinderInfoMapper>
implements ICylinderInfoService {
@Autowired
CylinderUnitServiceImpl cylinderUnitServiceImpl;
@Autowired
CylinderUnitServiceImpl cylinderUnitServiceImpl;
@Autowired
CylinderUnitDataServiceImpl cylinderUnitDataServiceImpl;
@Autowired
CylinderUnitDataServiceImpl cylinderUnitDataServiceImpl;
@Autowired
CylinderInfoDataServiceImpl cylinderInfoDataServiceImpl;
@Autowired
CylinderInfoDataServiceImpl cylinderInfoDataServiceImpl;
@Autowired
CylinderTagsServiceImpl cylinderTagsServiceImpl;
@Autowired
CylinderTagsServiceImpl cylinderTagsServiceImpl;
@Autowired
CylinderFillingServiceImpl cylinderFillingServiceImpl;
@Autowired
CylinderFillingServiceImpl cylinderFillingServiceImpl;
@Autowired
CylinderIntegrityDataServiceImpl cylinderIntegrityDataServiceImpl;
@Autowired
CylinderIntegrityDataServiceImpl cylinderIntegrityDataServiceImpl;
@Autowired
CylinderFillingRecordServiceImpl cylinderFillingRecordServiceImpl;
@Autowired
CylinderFillingRecordServiceImpl cylinderFillingRecordServiceImpl;
@Autowired
CylinderFillingCheckServiceImpl cylinderFillingCheckServiceImpl;
@Autowired
CylinderFillingCheckServiceImpl cylinderFillingCheckServiceImpl;
@Autowired
CylinderAreaDataServiceImpl cylinderAreaDataServiceImpl;
@Autowired
CylinderAreaDataServiceImpl cylinderAreaDataServiceImpl;
@Autowired
CylinderFillingUnloadDataServiceImpl cylinderFillingUnloadDataServiceImpl;
@Autowired
CylinderInfoDataUnitServiceImpl cylinderInfoDataUnitServiceImpl;
@Autowired
CylinderFillingDataUnitServiceImpl cylinderFillingDataUnitServiceImpl;
@Autowired
CylinderTagsDataUnitServiceImpl cylinderTagsDataUnitServiceImpl;
@Autowired
CylinderIntegrityDataUnitServiceImpl cylinderIntegrityDataUnitServiceImpl;
@Autowired
CylinderFillingCheckDataUnitServiceImpl cylinderFillingCheckDataUnitServiceImpl;
@Autowired
CylinderFillingUnloadDataUnitServiceImpl cylinderFillingUnloadDataUnitServiceImpl;
@Autowired
MsgLogServiceImpl msgLogService;
@Autowired
private RuleTrigger ruleTrigger;
@Autowired
TzsAuthServiceImpl tzsAuthService;
@Autowired
private ScheduleMapper scheduleMapper;
@Value("${cylinder-early-warning-packageId:气瓶监管/cylwarningmsg}")
private String packageId;
@Value("${cylinder-early-warning-packageId:气瓶消息预警/cylwarningmsg}")
private String cylPackageId;
@Autowired
StartPlatformTokenService startPlatformTokenService;
/**
* 分页查询
*/
public Page<CylinderInfoDto> queryForCylinderInfoPage(Page<CylinderInfoDto> page) {
return queryForPage(page, null, false);
}
/**
* 列表查询 示例
*/
public List<CylinderInfoDto> queryForCylinderInfoList() {
return queryForList("", false);
}
@Override
public Map<String, String> queryNumAndOutOfDateNum(Long unitId) {
return baseMapper.queryNumAndOutOfDateNum(unitId);
}
/**
* 获取上个月气瓶总量
*/
public Integer getLastMonthInfoTotal(String regionCode) {
return baseMapper.getLastMonthInfoTotal(regionCode);
}
/**
* 获取上上个月气瓶总量
*/
public Integer getMonthBeforeLastInfoTotal(String regionCode) {
return baseMapper.getMonthBeforeLastInfoTotal(regionCode);
}
public Integer getInfoTotalByRegionCode(String regionCode) {
return baseMapper.getInfoTotalByRegionCode(regionCode);
}
public Double queryIntegirtyByAppId(String appId) {
return this.baseMapper.queryIntegirtyByAppId(appId);
}
public Integer getWarnNum(String code) {
return baseMapper.getWarnNum(code);
}
/**
* 按单位统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void synFillingUnloadData() {
cylinderFillingUnloadDataServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingUnloadData>());
countByRegion(regionModel -> {
Calendar now = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
for (int i = 0; i < 30; i++) {
now.add(Calendar.DATE, -1);
CylinderFillingUnloadDataDto temp = new CylinderFillingUnloadDataDto();
Double fillingSum = cylinderFillingRecordServiceImpl.getFillingSum(String.valueOf(regionModel.getRegionCode()), now.getTime());
Double unloadSum = 0d;
temp.setFillingSum(fillingSum);
temp.setRegionCode(String.valueOf(regionModel.getRegionCode()));
temp.setStatisDate(now.getTime());
temp.setStatisDateStr(sdf.format(now.getTime()));
temp.setUnloadSum(unloadSum);
cylinderFillingUnloadDataServiceImpl.createWithModel(temp);
}
});
}
/**
* 按区域统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void synAreaData() {
cylinderAreaDataServiceImpl.remove(new LambdaQueryWrapper<CylinderAreaData>());
countByRegion(regionModel -> {
CylinderAreaDataDto temp = new CylinderAreaDataDto();
temp.setAreaName(regionModel.getRegionName());
String code = regionModel.getRegionCode() + "";
Integer cylinderTotal = this.getInfoTotalByRegionCode(code);
Integer cylinderUnitTotal = cylinderUnitServiceImpl.getUnitTotalByRegionCode(code);
Integer cylinderUnitWarn = cylinderUnitServiceImpl.getWarnNum(code);
Integer cylinderInfoWarn = this.getWarnNum(code);
int warmTotal = cylinderUnitWarn + cylinderInfoWarn;
String parentCode = "";
if ("610000".equals(code)) {
parentCode = "-1";
} else if (!"00".equals(code.substring(4, 6))) {
parentCode = code.substring(0, 4) + "00";
} else {
parentCode = "610000";
}
temp.setCylinderNum(Long.valueOf(cylinderTotal));
temp.setParentRegionCode(parentCode);
temp.setRegionCode(regionModel.getRegionCode() + "");
temp.setUnitNum(Long.valueOf(cylinderUnitTotal));
temp.setWarnNum((long) warmTotal);
cylinderAreaDataServiceImpl.createWithModel(temp);
});
}
/**
* 按区域统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "* * 2 * * ?")
public void addIntegrityData() {
System.out.println("====================数据完整性开始============================");
cylinderIntegrityDataServiceImpl.remove(new LambdaQueryWrapper<CylinderIntegrityData>());
countByRegion(regionModel -> {
List<CylinderUnit> unitlist = cylinderUnitServiceImpl.list(new LambdaQueryWrapper<CylinderUnit>().like(CylinderUnit::getRegionCode, regionModel.getRegionCode()));
List<CylinderIntegrityDataDto> tempList = new LinkedList<>();
System.out.println("====================regioncode: "+regionModel.getRegionCode()+"============================");
unitlist.forEach(t -> {
System.out.println("====================appId: "+t.getAppId()+"============================");
CylinderIntegrityDataDto temp = new CylinderIntegrityDataDto();
String appId = t.getAppId();
Double totalIntegirty = 0d;
// tz_cylinder_info
Double unitIntegirty = t.getIntegrity();
unitIntegirty=unitIntegirty==null?0d:unitIntegirty;
//tz_cylinder_tags
Double tagIntegirty = cylinderTagsServiceImpl.queryIntegirtyByAppId(appId);
tagIntegirty=tagIntegirty==null?0d:tagIntegirty;
//tz_cylinder_info
Double infoIntegirty = this.queryIntegirtyByAppId(appId);
infoIntegirty=infoIntegirty==null?0d:infoIntegirty;
// tz_cylinder_filling_record 30天内
Double recordIntegirty = cylinderFillingRecordServiceImpl.queryIntegirtyByAppId(appId);
recordIntegirty=recordIntegirty==null?0d:recordIntegirty;
//tz_cylinder_filling 30天内ji
Double fillingIntegirty = cylinderFillingServiceImpl.queryIntegirtyByAppId(appId);
fillingIntegirty=fillingIntegirty==null?0d:fillingIntegirty;
//tz_cylinder_filling_check 30天内
Double checkIntegirty = cylinderFillingCheckServiceImpl.queryIntegirtyByAppId(appId);
checkIntegirty=checkIntegirty==null?0d:checkIntegirty;
totalIntegirty = (unitIntegirty + tagIntegirty + infoIntegirty + recordIntegirty + fillingIntegirty + checkIntegirty) / 6;
BigDecimal bg = new BigDecimal(totalIntegirty);
totalIntegirty = bg.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue() * 100;
temp.setAppId(appId);
temp.setRegionCode(String.valueOf(regionModel.getRegionCode()));
temp.setIntegrity(totalIntegirty);
temp.setUnitName(t.getUnitName());
// 判断list 是否达到5个,如果达到则对比最后一个进行替换
if (tempList.size() == 5) {
if (tempList.get(0).getIntegrity() < totalIntegirty) {
tempList.set(0, temp);
}
} else {
tempList.add(temp);
}
tempList.sort(Comparator.comparing(CylinderIntegrityDataDto::getIntegrity));
});
tempList.forEach(t -> {
System.out.println("====================unitName: "+t.getUnitName()+"============================");
t.setUpdateTime(new Date());
cylinderIntegrityDataServiceImpl.createWithModel(t);
});
});
System.out.println("====================数据完整性结束============================");
}
/**
* 企业总量按区域统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void getCylinderUnitInfo() {
cylinderUnitDataServiceImpl.remove(new LambdaQueryWrapper<CylinderUnitData>());
countByRegion(regionModel -> {
String regionCode = String.valueOf(regionModel.getRegionCode());
Integer cylinderUnitTotal = cylinderUnitServiceImpl.getUnitTotalByRegionCode(regionCode);
Double lastUnitTotal = Double.valueOf(cylinderUnitServiceImpl.getLastMonthUnitTotal(regionCode));
Double monthUnitLastInfo = Double.valueOf(cylinderUnitServiceImpl.getMonthBeforeLastUnitTotal(regionCode));
double changeNum = lastUnitTotal - monthUnitLastInfo;
double percent = 0d;
if (monthUnitLastInfo != 0) {
percent = changeNum / monthUnitLastInfo;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
CylinderUnitDataDto temp = new CylinderUnitDataDto();
temp.setChangeSum((long) changeNum);
temp.setChangePercent((int) (percent * 100) + "");
temp.setRegionCode(regionCode);
temp.setTotalSum((long) cylinderUnitTotal);
temp.setUpdateTime(new Date());
cylinderUnitDataServiceImpl.createWithModel(temp);
});
}
/**
* 气瓶总量按区域统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void getCylinderInfo() {
cylinderInfoDataServiceImpl.remove(new LambdaQueryWrapper<>());
countByRegion(regionModel -> {
CylinderInfoDataDto temp = new CylinderInfoDataDto();
String regionCode = String.valueOf(regionModel.getRegionCode());
Integer cylinderTotal = this.getInfoTotalByRegionCode(regionCode);//当前总数
Double lastInfoTotal = Double.valueOf(this.getLastMonthInfoTotal(regionCode));//上月总数
Double monthBeforeLastInfo = Double.valueOf(this.getMonthBeforeLastInfoTotal(regionCode));//上上月总数
double percent = 0d;
if (monthBeforeLastInfo != 0) {
percent = (lastInfoTotal - monthBeforeLastInfo) / monthBeforeLastInfo;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
temp.setChangeSum((long) (lastInfoTotal - monthBeforeLastInfo));
temp.setChangePercent((int) (percent * 100) + "");
temp.setRegionCode(regionCode);
temp.setTotalSum((long) cylinderTotal);
cylinderInfoDataServiceImpl.createWithModel(temp);
});
}
/**
* 按单位统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void synUnitCylinderInfoData() {
cylinderInfoDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderInfoDataUnit>());
countByUnit(cylinderUnit -> {
CylinderInfoDataUnitDto temp = new CylinderInfoDataUnitDto();
temp.setAppId(cylinderUnit.getAppId());
int count = this.count(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getAppId, cylinderUnit.getAppId()));//当前总数
temp.setTotalSum((long) count);
Double thismonth = Double.valueOf(baseMapper.getLastMonthInfoTotalUnit(cylinderUnit.getAppId()));//上月总数
Double lastmonth = Double.valueOf(baseMapper.getMonthBeforeLastInfoTotalUnit(cylinderUnit.getAppId()));//上上月总数
double percent = 0d;
if (lastmonth != 0) {
percent = (thismonth - lastmonth) / lastmonth;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
temp.setChangeSum((long) (thismonth - lastmonth));
temp.setChangePercent((int) (percent * 100) + "");
cylinderInfoDataUnitServiceImpl.createWithModel(temp);
});
}
/**
* 充装量按单位和月统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void synUnitCylinderFillingData() {
cylinderFillingDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingDataUnit>());
countByUnit(cylinderUnit -> {
// 按照月份 获取数据 取一年数据
Calendar calendar = Calendar.getInstance();
// 按月份获取充装量
// 当月与上月 对比获取数据
for (int i = 0; i < 12; i++) {
// 获取当月数据
CylinderFillingDataUnitDto temp = new CylinderFillingDataUnitDto();
String year = calendar.get(Calendar.YEAR) + "";
int month = calendar.get(Calendar.MONTH) + 1;
String monthStr = month < 10 ? "0" + month : month + "";
temp.setFillingYear(year);
temp.setFillingMonth(monthStr);
//本月
Double thisMonth = cylinderFillingRecordServiceImpl.getFillingSumByMonth(cylinderUnit.getAppId(), calendar.getTime());
temp.setTotalSum(thisMonth);
calendar.add(Calendar.MONTH, -1);
//上月
Double lastMonth = cylinderFillingRecordServiceImpl.getFillingSumByMonth(cylinderUnit.getAppId(), calendar.getTime());
double percent = 0d;
if (lastMonth != 0) {
percent = (thisMonth - lastMonth) / lastMonth;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
temp.setChangePercent((int) (percent * 100) + "");
temp.setAppId(cylinderUnit.getAppId());
temp.setChangeSum(thisMonth - lastMonth);
cylinderFillingDataUnitServiceImpl.createWithModel(temp);
}
});
}
/**
* 按单位统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void synUnitCylinderTagsData() {
cylinderTagsDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderTagsDataUnit>());
countByUnit(cylinderUnit -> {
CylinderTagsDataUnitDto temp = new CylinderTagsDataUnitDto();
temp.setAppId(cylinderUnit.getAppId());
int cylinder = this.count(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getAppId, cylinderUnit.getAppId()));
int tags = cylinderTagsServiceImpl.count(new LambdaQueryWrapper<CylinderTags>().eq(CylinderTags::getAppId, cylinderUnit.getAppId()));
double percent = 0d;
if (tags != 0) {
percent = (double) cylinder / (double) tags;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
temp.setCylinderSum((long) cylinder);
temp.setTagsSum((long) tags);
temp.setTagPercent(percent * 100);
cylinderTagsDataUnitServiceImpl.createWithModel(temp);
});
}
/**
* 按单位统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void synUnitIntegrityData() {
cylinderIntegrityDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderIntegrityDataUnit>());
countByUnit(cylinderUnit -> {
// 企业信息
CylinderIntegrityDataUnitDto uninInfo = new CylinderIntegrityDataUnitDto();
uninInfo.setAppId(cylinderUnit.getAppId());
uninInfo.setDataType("企业信息");
Double unitIntegirty = cylinderUnit.getIntegrity();
uninInfo.setIntegrity(unitIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(uninInfo);
// 气瓶基本信息
CylinderIntegrityDataUnitDto cylinderInfo = new CylinderIntegrityDataUnitDto();
cylinderInfo.setAppId(cylinderUnit.getAppId());
cylinderInfo.setDataType("气瓶基本信息");
Double cylinderIntegirty = this.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderInfo.setIntegrity(cylinderIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderInfo);
// 气瓶标签信息
CylinderIntegrityDataUnitDto cylinderTag = new CylinderIntegrityDataUnitDto();
cylinderTag.setAppId(cylinderUnit.getAppId());
cylinderTag.setDataType("气瓶标签信息");
Double tagIntegirty = cylinderTagsServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderTag.setIntegrity(tagIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderTag);
// 气瓶检验信息
CylinderIntegrityDataUnitDto cylinderInspection = new CylinderIntegrityDataUnitDto();
cylinderInspection.setAppId(cylinderUnit.getAppId());
cylinderInspection.setDataType("气瓶检验信息");
cylinderInspection.setIntegrity(0d);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderInspection);
// 充装前检查
CylinderIntegrityDataUnitDto cylinderFilling = new CylinderIntegrityDataUnitDto();
cylinderFilling.setAppId(cylinderUnit.getAppId());
cylinderFilling.setDataType("充装前检查");
Double fillingIntegirty = cylinderFillingServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderFilling.setIntegrity(fillingIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderFilling);
// 充装信息
CylinderIntegrityDataUnitDto cylinderRecord = new CylinderIntegrityDataUnitDto();
cylinderRecord.setAppId(cylinderUnit.getAppId());
cylinderRecord.setDataType("充装信息");
Double recordIntegirty = cylinderFillingRecordServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderRecord.setIntegrity(recordIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderRecord);
// 充装后复查
CylinderIntegrityDataUnitDto cylinderCheck = new CylinderIntegrityDataUnitDto();
cylinderCheck.setAppId(cylinderUnit.getAppId());
cylinderCheck.setDataType("充装后复查");
Double checkIntegirty = cylinderFillingCheckServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderCheck.setIntegrity(checkIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderCheck);
});
}
/**
* 充装详情按单位统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void synUnitFillingCheckData() {
cylinderFillingCheckDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingCheckDataUnit>());
countByUnit(cylinderUnit -> {
// 按照月份 获取数据 取一年数据
Calendar c = Calendar.getInstance();
// 按月份获取充装量
// 当月与上月 对比获取数据
for (int i = 0; i < 12; i++) {
// 获取当月数据
CylinderFillingCheckDataUnitDto temp = new CylinderFillingCheckDataUnitDto();
String year = c.get(Calendar.YEAR) + "";
int month = c.get(Calendar.MONTH) + 1;
String monthStr = month < 10 ? "0" + month : month + "";
temp.setFillingMonth(monthStr);
temp.setFillingYear(year);
temp.setFillingDate(year + "-" + monthStr);
Integer countThisMonth = cylinderFillingRecordServiceImpl.getFillingCountByMonth(cylinderUnit.getAppId(), c.getTime());
temp.setTotalSum((long) countThisMonth);
// 获取本月数据
Integer fillingCount = cylinderFillingServiceImpl.getFillingCountByMonth(cylinderUnit.getAppId(), c.getTime());
Integer fillingCheckCount = cylinderFillingCheckServiceImpl.getFillingCountByMonth(cylinderUnit.getAppId(), c.getTime());
// 充装前检查率:充装前检查次数/充装次数
double before = 0d;
if (countThisMonth != 0) {
before = (double) (fillingCount) / (double) countThisMonth;
}
temp.setFillingCount((long) fillingCount);
temp.setFillingPercent(before * 100);
// 充装后检查率:充装后检查次数/充装次数
double after = 0d;
if (countThisMonth != 0) {
after = (double) (fillingCheckCount) / (double) countThisMonth;
}
temp.setFillingCheckCount((long) fillingCheckCount);
temp.setFillingCheckPercent(after * 100);
// 充装合格率:充装前检查合格次数+充装后检查合格次数/2*充装次数
double passed = 0d;
// 充装前检查合格次数
Integer fillingPassedCount = cylinderFillingServiceImpl.getFillingPassedCountByMonth(cylinderUnit.getAppId(), c.getTime());
// 充装后检查合格次数
Integer fillingCheckPassedCount = cylinderFillingCheckServiceImpl.getFillingPassedCountByMonth(cylinderUnit.getAppId(), c.getTime());
if (countThisMonth != 0) {
passed = ((double) (fillingPassedCount) + (double) fillingCheckPassedCount) / (double) (2 * countThisMonth);
}
temp.setFillingPassedCount((long) (fillingPassedCount + fillingCheckPassedCount));
temp.setTotalSumDouble((long) 2 * countThisMonth);
temp.setFillingPassedPercent(passed * 100);
temp.setAppId(cylinderUnit.getAppId());
c.add(Calendar.MONTH, -1);
cylinderFillingCheckDataUnitServiceImpl.createWithModel(temp);
}
});
}
/**
* 充装量、卸液量按单位统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void synFillingUnloadUnitData() {
cylinderFillingUnloadDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingUnloadDataUnit>());
countByUnit(cylinderUnit -> {
Calendar now = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
for (int i = 0; i < 30; i++) {
now.add(Calendar.DATE, -1);
CylinderFillingUnloadDataUnitDto temp = new CylinderFillingUnloadDataUnitDto();
Double fillingSum = cylinderFillingRecordServiceImpl.getFillingSumByDate(cylinderUnit.getAppId(), now.getTime());
Double unloadSum = 0d;
temp.setFillingSum(fillingSum);
temp.setAppId(cylinderUnit.getAppId());
temp.setStatisDate(now.getTime());
temp.setStatisDateStr(sdf.format(now.getTime()));
temp.setUnloadSum(unloadSum);
cylinderFillingUnloadDataUnitServiceImpl.createWithModel(temp);
}
});
}
/**
* 根据月份统计
*/
private void countByMonth(IntConsumer consumer) {
for (int i = 0; i < 12; i++) {
consumer.accept(i);
}
}
/**
* 根据单位统计
*/
private void countByUnit(Consumer<CylinderUnit> consumer) {
List<CylinderUnit> units = cylinderUnitServiceImpl.list();
units.forEach(consumer);
}
/**
* 根据区域统计
*/
private void countByRegion(Consumer<RegionModel> consumer) {
List<RegionModel> regionList = new ArrayList<>();
startPlatformTokenService.getToken();
Collection<RegionModel> regions = Systemctl.regionClient.queryForTree(null).getResult();
regions.forEach(regionModel -> convertTreeToList(regionList, regionModel));
regionList.forEach(consumer);
}
/**
* 将区域树转为区域List列表
*/
private void convertTreeToList(List<RegionModel> regionList, RegionModel region) {
regionList.add(region);
if (region.getChildren() != null) {
region.getChildren().forEach(c -> {
convertTreeToList(regionList, c);
});
}
}
public Integer getOverDateStatisticsNumber(String earlyWarningLevel) {
return this.baseMapper.countOverDateNumber(earlyWarningLevel);
}
public Page<CylinderInfoDto> earlyWarningLevelPageList(Page<CylinderInfoDto> page, String earlyWarningLevel) {
Page<CylinderInfoDto> result = this.baseMapper.queryPageListByEarlyWarningLevel(page, earlyWarningLevel);
result.getRecords().forEach(r -> {
@Autowired
CylinderFillingUnloadDataServiceImpl cylinderFillingUnloadDataServiceImpl;
@Autowired
CylinderInfoDataUnitServiceImpl cylinderInfoDataUnitServiceImpl;
@Autowired
CylinderFillingDataUnitServiceImpl cylinderFillingDataUnitServiceImpl;
@Autowired
CylinderTagsDataUnitServiceImpl cylinderTagsDataUnitServiceImpl;
@Autowired
CylinderIntegrityDataUnitServiceImpl cylinderIntegrityDataUnitServiceImpl;
@Autowired
CylinderFillingCheckDataUnitServiceImpl cylinderFillingCheckDataUnitServiceImpl;
@Autowired
CylinderFillingUnloadDataUnitServiceImpl cylinderFillingUnloadDataUnitServiceImpl;
@Autowired
MsgLogServiceImpl msgLogService;
@Autowired
private RuleTrigger ruleTrigger;
@Autowired
TzsAuthServiceImpl tzsAuthService;
@Autowired
private ScheduleMapper scheduleMapper;
@Value("${cylinder-early-warning-packageId:气瓶监管/cylwarningmsg}")
private String packageId;
@Value("${cylinder-early-warning-packageId:气瓶消息预警/cylwarningmsg}")
private String cylPackageId;
@Autowired
StartPlatformTokenService startPlatformTokenService;
/**
* 分页查询
*/
public Page<CylinderInfoDto> queryForCylinderInfoPage(Page<CylinderInfoDto> page) {
return queryForPage(page, null, false);
}
/**
* 列表查询 示例
*/
public List<CylinderInfoDto> queryForCylinderInfoList() {
return queryForList("", false);
}
@Override
public Map<String, String> queryNumAndOutOfDateNum(Long unitId) {
return baseMapper.queryNumAndOutOfDateNum(unitId);
}
/**
* 获取上个月气瓶总量
*/
public Integer getMonthInfoTotal(String regionCode) {
return baseMapper.getMonthInfoTotal(regionCode);
}
/**
* 获取上个月气瓶总量
*/
public Integer getLastMonthInfoTotal(String regionCode) {
return baseMapper.getLastMonthInfoTotal(regionCode);
}
/**
* 获取上上个月气瓶总量
*/
public Integer getMonthBeforeLastInfoTotal(String regionCode) {
return baseMapper.getMonthBeforeLastInfoTotal(regionCode);
}
public Integer getInfoTotalByRegionCode(String regionCode) {
return baseMapper.getInfoTotalByRegionCode(regionCode);
}
public Double queryIntegirtyByAppId(String appId) {
return this.baseMapper.queryIntegirtyByAppId(appId);
}
public Integer getWarnNum(String code) {
return baseMapper.getWarnNum(code);
}
/**
* 按单位统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void synFillingUnloadData() {
cylinderFillingUnloadDataServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingUnloadData>());
countByRegion(regionModel -> {
Calendar now = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
for (int i = 0; i < 30; i++) {
now.add(Calendar.DATE, -1);
CylinderFillingUnloadDataDto temp = new CylinderFillingUnloadDataDto();
Double fillingSum = cylinderFillingRecordServiceImpl
.getFillingSum(String.valueOf(regionModel.getRegionCode()), now.getTime());
Double unloadSum = 0d;
temp.setFillingSum(fillingSum);
temp.setRegionCode(String.valueOf(regionModel.getRegionCode()));
temp.setStatisDate(now.getTime());
temp.setStatisDateStr(sdf.format(now.getTime()));
temp.setUnloadSum(unloadSum);
cylinderFillingUnloadDataServiceImpl.createWithModel(temp);
}
});
}
/**
* 按区域统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void synAreaData() {
cylinderAreaDataServiceImpl.remove(new LambdaQueryWrapper<CylinderAreaData>());
countByRegion(regionModel -> {
CylinderAreaDataDto temp = new CylinderAreaDataDto();
temp.setAreaName(regionModel.getRegionName());
String code = regionModel.getRegionCode() + "";
Integer cylinderTotal = this.getInfoTotalByRegionCode(code);
Integer cylinderUnitTotal = cylinderUnitServiceImpl.getUnitTotalByRegionCode(code);
Integer cylinderUnitWarn = cylinderUnitServiceImpl.getWarnNum(code);
Integer cylinderInfoWarn = this.getWarnNum(code);
int warmTotal = cylinderUnitWarn + cylinderInfoWarn;
String parentCode = "";
if ("610000".equals(code)) {
parentCode = "-1";
} else if (!"00".equals(code.substring(4, 6))) {
parentCode = code.substring(0, 4) + "00";
} else {
parentCode = "610000";
}
temp.setCylinderNum(Long.valueOf(cylinderTotal));
temp.setParentRegionCode(parentCode);
temp.setRegionCode(regionModel.getRegionCode() + "");
temp.setUnitNum(Long.valueOf(cylinderUnitTotal));
temp.setWarnNum((long) warmTotal);
cylinderAreaDataServiceImpl.createWithModel(temp);
});
}
/**
* 按区域统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "* * 2 * * ?")
public void addIntegrityData() {
System.out.println("====================数据完整性开始============================");
cylinderIntegrityDataServiceImpl.remove(new LambdaQueryWrapper<CylinderIntegrityData>());
countByRegion(regionModel -> {
List<CylinderUnit> unitlist = cylinderUnitServiceImpl.list(new LambdaQueryWrapper<CylinderUnit>()
.like(CylinderUnit::getRegionCode, regionModel.getRegionCode()));
List<CylinderIntegrityDataDto> tempList = new LinkedList<>();
System.out.println(
"====================regioncode: " + regionModel.getRegionCode() + "============================");
unitlist.forEach(t -> {
System.out.println("====================appId: " + t.getAppId() + "============================");
CylinderIntegrityDataDto temp = new CylinderIntegrityDataDto();
String appId = t.getAppId();
Double totalIntegirty = 0d;
// tz_cylinder_info
Double unitIntegirty = t.getIntegrity();
unitIntegirty = unitIntegirty == null ? 0d : unitIntegirty;
// tz_cylinder_tags
Double tagIntegirty = cylinderTagsServiceImpl.queryIntegirtyByAppId(appId);
tagIntegirty = tagIntegirty == null ? 0d : tagIntegirty;
// tz_cylinder_info
Double infoIntegirty = this.queryIntegirtyByAppId(appId);
infoIntegirty = infoIntegirty == null ? 0d : infoIntegirty;
// tz_cylinder_filling_record 30天内
Double recordIntegirty = cylinderFillingRecordServiceImpl.queryIntegirtyByAppId(appId);
recordIntegirty = recordIntegirty == null ? 0d : recordIntegirty;
// tz_cylinder_filling 30天内ji
Double fillingIntegirty = cylinderFillingServiceImpl.queryIntegirtyByAppId(appId);
fillingIntegirty = fillingIntegirty == null ? 0d : fillingIntegirty;
// tz_cylinder_filling_check 30天内
Double checkIntegirty = cylinderFillingCheckServiceImpl.queryIntegirtyByAppId(appId);
checkIntegirty = checkIntegirty == null ? 0d : checkIntegirty;
totalIntegirty = (unitIntegirty + tagIntegirty + infoIntegirty + recordIntegirty + fillingIntegirty
+ checkIntegirty) / 6;
BigDecimal bg = new BigDecimal(totalIntegirty);
totalIntegirty = bg.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue() * 100;
temp.setAppId(appId);
temp.setRegionCode(String.valueOf(regionModel.getRegionCode()));
temp.setIntegrity(totalIntegirty);
temp.setUnitName(t.getUnitName());
// 判断list 是否达到5个,如果达到则对比最后一个进行替换
if (tempList.size() == 5) {
if (tempList.get(0).getIntegrity() < totalIntegirty) {
tempList.set(0, temp);
}
} else {
tempList.add(temp);
}
tempList.sort(Comparator.comparing(CylinderIntegrityDataDto::getIntegrity));
});
tempList.forEach(t -> {
System.out.println("====================unitName: " + t.getUnitName() + "============================");
t.setUpdateTime(new Date());
cylinderIntegrityDataServiceImpl.createWithModel(t);
});
});
System.out.println("====================数据完整性结束============================");
}
/**
* 企业总量按区域统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void getCylinderUnitInfo() {
cylinderUnitDataServiceImpl.remove(new LambdaQueryWrapper<CylinderUnitData>());
countByRegion(regionModel -> {
String regionCode = String.valueOf(regionModel.getRegionCode());
Integer cylinderUnitTotal = cylinderUnitServiceImpl.getUnitTotalByRegionCode(regionCode);
Double lastUnitTotal = Double.valueOf(cylinderUnitServiceImpl.getLastMonthUnitTotal(regionCode));
Double monthUnitLastInfo = Double.valueOf(cylinderUnitServiceImpl.getMonthBeforeLastUnitTotal(regionCode));
double changeNum = cylinderUnitTotal - lastUnitTotal;
double percent = 0d;
if (monthUnitLastInfo != 0) {
percent = (lastUnitTotal-monthUnitLastInfo) / monthUnitLastInfo;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
} else {
percent = 0 ;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
CylinderUnitDataDto temp = new CylinderUnitDataDto();
temp.setChangeSum((long) changeNum);
temp.setChangePercent((int) (percent * 100) + "");
temp.setRegionCode(regionCode);
temp.setTotalSum((long) cylinderUnitTotal);
temp.setUpdateTime(new Date());
cylinderUnitDataServiceImpl.createWithModel(temp);
});
}
/**
* 气瓶总量按区域统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void getCylinderInfo() {
cylinderInfoDataServiceImpl.remove(new LambdaQueryWrapper<>());
countByRegion(regionModel -> {
CylinderInfoDataDto temp = new CylinderInfoDataDto();
String regionCode = String.valueOf(regionModel.getRegionCode());
Integer cylinderTotal = this.getInfoTotalByRegionCode(regionCode);// 当前总数
Double InfoTotal = Double.valueOf(this.getMonthInfoTotal(regionCode));
Double lastInfoTotal = Double.valueOf(this.getLastMonthInfoTotal(regionCode));// 上月总数
Double monthBeforeLastInfo = Double.valueOf(this.getMonthBeforeLastInfoTotal(regionCode));// 上上月总数
double percent = 0d;
if (monthBeforeLastInfo != 0) {
percent = (lastInfoTotal - monthBeforeLastInfo) / monthBeforeLastInfo;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}else
{
percent = 0;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
temp.setChangeSum((long) (InfoTotal - lastInfoTotal));
temp.setChangePercent((int) (percent * 100) + "");
temp.setRegionCode(regionCode);
temp.setTotalSum((long) cylinderTotal);
cylinderInfoDataServiceImpl.createWithModel(temp);
});
}
/**
* 按单位统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void synUnitCylinderInfoData() {
cylinderInfoDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderInfoDataUnit>());
countByUnit(cylinderUnit -> {
CylinderInfoDataUnitDto temp = new CylinderInfoDataUnitDto();
temp.setAppId(cylinderUnit.getAppId());
int count = this
.count(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getAppId, cylinderUnit.getAppId()));// 当前总数
temp.setTotalSum((long) count);
Double month = Double.valueOf(baseMapper.getMonthInfoTotalUnit(cylinderUnit.getAppId()));
Double thismonth = Double.valueOf(baseMapper.getLastMonthInfoTotalUnit(cylinderUnit.getAppId()));// 上月总数
Double lastmonth = Double.valueOf(baseMapper.getMonthBeforeLastInfoTotalUnit(cylinderUnit.getAppId()));// 上上月总数
double percent = 0d;
if (lastmonth != 0) {
percent = (thismonth - lastmonth) / lastmonth;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}else
{
percent = 0;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
temp.setChangeSum((long) (month - thismonth));
temp.setChangePercent((int) (percent * 100) + "");
cylinderInfoDataUnitServiceImpl.createWithModel(temp);
});
}
/**
* 充装量按单位和月统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void synUnitCylinderFillingData() {
cylinderFillingDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingDataUnit>());
countByUnit(cylinderUnit -> {
// 按照月份 获取数据 取一年数据
Calendar calendar = Calendar.getInstance();
// 按月份获取充装量
// 当月与上月 对比获取数据
for (int i = 0; i < 12; i++) {
// 获取当月数据
CylinderFillingDataUnitDto temp = new CylinderFillingDataUnitDto();
String year = calendar.get(Calendar.YEAR) + "";
int month = calendar.get(Calendar.MONTH) + 1;
String monthStr = month < 10 ? "0" + month : month + "";
temp.setFillingYear(year);
temp.setFillingMonth(monthStr);
// 本月
Double thisMonth = cylinderFillingRecordServiceImpl.getFillingSumByMonth(cylinderUnit.getAppId(),
calendar.getTime());
temp.setTotalSum(thisMonth);
calendar.add(Calendar.MONTH, -1);
// 上月
Double lastMonth = cylinderFillingRecordServiceImpl.getFillingSumByMonth(cylinderUnit.getAppId(),
calendar.getTime());
double percent = 0d;
if (lastMonth != 0) {
percent = (thisMonth - lastMonth) / lastMonth;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
temp.setChangePercent((int) (percent * 100) + "");
temp.setAppId(cylinderUnit.getAppId());
temp.setChangeSum(thisMonth - lastMonth);
cylinderFillingDataUnitServiceImpl.createWithModel(temp);
}
});
}
/**
* 按单位统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void synUnitCylinderTagsData() {
cylinderTagsDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderTagsDataUnit>());
countByUnit(cylinderUnit -> {
CylinderTagsDataUnitDto temp = new CylinderTagsDataUnitDto();
temp.setAppId(cylinderUnit.getAppId());
int cylinder = this
.count(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getAppId, cylinderUnit.getAppId()));
int tags = cylinderTagsServiceImpl
.count(new LambdaQueryWrapper<CylinderTags>().eq(CylinderTags::getAppId, cylinderUnit.getAppId()));
double percent = 0d;
if (tags != 0) {
percent = (double) cylinder / (double) tags;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
temp.setCylinderSum((long) cylinder);
temp.setTagsSum((long) tags);
temp.setTagPercent(percent * 100);
cylinderTagsDataUnitServiceImpl.createWithModel(temp);
});
}
/**
* 按单位统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void synUnitIntegrityData() {
cylinderIntegrityDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderIntegrityDataUnit>());
countByUnit(cylinderUnit -> {
// 企业信息
CylinderIntegrityDataUnitDto uninInfo = new CylinderIntegrityDataUnitDto();
uninInfo.setAppId(cylinderUnit.getAppId());
uninInfo.setDataType("企业信息");
Double unitIntegirty = cylinderUnit.getIntegrity();
uninInfo.setIntegrity(unitIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(uninInfo);
// 气瓶基本信息
CylinderIntegrityDataUnitDto cylinderInfo = new CylinderIntegrityDataUnitDto();
cylinderInfo.setAppId(cylinderUnit.getAppId());
cylinderInfo.setDataType("气瓶基本信息");
Double cylinderIntegirty = this.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderInfo.setIntegrity(cylinderIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderInfo);
// 气瓶标签信息
CylinderIntegrityDataUnitDto cylinderTag = new CylinderIntegrityDataUnitDto();
cylinderTag.setAppId(cylinderUnit.getAppId());
cylinderTag.setDataType("气瓶标签信息");
Double tagIntegirty = cylinderTagsServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderTag.setIntegrity(tagIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderTag);
// 气瓶检验信息
CylinderIntegrityDataUnitDto cylinderInspection = new CylinderIntegrityDataUnitDto();
cylinderInspection.setAppId(cylinderUnit.getAppId());
cylinderInspection.setDataType("气瓶检验信息");
cylinderInspection.setIntegrity(0d);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderInspection);
// 充装前检查
CylinderIntegrityDataUnitDto cylinderFilling = new CylinderIntegrityDataUnitDto();
cylinderFilling.setAppId(cylinderUnit.getAppId());
cylinderFilling.setDataType("充装前检查");
Double fillingIntegirty = cylinderFillingServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderFilling.setIntegrity(fillingIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderFilling);
// 充装信息
CylinderIntegrityDataUnitDto cylinderRecord = new CylinderIntegrityDataUnitDto();
cylinderRecord.setAppId(cylinderUnit.getAppId());
cylinderRecord.setDataType("充装信息");
Double recordIntegirty = cylinderFillingRecordServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderRecord.setIntegrity(recordIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderRecord);
// 充装后复查
CylinderIntegrityDataUnitDto cylinderCheck = new CylinderIntegrityDataUnitDto();
cylinderCheck.setAppId(cylinderUnit.getAppId());
cylinderCheck.setDataType("充装后复查");
Double checkIntegirty = cylinderFillingCheckServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderCheck.setIntegrity(checkIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderCheck);
});
}
/**
* 充装详情按单位统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void synUnitFillingCheckData() {
cylinderFillingCheckDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingCheckDataUnit>());
countByUnit(cylinderUnit -> {
// 按照月份 获取数据 取一年数据
Calendar c = Calendar.getInstance();
// 按月份获取充装量
// 当月与上月 对比获取数据
for (int i = 0; i < 12; i++) {
// 获取当月数据
CylinderFillingCheckDataUnitDto temp = new CylinderFillingCheckDataUnitDto();
String year = c.get(Calendar.YEAR) + "";
int month = c.get(Calendar.MONTH) + 1;
String monthStr = month < 10 ? "0" + month : month + "";
temp.setFillingMonth(monthStr);
temp.setFillingYear(year);
temp.setFillingDate(year + "-" + monthStr);
Integer countThisMonth = cylinderFillingRecordServiceImpl
.getFillingCountByMonth(cylinderUnit.getAppId(), c.getTime());
temp.setTotalSum((long) countThisMonth);
// 获取本月数据
Integer fillingCount = cylinderFillingServiceImpl.getFillingCountByMonth(cylinderUnit.getAppId(),
c.getTime());
Integer fillingCheckCount = cylinderFillingCheckServiceImpl
.getFillingCountByMonth(cylinderUnit.getAppId(), c.getTime());
// 充装前检查率:充装前检查次数/充装次数
double before = 0d;
if (countThisMonth != 0) {
before = (double) (fillingCount) / (double) countThisMonth;
}
temp.setFillingCount((long) fillingCount);
temp.setFillingPercent(before * 100);
// 充装后检查率:充装后检查次数/充装次数
double after = 0d;
if (countThisMonth != 0) {
after = (double) (fillingCheckCount) / (double) countThisMonth;
}
temp.setFillingCheckCount((long) fillingCheckCount);
temp.setFillingCheckPercent(after * 100);
// 充装合格率:充装前检查合格次数+充装后检查合格次数/2*充装次数
double passed = 0d;
// 充装前检查合格次数
Integer fillingPassedCount = cylinderFillingServiceImpl
.getFillingPassedCountByMonth(cylinderUnit.getAppId(), c.getTime());
// 充装后检查合格次数
Integer fillingCheckPassedCount = cylinderFillingCheckServiceImpl
.getFillingPassedCountByMonth(cylinderUnit.getAppId(), c.getTime());
if (countThisMonth != 0) {
passed = ((double) (fillingPassedCount) + (double) fillingCheckPassedCount)
/ (double) (2 * countThisMonth);
}
temp.setFillingPassedCount((long) (fillingPassedCount + fillingCheckPassedCount));
temp.setTotalSumDouble((long) 2 * countThisMonth);
temp.setFillingPassedPercent(passed * 100);
temp.setAppId(cylinderUnit.getAppId());
c.add(Calendar.MONTH, -1);
cylinderFillingCheckDataUnitServiceImpl.createWithModel(temp);
}
});
}
/**
* 充装量、卸液量按单位统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void synFillingUnloadUnitData() {
cylinderFillingUnloadDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingUnloadDataUnit>());
countByUnit(cylinderUnit -> {
Calendar now = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
for (int i = 0; i < 30; i++) {
now.add(Calendar.DATE, -1);
CylinderFillingUnloadDataUnitDto temp = new CylinderFillingUnloadDataUnitDto();
Double fillingSum = cylinderFillingRecordServiceImpl.getFillingSumByDate(cylinderUnit.getAppId(),
now.getTime());
Double unloadSum = 0d;
temp.setFillingSum(fillingSum);
temp.setAppId(cylinderUnit.getAppId());
temp.setStatisDate(now.getTime());
temp.setStatisDateStr(sdf.format(now.getTime()));
temp.setUnloadSum(unloadSum);
cylinderFillingUnloadDataUnitServiceImpl.createWithModel(temp);
}
});
}
/**
* 根据月份统计
*/
private void countByMonth(IntConsumer consumer) {
for (int i = 0; i < 12; i++) {
consumer.accept(i);
}
}
/**
* 根据单位统计
*/
private void countByUnit(Consumer<CylinderUnit> consumer) {
List<CylinderUnit> units = cylinderUnitServiceImpl.list();
units.forEach(consumer);
}
/**
* 根据区域统计
*/
private void countByRegion(Consumer<RegionModel> consumer) {
List<RegionModel> regionList = new ArrayList<>();
startPlatformTokenService.getToken();
Collection<RegionModel> regions = Systemctl.regionClient.queryForTree(null).getResult();
regions.forEach(regionModel -> convertTreeToList(regionList, regionModel));
regionList.forEach(consumer);
}
/**
* 将区域树转为区域List列表
*/
private void convertTreeToList(List<RegionModel> regionList, RegionModel region) {
regionList.add(region);
if (region.getChildren() != null) {
region.getChildren().forEach(c -> {
convertTreeToList(regionList, c);
});
}
}
public Integer getOverDateStatisticsNumber(String earlyWarningLevel) {
return this.baseMapper.countOverDateNumber(earlyWarningLevel);
}
public Page<CylinderInfoDto> earlyWarningLevelPageList(Page<CylinderInfoDto> page, String earlyWarningLevel) {
Page<CylinderInfoDto> result = this.baseMapper.queryPageListByEarlyWarningLevel(page, earlyWarningLevel);
result.getRecords().forEach(r -> {
// r.setEarlyWarningLevelName(EarlyWarningLevelEnum.getEumByLevel(earlyWarningLevel).getName());
// r.setInspectionStatusDesc(EarlyWarningLevelEnum.getEumByLevel(earlyWarningLevel).getStatus());
});
return result;
}
public void calEarlyWarningLevel() {
if (log.isDebugEnabled()) {
log.debug("气瓶超期预警时间调用规则开始");
}
// 1.批量分组大小
int size = 500;
int total = this.count();
int groupNumber = total / size + 1;
// 2.批量小分组处理数据,调用规则
for (int i = 0; i < groupNumber; i++) {
Page<CylinderInfo> page = new Page<>();
page.setCurrent(i);
page.setSize(size);
LambdaQueryWrapper<CylinderInfo> wrapper = new LambdaQueryWrapper<>();
wrapper.select(CylinderInfo::getSequenceCode,CylinderInfo::getSequenceNbr).orderByDesc(CylinderInfo::getSequenceNbr);
IPage<CylinderInfo> result = this.page(page, wrapper);
for (CylinderInfo r : result.getRecords()) {
// 设置token
tzsAuthService.setRequestContext();
// 调用规则
this.touchRuleToCalLevel(r);
}
}
if (log.isDebugEnabled()) {
log.debug("气瓶超期预警时间调用规则完成");
}
}
private void touchRuleToCalLevel(CylinderInfo r) {
Date now = new Date();
String dateStr;
try {
dateStr = DateUtils.dateFormat(now,DateUtils.DATE_TIME_PATTERN);
} catch (ParseException e) {
throw new RuntimeException("日期个时候失败");
}
//1.气瓶详情
CylinderInfoDto cylinderInfoDto = this.getDetail(r.getSequenceCode());
try {
WarningMsgDto warningMsgDto = new WarningMsgDto();
int interval = DateUtils.dateBetweenIncludeToday(now, cylinderInfoDto.getNextInspectionDate()) - 1;
warningMsgDto.setNum(String.valueOf(interval));
warningMsgDto.setFactoryNum(cylinderInfoDto.getFactoryNum());
});
return result;
}
public void calEarlyWarningLevel() {
if (log.isDebugEnabled()) {
log.debug("气瓶超期预警时间调用规则开始");
}
// 1.批量分组大小
int size = 500;
int total = this.count();
int groupNumber = total / size + 1;
// 2.批量小分组处理数据,调用规则
for (int i = 0; i < groupNumber; i++) {
Page<CylinderInfo> page = new Page<>();
page.setCurrent(i);
page.setSize(size);
LambdaQueryWrapper<CylinderInfo> wrapper = new LambdaQueryWrapper<>();
wrapper.select(CylinderInfo::getSequenceCode, CylinderInfo::getSequenceNbr)
.orderByDesc(CylinderInfo::getSequenceNbr);
IPage<CylinderInfo> result = this.page(page, wrapper);
for (CylinderInfo r : result.getRecords()) {
// 设置token
tzsAuthService.setRequestContext();
// 调用规则
this.touchRuleToCalLevel(r);
}
}
if (log.isDebugEnabled()) {
log.debug("气瓶超期预警时间调用规则完成");
}
}
private void touchRuleToCalLevel(CylinderInfo r) {
Date now = new Date();
String dateStr;
try {
dateStr = DateUtils.dateFormat(now, DateUtils.DATE_TIME_PATTERN);
} catch (ParseException e) {
throw new RuntimeException("日期个时候失败");
}
// 1.气瓶详情
CylinderInfoDto cylinderInfoDto = this.getDetail(r.getSequenceCode());
try {
WarningMsgDto warningMsgDto = new WarningMsgDto();
int interval = DateUtils.dateBetweenIncludeToday(now, cylinderInfoDto.getNextInspectionDate()) - 1;
warningMsgDto.setNum(String.valueOf(interval));
warningMsgDto.setFactoryNum(cylinderInfoDto.getFactoryNum());
// warningMsgDto.setUserType(cylinderInfoDto.getCustomType());
// warningMsgDto.setUserPeople(cylinderInfoDto.getCustomName());
// warningMsgDto.setUserPeoplePhone(cylinderInfoDto.getContactPhone());
warningMsgDto.setCode(cylinderInfoDto.getSequenceCode());
warningMsgDto.setCompanyName(cylinderInfoDto.getUnitName());
warningMsgDto.setPhone(cylinderInfoDto.getPersonMobilePhone());
warningMsgDto.setPeople(cylinderInfoDto.getUnitPerson());
warningMsgDto.setCurrentTime(dateStr);
// 2.循环调用规则 触发计算等级及发送消息
if (log.isInfoEnabled()) {
log.info("调用规则对象!+:{}", JSON.toJSONString(warningMsgDto));
}
ruleTrigger.publish(warningMsgDto, packageId, null);
} catch (Exception e) {
log.error("调用规则失败!:{},{}", JSON.toJSONString(cylinderInfoDto),e);
}
}
public CylinderInfoDto getDetail(String sequenceCode) {
CylinderInfoDto dto = scheduleMapper.getCylDetail(sequenceCode);
dto.setInspectionStatusDesc(StringUtils.isNotEmpty(dto.getEarlyWarningLevel()) ? EarlyWarningLevelEnum.getEumByLevel(dto.getEarlyWarningLevel()).getStatus() : "");
return dto;
}
public List<MsgLog> getMsgList(String sequenceCode, String terminalType) {
LambdaQueryWrapper<MsgLog> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(MsgLog::getRelationCode, sequenceCode);
wrapper.eq(StringUtils.isNotEmpty(terminalType), MsgLog::getTerminalType, terminalType);
wrapper.orderByDesc(MsgLog::getSendTime);
return msgLogService.list(wrapper);
}
/**
* 更新气瓶等级
* @param sequenceCode 唯一表设
* @param level 等级
* @return CylinderInfo
*/
public CylinderInfo updateEarlyWarningLevel(String sequenceCode, String level) {
CylinderInfo cylinderInfo = this.getOne(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getSequenceCode, sequenceCode));
cylinderInfo.setEarlyWarningLevel(level);
cylinderInfo.setEarlyWarningLevelCalDate(new Date());
this.updateById(cylinderInfo);
return cylinderInfo;
}
public Boolean nextInspectionDateUpdate(List<CylinderInfoDto> cylinderInfoDtos) {
// 1.更新下次检验日期
List<CylinderInfo> cylinderInfos = new ArrayList<>();
cylinderInfoDtos.forEach(c -> {
CylinderInfo cylinderInfo = this.getOne(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getSequenceCode, c.getSequenceCode()));
warningMsgDto.setCode(cylinderInfoDto.getSequenceCode());
warningMsgDto.setCompanyName(cylinderInfoDto.getUnitName());
warningMsgDto.setPhone(cylinderInfoDto.getPersonMobilePhone());
warningMsgDto.setPeople(cylinderInfoDto.getUnitPerson());
warningMsgDto.setCurrentTime(dateStr);
// 2.循环调用规则 触发计算等级及发送消息
if (log.isInfoEnabled()) {
log.info("调用规则对象!+:{}", JSON.toJSONString(warningMsgDto));
}
ruleTrigger.publish(warningMsgDto, packageId, null);
} catch (Exception e) {
log.error("调用规则失败!:{},{}", JSON.toJSONString(cylinderInfoDto), e);
}
}
public CylinderInfoDto getDetail(String sequenceCode) {
CylinderInfoDto dto = scheduleMapper.getCylDetail(sequenceCode);
dto.setInspectionStatusDesc(StringUtils.isNotEmpty(dto.getEarlyWarningLevel())
? EarlyWarningLevelEnum.getEumByLevel(dto.getEarlyWarningLevel()).getStatus()
: "");
return dto;
}
public List<MsgLog> getMsgList(String sequenceCode, String terminalType) {
LambdaQueryWrapper<MsgLog> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(MsgLog::getRelationCode, sequenceCode);
wrapper.eq(StringUtils.isNotEmpty(terminalType), MsgLog::getTerminalType, terminalType);
wrapper.orderByDesc(MsgLog::getSendTime);
return msgLogService.list(wrapper);
}
/**
* 更新气瓶等级
*
* @param sequenceCode 唯一表设
* @param level 等级
* @return CylinderInfo
*/
public CylinderInfo updateEarlyWarningLevel(String sequenceCode, String level) {
CylinderInfo cylinderInfo = this
.getOne(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getSequenceCode, sequenceCode));
cylinderInfo.setEarlyWarningLevel(level);
cylinderInfo.setEarlyWarningLevelCalDate(new Date());
this.updateById(cylinderInfo);
return cylinderInfo;
}
public Boolean nextInspectionDateUpdate(List<CylinderInfoDto> cylinderInfoDtos) {
// 1.更新下次检验日期
List<CylinderInfo> cylinderInfos = new ArrayList<>();
cylinderInfoDtos.forEach(c -> {
CylinderInfo cylinderInfo = this.getOne(
new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getSequenceCode, c.getSequenceCode()));
// cylinderInfo.setNextInspectionDate(c.getNextInspectionDate());
cylinderInfos.add(cylinderInfo);
});
if (!cylinderInfos.isEmpty()) {
this.updateBatchById(cylinderInfos);
}
// 2.循环调用规则 触发计算等级及发送消息
cylinderInfos.forEach(this::touchRuleToCalLevel);
return Boolean.TRUE;
}
cylinderInfos.add(cylinderInfo);
});
if (!cylinderInfos.isEmpty()) {
this.updateBatchById(cylinderInfos);
}
// 2.循环调用规则 触发计算等级及发送消息
cylinderInfos.forEach(this::touchRuleToCalLevel);
return Boolean.TRUE;
}
}
\ No newline at end of file
package com.yeejoin.amos.boot.module.tzs.flc.biz.service.impl;
import java.util.List;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.CylinderInspectionDto;
import com.yeejoin.amos.boot.module.tzs.flc.api.entity.CylinderInfo;
import com.yeejoin.amos.boot.module.tzs.flc.api.entity.CylinderInspection;
import com.yeejoin.amos.boot.module.tzs.flc.api.mapper.CylinderInspectionMapper;
import com.yeejoin.amos.boot.module.tzs.flc.api.service.ICylinderInspectionService;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.CylinderInspectionDto;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;
/**
* 气瓶检验信息服务实现类
......@@ -16,18 +19,27 @@ import java.util.List;
* @date 2022-03-04
*/
@Service
public class CylinderInspectionServiceImpl extends BaseService<CylinderInspectionDto, CylinderInspection,CylinderInspectionMapper> implements ICylinderInspectionService {
/**
* 分页查询
*/
public Page<CylinderInspectionDto> queryForCylinderInspectionPage(Page<CylinderInspectionDto> page) {
return this.queryForPage(page, null, false);
}
public class CylinderInspectionServiceImpl
extends BaseService<CylinderInspectionDto, CylinderInspection, CylinderInspectionMapper>
implements ICylinderInspectionService {
/**
* 分页查询
*/
public Page<CylinderInspectionDto> queryForCylinderInspectionPage(Page<CylinderInspectionDto> page) {
return this.queryForPage(page, null, false);
}
/**
* 列表查询 示例
*/
public List<CylinderInspectionDto> queryForCylinderInspectionList() {
return this.queryForList("", false);
}
/**
* 列表查询 示例
*/
public List<CylinderInspectionDto> queryForCylinderInspectionList() {
return this.queryForList("" , false);
}
/**
* 列表查询 示例
*/
public Page<CylinderInfo> queryOutOfDateCylinder(Page<CylinderInfo> pageBean,String appId) {
return this.baseMapper.queryOutOfDateCylinder(pageBean,appId);
}
}
\ No newline at end of file
......@@ -61,4 +61,9 @@ public class CylinderUnitServiceImpl extends BaseService<CylinderUnitDto, Cylind
// return baseMapper.getWarnNum(code);
return 0;
}
public int getWarnNumByAppId(String appId)
{
return baseMapper.getWarnNumByAppId(appId);
}
}
\ No newline at end of file
package com.yeejoin.amos.boot.module.tzs.flc.biz.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.entity.DataDictionary;
import com.yeejoin.amos.boot.biz.common.service.impl.DataDictionaryServiceImpl;
import com.yeejoin.amos.boot.module.tzs.api.entity.PageParam;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.*;
import com.yeejoin.amos.boot.module.tzs.flc.api.entity.CylinderInfo;
......@@ -25,75 +28,97 @@ import java.util.Map;
* @date 2022-08-11
*/
@Service
public class TzCylinderServiceImpl extends BaseService<TzCylinderInfoDto, CylinderInfo, TzCylinderMapper> implements ITzCylinderService {
public class TzCylinderServiceImpl extends BaseService<TzCylinderInfoDto, CylinderInfo, TzCylinderMapper>
implements ITzCylinderService {
@Autowired
private TzCylinderMapper tzCylinderMapper;
@Autowired
private TzCylinderMapper tzCylinderMapper;
@Override
public IPage<TzCylinderInfoDto> getCylinderInfoDtoList(PageParam pageParam, TzCylinderInfoDto tzCylinderInfoDto, String key) {
Page<TzCylinderInfoDto> page = new Page<>(pageParam.getCurrent(), pageParam.getSize());
System.out.println("key有值:"+key);
String superviseOrgCode = Privilege.companyClient.seleteOne(Long.valueOf(key)).getResult().getOrgCode();
return tzCylinderMapper.getTzCylinderInfoList(page, tzCylinderInfoDto, superviseOrgCode);
@Autowired
DataDictionaryServiceImpl iDataDictionaryService;
}
@Override
public IPage<TzCylinderInfoDto> getCylinderInfoDtoList(PageParam pageParam, TzCylinderInfoDto tzCylinderInfoDto,
String key) {
Page<TzCylinderInfoDto> page = new Page<>(pageParam.getCurrent(), pageParam.getSize());
System.out.println("key有值:" + key);
String superviseOrgCode = Privilege.companyClient.seleteOne(Long.valueOf(key)).getResult().getOrgCode();
return tzCylinderMapper.getTzCylinderInfoList(page, tzCylinderInfoDto, superviseOrgCode);
@Override
public TzCylinderTraceDto getCylinderTraceDto(String sequenceNbr) {
String orgCode = tzCylinderMapper.getSequencCode(sequenceNbr);
TzCylinderProduceDto tzCylinderProduceDto = tzCylinderMapper.getTzCylinderProduceDto(orgCode);
TzCylinderInfoDto tzCylinderInfoDto = tzCylinderMapper.getTzCylinderInfoDto(sequenceNbr);
TzCylinderTagsDto tzCylinderTagsDto = tzCylinderMapper.getTzCylinderTagsDto(orgCode);
List<TzCylinderInspectionDto> tzCylinderInspectionDtoList = tzCylinderMapper.getTzCylinderInspectionDto(orgCode);
List<TzCylinderFillingDto> tzCylinderFillingDtoList = tzCylinderMapper.getTzCylinderFillingDto(orgCode);
}
@Override
public TzCylinderTraceDto getCylinderTraceDto(String sequenceNbr) {
String orgCode = tzCylinderMapper.getSequencCode(sequenceNbr);
TzCylinderProduceDto tzCylinderProduceDto = tzCylinderMapper.getTzCylinderProduceDto(orgCode);
TzCylinderInfoDto tzCylinderInfoDto = tzCylinderMapper.getTzCylinderInfoDto(sequenceNbr);
DataDictionary data1 = iDataDictionaryService.getOne(new LambdaQueryWrapper<DataDictionary>()
.eq(DataDictionary::getSequenceNbr, tzCylinderInfoDto.getCylinderVariety()));
tzCylinderInfoDto.setCylinderVariety(data1 != null ? data1.getName() : null);
DataDictionary data2 = iDataDictionaryService.getOne(new LambdaQueryWrapper<DataDictionary>()
.eq(DataDictionary::getCode, tzCylinderInfoDto.getFillingMedia())
.eq(DataDictionary::getType, "mediumType"));
tzCylinderInfoDto.setFillingMedia(data2 != null ? data2.getName() : null);
DataDictionary data3 = iDataDictionaryService.getOne(new LambdaQueryWrapper<DataDictionary>()
.eq(DataDictionary::getSequenceNbr, tzCylinderInfoDto.getCylinderStatus()));
tzCylinderInfoDto.setCylinderStatus(data3 != null ? data3.getName() : null);
TzCylinderTagsDto tzCylinderTagsDto = tzCylinderMapper.getTzCylinderTagsDto(orgCode);
List<TzCylinderInspectionDto> tzCylinderInspectionDtoList = tzCylinderMapper
.getTzCylinderInspectionDto(orgCode);
List<TzCylinderFillingDto> tzCylinderFillingDtoList = tzCylinderMapper.getTzCylinderFillingDto(orgCode);
/**
* 取气瓶追溯详情 充装前检查项 名称和结果列表
*/
List<TzCylinderCheckDto> tzCylinderCheckDtoList = tzCylinderMapper.getTzCylinderCheckItem();
Map<String,String> map = new HashMap<>();
for(TzCylinderCheckDto tzCylinderCheckDto : tzCylinderCheckDtoList){
map.put(tzCylinderCheckDto.getItem(), tzCylinderCheckDto.getExplain());
}
for(TzCylinderFillingDto tzCylinderFillingDto : tzCylinderFillingDtoList){
List<TzCylinderCheckDto> tzCylinderCheckDtoListResult = new ArrayList<>();
TzCylinderBeforeCheckDto tzcylinderBeforeCheckDto = tzCylinderMapper.getTzCylinderBeforeCheck(tzCylinderFillingDto.getFillingBeforeId());
JSONObject obj = JSONObject.parseObject(JSONObject.toJSONString(tzcylinderBeforeCheckDto));
for( String str : obj.keySet())
{
String explain = map.get(str);
String value = String.valueOf(obj.get(str)) ;
TzCylinderCheckDto tzcylinderCheckDto = new TzCylinderCheckDto(str,explain,value);
tzCylinderCheckDtoListResult.add(tzcylinderCheckDto);
}
tzCylinderFillingDto.setTzCylinderCheckDtoList(tzCylinderCheckDtoListResult);
}
/**
* 取气瓶追溯详情 充装前检查项 名称和结果列表
*/
List<TzCylinderCheckDto> tzCylinderCheckDtoList = tzCylinderMapper.getTzCylinderCheckItem();
Map<String, String> map = new HashMap<>();
for (TzCylinderCheckDto tzCylinderCheckDto : tzCylinderCheckDtoList) {
map.put(tzCylinderCheckDto.getItem(), tzCylinderCheckDto.getExplain());
}
/**
* 取气瓶追溯详情 充装后检查项 名称和结果列表
*/
List<TzCylinderCheckDto> tzCylinderAfterCheckDtoList = tzCylinderMapper.getTzCylinderAfterCheckItem();
Map<String,String> afterMap = new HashMap<>();
for(TzCylinderCheckDto tzCylinderCheckDto : tzCylinderAfterCheckDtoList){
afterMap.put(tzCylinderCheckDto.getItem(), tzCylinderCheckDto.getExplain());
}
for(TzCylinderFillingDto tzCylinderFillingDto : tzCylinderFillingDtoList){
List<TzCylinderCheckDto> tzCylinderAfterCheckDtoListResult = new ArrayList<>();
TzCylinderAfterCheckDto tzcylinderAfterCheckDto = tzCylinderMapper.getTzCylinderAfterCheck(tzCylinderFillingDto.getFillingCheckId());
JSONObject obj = JSONObject.parseObject(JSONObject.toJSONString(tzcylinderAfterCheckDto));
for( String str : obj.keySet())
{
String explain = afterMap.get(str);
String value = String.valueOf(obj.get(str)) ;
TzCylinderCheckDto tzcylinderCheckDto = new TzCylinderCheckDto(str,explain,value);
tzCylinderAfterCheckDtoListResult.add(tzcylinderCheckDto);
}
tzCylinderFillingDto.setTzCylinderAfterCheckDtoList(tzCylinderAfterCheckDtoListResult);
}
for (TzCylinderFillingDto tzCylinderFillingDto : tzCylinderFillingDtoList) {
List<TzCylinderCheckDto> tzCylinderCheckDtoListResult = new ArrayList<>();
TzCylinderBeforeCheckDto tzcylinderBeforeCheckDto = tzCylinderMapper
.getTzCylinderBeforeCheck(tzCylinderFillingDto.getFillingBeforeId());
JSONObject obj = JSONObject.parseObject(JSONObject.toJSONString(tzcylinderBeforeCheckDto));
for (String str : obj.keySet()) {
String explain = map.get(str);
String value = String.valueOf(obj.get(str));
DataDictionary data = iDataDictionaryService
.getOne(new LambdaQueryWrapper<DataDictionary>().eq(DataDictionary::getSequenceNbr, value));
TzCylinderCheckDto tzcylinderCheckDto = new TzCylinderCheckDto(str, explain,
data != null ? data.getCode() : null);
tzCylinderCheckDtoListResult.add(tzcylinderCheckDto);
}
tzCylinderFillingDto.setTzCylinderCheckDtoList(tzCylinderCheckDtoListResult);
}
/**
* 取气瓶追溯详情 充装后检查项 名称和结果列表
*/
List<TzCylinderCheckDto> tzCylinderAfterCheckDtoList = tzCylinderMapper.getTzCylinderAfterCheckItem();
Map<String, String> afterMap = new HashMap<>();
for (TzCylinderCheckDto tzCylinderCheckDto : tzCylinderAfterCheckDtoList) {
afterMap.put(tzCylinderCheckDto.getItem(), tzCylinderCheckDto.getExplain());
}
for (TzCylinderFillingDto tzCylinderFillingDto : tzCylinderFillingDtoList) {
List<TzCylinderCheckDto> tzCylinderAfterCheckDtoListResult = new ArrayList<>();
TzCylinderAfterCheckDto tzcylinderAfterCheckDto = tzCylinderMapper
.getTzCylinderAfterCheck(tzCylinderFillingDto.getFillingCheckId());
JSONObject obj = JSONObject.parseObject(JSONObject.toJSONString(tzcylinderAfterCheckDto));
for (String str : obj.keySet()) {
String explain = afterMap.get(str);
String value = String.valueOf(obj.get(str));
DataDictionary data = iDataDictionaryService
.getOne(new LambdaQueryWrapper<DataDictionary>().eq(DataDictionary::getSequenceNbr, value));
TzCylinderCheckDto tzcylinderCheckDto = new TzCylinderCheckDto(str, explain,
data != null ? data.getCode() : null);
tzCylinderAfterCheckDtoListResult.add(tzcylinderCheckDto);
}
tzCylinderFillingDto.setTzCylinderAfterCheckDtoList(tzCylinderAfterCheckDtoListResult);
}
return new TzCylinderTraceDto(tzCylinderProduceDto,tzCylinderInfoDto,tzCylinderTagsDto,tzCylinderInspectionDtoList,tzCylinderFillingDtoList);
}
return new TzCylinderTraceDto(tzCylinderProduceDto, tzCylinderInfoDto, tzCylinderTagsDto,
tzCylinderInspectionDtoList, tzCylinderFillingDtoList);
}
}
#DB properties:
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://172.16.10.90:53306/tzs_amos_tzs_biz?allowMultiQueries=true&serverTimezone=GMT%2B8\
&characterEncoding=utf8
spring.datasource.url=jdbc:mysql://36.46.151.113:23306/per_tzs_amos_tzs_biz?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8
spring.datasource.username=root
spring.datasource.password=Yeejoin@2020
##eureka properties:
eureka.client.service-url.defaultZone =http://172.16.3.99:10001/eureka/
eureka.instance.prefer-ip-address=true
management.endpoint.health.show-details=always
management.endpoints.web.exposure.include=*
eureka.instance.health-check-url=http://172.16.10.90:${server.port}${server.servlet.context-path}/actuator/health
eureka.instance.metadata-map.management.context-path=${server.servlet.context-path}/actuator
eureka.instance.status-page-url=http://172.16.10.90:${server.port}${server.servlet.context-path}/actuator/info
eureka.instance.metadata-map.management.api-docs=http://172.16.10.90:${server.port}${server.servlet.context-path}/swagger-ui.html
#eureka properties:
eureka.instance.hostname= eureka
eureka.instance.prefer-ip-address = true
eureka.client.serviceUrl.defaultZone =http://36.46.151.113:10001/eureka/
eureka.instance.ip-address = 172.16.3.133
## ES properties:
biz.elasticsearch.address=172.16.10.90
spring.data.elasticsearch.cluster-name=elasticsearch
biz.elasticsearch.address=36.46.151.113
spring.data.elasticsearch.cluster-name=docker-cluster
spring.data.elasticsearch.cluster-nodes=${biz.elasticsearch.address}:9300
spring.elasticsearch.rest.uris=http://${biz.elasticsearch.address}:9200
elasticsearch.username= elastic
elasticsearch.password= 123456
elasticsearch.username=elastic
elasticsearch.password=123456
## unit(h)
alertcall.es.synchrony.time=48
fileserver.domain=https://rpm.yeeamos.com:8888/
#redis properties:
spring.redis.database=1
spring.redis.host=172.16.10.90
spring.redis.port=6379
spring.redis.host=36.46.151.113
spring.redis.port=16379
spring.redis.password=yeejoin@2020
spring.redis.lettuce.pool.max-active=200
spring.redis.lettuce.pool.max-wait=-1
......@@ -40,20 +35,67 @@ spring.redis.lettuce.pool.min-idle=0
spring.redis.expire.time=300
## emqx properties:
emqx.clean-session=true
emqx.clean-session=false
emqx.client-id=${spring.application.name}-${random.int[1024,65536]}
emqx.broker=tcp://172.16.10.90:1883
emqx.user-name=admin
emqx.password=public
emqx.broker=tcp://36.46.151.113:1883
emqx.user-name=super
emqx.password=123456
emqx.keepAliveInterval=1000
tzs.cti.appkey=4e805006-3fef-ae43-3915-a153731007c4
tzs.cti.secretkey=7bd29115-99ee-4f7d-1fb1-7c4719d5f43a
tzs.cti.url=http://36.46.151.113:8000
##wechatToken
tzs.wechat.token=yeejoin_2021
##wechatTicketUrl
tzs.wechat.ticketurl=https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=
#tzs.wechat.tempId.kr=rjW8x9rRitIpa21Jekyx2nzBzpJy7tycssCXSN4YhWw
tzs.wechat.tempId.kr=bxchKYhYW7aHbGKM2pVyR_yY2-bG4sRMNU3ZRQbMKYM
tzs.wechat.url.kr=tzs.yeeamos.com/persondetail.html
#tzs.wechat.tempId.wx=ofBIZS8Bup9s0zKbrGa8BfhVhS18H_hyC_OYXuBN6hI
tzs.wechat.tempId.wx=rags-expfNSBB-h2WenuBI2c6pCEndH4uwTtOqlHqDM
tzs.wechat.url.wx=tzs.yeeamos.com/repairPersondetail.html
#tzs.wechat.tempId.ts=Kr7lcV8g4g_lgyW_RpwnNgw_HDxxRuVx759EoFWrIfU
tzs.wechat.tempId.ts=VWqgY-lXFt4dg2EL4pLjfDCBAU49Z0mRxVaQhAMMW8Q
tzs.wechat.url.ts=tzs.yeeamos.com/taskComplaintDetail.html
mqtt.topic.task.newtask=tzs-task-newtask
mqtt.topic.task.personinfo=tzs-task-personinfo
mqtt.topic.elevator.push=/tzs/tcb_elevator
mqtt.topic.alertInfo.push=/tzs/tcb_alertInfo
mqtt.topic.alertReport.push=/tzs/tcb_alertReport
tzs.cti.url=http://113.134.211.174:8000
mqtt.topic.alertHeart.push=/tzs/tcb_alertHeart
rule.definition.load=false
rule.definition.model-package=com.yeejoin.amos.boot.module.tzs.api.dto
rule.definition.default-agency=tzs
#rule.definition.localIp=172.16.3.34
mqtt.topic.alertMatrix.push=/tzs/tcb_alertMatrix
mqtt.topic.cti.push=/cti/record
cti.user.name=tzs_cti
cti.user.pwd=a1234567
flc.sms.tempCode=SMS_TZS_0001
## \u9884\u8B66\u901A\u77E5\u6A21\u677Fid
tzs.wechat.tempId.warning=-pHsHLIjW8j-_AemoZycf6Dmu6iYc-YWWaJ0cAPGeUY
##\u7763\u67E5\u6574\u6539\u901A\u77E5
tzs.wechat.tempId.supervise=P5XGbszS2Pc6kynvGjzPpZ--ikAwDZo6O7WdJ2EUxtE
## \u516C\u4F17\u53F7\u6D4B\u8BD5\u7528\u6237id\uFF08\u5E73\u53F0userId\uFF09
tzs.wechat.test.userId=3413513
fileserver.domain=https://rpm.yeeamos.com:8888/
org.filter.group.seq=1564150103147573249
elasticsearch.username= elastic
elasticsearch.password= Yeejoin@2020
\ No newline at end of file
duty.seats.role.ids=1585956200472674305,1585956257590706177
spring.application.name=TZS
spring.application.name=TZS-wj
server.servlet.context-path=/tzs
server.port=11000
spring.profiles.active=dev
spring.profiles.active=dev2
spring.jackson.time-zone=GMT+8
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
......
......@@ -43,7 +43,7 @@
<logger name="org.apache.activemq" level="INFO"/>
<logger name="org.typroject" level="INFO"/>
<logger name="com.yeejoin" level="INFO"/>
<logger name="org.apache.http" level="ERROR"/>
<!-- 日志输出级别 -->
<root level="DEBUG">
<!-- <appender-ref ref="FILE" /> -->
......
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