Commit e7760205 authored by lisong's avatar lisong

气瓶大屏统计优化

parent 9942e54d
...@@ -91,4 +91,11 @@ public interface CylinderInfoMapper extends BaseMapper<CylinderInfo> { ...@@ -91,4 +91,11 @@ public interface CylinderInfoMapper extends BaseMapper<CylinderInfo> {
void updateEsCylinderInfoStatus(@Param("ids")List<String> ids); void updateEsCylinderInfoStatus(@Param("ids")List<String> ids);
Integer saveOrUpdateBatch(@Param("list") List<CylinderInfo> list); Integer saveOrUpdateBatch(@Param("list") List<CylinderInfo> list);
Page<Map<String,Object>> timeOutList(@Param("page") Page<Map<String, Object>> page, @Param("companyId") String companyId, @Param("regionCode") String regionCode);
Page<Map<String,Object>> licenceList(@Param("page") Page<Map<String, Object>> page, @Param("companyId") String companyId);
int countNumber(@Param("status") String status, @Param("companyId") String companyId, @Param("regionCode") String regionCode);
} }
...@@ -310,7 +310,8 @@ ...@@ -310,7 +310,8 @@
d3.name AS cylinder_status_str, d3.name AS cylinder_status_str,
ct.qrCode, ct.qrCode,
ct.electronic_label_code, ct.electronic_label_code,
cu.region_code cu.region_code,
(SELECT date_format(inspection_date,'%Y-%m-%d %h:%m:%s') from tz_cylinder_filling where sequence_code = ci.sequence_code and app_id = cu.app_id ORDER BY inspection_date desc limit 1) as inspectionDate
FROM FROM
tz_cylinder_info AS ci tz_cylinder_info AS ci
LEFT JOIN cb_data_dictionary AS d1 ON d1.type = 'CZJZMC' AND d1.code = ci.filling_media LEFT JOIN cb_data_dictionary AS d1 ON d1.type = 'CZJZMC' AND d1.code = ci.filling_media
...@@ -335,6 +336,93 @@ ...@@ -335,6 +336,93 @@
where ci.is_not_es IS NULL where ci.is_not_es IS NULL
AND region_code is not null AND region_code is not null
</select> </select>
<select id="timeOutList" resultType="java.util.Map">
SELECT DISTINCT(onlyCode),sequence_code,status,expire_day,unit_name
FROM(
SELECT
concat(insp.app_id,insp.sequence_code) as onlyCode,
insp.sequence_code,
unit.unit_name ,
CASE
WHEN ( now() > ( to_date(( insp.next_inspection_date ), 'yyyy-mm-dd' )) ) THEN
'已超期'
WHEN ((
to_days (( to_date(( insp.next_inspection_date ) , 'yyyy-mm-dd' )) ) - to_days (
now())) &lt;= 30
) THEN
'即将超期'
END AS status,
concat ((
to_days (( to_date(( insp.next_inspection_date ) :: TEXT, 'yyyy-mm-dd' :: TEXT )) ) - to_days (
now())),
'天'
) AS expire_day
FROM
tz_cylinder_inspection insp
LEFT JOIN tz_cylinder_unit unit ON insp.app_id = unit.app_id
WHERE
to_date( insp.next_inspection_date, 'yyyy-mm-dd' ) &lt; now()
OR (( to_days ( to_date(( insp.next_inspection_date ), 'yyyy-mm-dd' ) ) - to_days ( now())) &lt;= 30 )
<if test="companyId != null and companyId != ''">
and unit.app_id = #{companyId}
</if>
<if test="regionCode != null and regionCode != ''">
and unit.region_code like concat('%',#{regionCode},'%')
</if>
)
</select>
<select id="licenceList" resultType="java.util.Map">
SELECT status,
filling_perm_scope,
filling_permit_date,
unit_name
FROM view_licence_unit_table
<where>
<if test="companyId != null and companyId != ''">
app_id = #{companyId}
</if>
</where>
</select>
<select id="countNumber" resultType="java.lang.Integer">
SELECT count(DISTINCT(onlyCode))
FROM(
SELECT
concat(insp.app_id,insp.sequence_code) as onlyCode,
insp.sequence_code,
unit.unit_name ,
CASE
WHEN ( now() > ( to_date(( insp.next_inspection_date ), 'yyyy-mm-dd' )) ) THEN
'已超期'
WHEN ((
to_days (( to_date(( insp.next_inspection_date ) , 'yyyy-mm-dd' )) ) - to_days (
now())) &lt;= 30
) THEN
'即将超期'
END AS status,
concat ((
to_days (( to_date(( insp.next_inspection_date ) :: TEXT, 'yyyy-mm-dd' :: TEXT )) ) - to_days (
now())),
'天'
) AS expire_day
FROM
tz_cylinder_inspection insp
LEFT JOIN tz_cylinder_unit unit ON insp.app_id = unit.app_id
WHERE
to_date( insp.next_inspection_date, 'yyyy-mm-dd' ) &lt; now()
OR (( to_days ( to_date(( insp.next_inspection_date ), 'yyyy-mm-dd' ) ) - to_days ( now())) &lt;= 30 )
<if test="companyId != null and companyId != ''">
and unit.app_id = #{companyId}
</if>
)where status = #{status}
<if test="regionCode != null and regionCode != ''">
and unit.region_code like concat('%',#{regionCode},'%')
</if>
</select>
<update id="updateEsCylinderInfoStatus"> <update id="updateEsCylinderInfoStatus">
UPDATE tz_cylinder_info SET "is_not_es" = 1 WHERE "sequence_nbr" IN UPDATE tz_cylinder_info SET "is_not_es" = 1 WHERE "sequence_nbr" IN
......
...@@ -1200,4 +1200,133 @@ public class CylinderInfoController extends BaseController { ...@@ -1200,4 +1200,133 @@ public class CylinderInfoController extends BaseController {
return ResponseHelper.buildResponse(true); return ResponseHelper.buildResponse(true);
} }
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "超期列表")
@GetMapping(value = "/timeOutList")
public ResponseModel<Object> timeOutList(@RequestParam("number") Long number, @RequestParam("size") Long size, @RequestParam(value = "companyId", required = false) String companyId, @RequestParam(value = "regionCode", required = false) String regionCode) {
Page<Map<String, Object>> page = new Page<>(number, size);
HashMap<String, Object> map = new HashMap<>();
HashMap<String, Object> result = new HashMap<>();
Page<Map<String, Object>> mapPage = cylinderInfoServiceImpl.getBaseMapper().timeOutList(page, companyId, regionCode);
// 组装分页信息
map.put("current", page.getCurrent());
map.put("pageSize", page.getSize());
map.put("total", mapPage.getTotal());
map.put("pagination", false);
map.put("totalPage", mapPage.getPages());
map.put("dataList", mapPage.getRecords());
result.put("dataGridMock", map);
// 组装表头信息
ArrayList<Map<String, Object>> maps = new ArrayList<>();
HashMap<String, Object> status = new HashMap<>();
status.put("fid", "status");
status.put("dataIndex", "status");
status.put("name", "状态");
status.put("title", "状态");
status.put("type", "dataGrid");
status.put("key", "status");
maps.add(status);
// 检验有效期
HashMap<String, Object> expire_day = new HashMap<>();
expire_day.put("fid", "expire_day");
expire_day.put("dataIndex", "expire_day");
expire_day.put("name", "检验有效期");
expire_day.put("title", "检验有效期");
expire_day.put("type", "dataGrid");
expire_day.put("key", "expire_day");
maps.add(expire_day);
// 气瓶编码
HashMap<String, Object> sequence_code = new HashMap<>();
sequence_code.put("fid", "sequence_code");
sequence_code.put("dataIndex", "sequence_code");
sequence_code.put("name", "气瓶编码");
sequence_code.put("title", "气瓶编码");
sequence_code.put("type", "dataGrid");
sequence_code.put("key", "sequence_code");
maps.add(sequence_code);
// 产权单位
HashMap<String, Object> unit_name = new HashMap<>();
unit_name.put("fid", "unit_name");
unit_name.put("dataIndex", "unit_name");
unit_name.put("name", "产权单位");
unit_name.put("title", "产权单位");
unit_name.put("type", "dataGrid");
unit_name.put("key", "unit_name");
maps.add(unit_name);
result.put("colModel", maps);
return ResponseHelper.buildResponse(result);
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "许可列表")
@GetMapping(value = "/licenceList")
public ResponseModel<Object> licenceList(@RequestParam("number") Long number, @RequestParam("size") Long size, @RequestParam(value = "companyId", required = false) String companyId) {
Page<Map<String, Object>> page = new Page<>(number, size);
HashMap<String, Object> map = new HashMap<>();
HashMap<String, Object> result = new HashMap<>();
Page<Map<String, Object>> mapPage = cylinderInfoServiceImpl.getBaseMapper().licenceList(page, companyId);
// 组装分页信息
map.put("current", page.getCurrent());
map.put("pageSize", page.getSize());
map.put("total", mapPage.getTotal());
map.put("pagination", false);
map.put("totalPage", mapPage.getPages());
map.put("dataList", mapPage.getRecords());
result.put("dataGridMock", map);
// 组装表头信息
ArrayList<Map<String, Object>> maps = new ArrayList<>();
HashMap<String, Object> status = new HashMap<>();
status.put("fid", "status");
status.put("dataIndex", "status");
status.put("name", "状态");
status.put("title", "状态");
status.put("type", "dataGrid");
status.put("key", "status");
maps.add(status);
// 许可范围
HashMap<String, Object> filling_perm_scope = new HashMap<>();
filling_perm_scope.put("fid", "filling_perm_scope");
filling_perm_scope.put("dataIndex", "filling_perm_scope");
filling_perm_scope.put("name", "检验有效期");
filling_perm_scope.put("title", "检验有效期");
filling_perm_scope.put("type", "dataGrid");
filling_perm_scope.put("key", "expire_day");
maps.add(filling_perm_scope);
// 许可有效期
HashMap<String, Object> filling_permit_date = new HashMap<>();
filling_permit_date.put("fid", "filling_permit_date");
filling_permit_date.put("dataIndex", "filling_permit_date");
filling_permit_date.put("name", "许可范围");
filling_permit_date.put("title", "许可范围");
filling_permit_date.put("type", "dataGrid");
filling_permit_date.put("key", "sequence_code");
maps.add(filling_permit_date);
// 气瓶企业
HashMap<String, Object> unit_name = new HashMap<>();
unit_name.put("fid", "unit_name");
unit_name.put("dataIndex", "unit_name");
unit_name.put("name", "气瓶企业");
unit_name.put("title", "气瓶企业");
unit_name.put("type", "dataGrid");
unit_name.put("key", "unit_name");
maps.add(unit_name);
result.put("colModel", maps);
return ResponseHelper.buildResponse(result);
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "统计")
@GetMapping(value = "/countNumber")
public ResponseModel<Object> countNumber(@RequestParam("status") String status, @RequestParam(value = "companyId", required = false) String companyId, @RequestParam(value = "regionCode", required = false) String regionCode) {
HashMap<String, Object> map = new HashMap<>();
int number = cylinderInfoServiceImpl.getBaseMapper().countNumber(status, companyId, regionCode);
map.put("status", number);
return ResponseHelper.buildResponse(map);
}
} }
...@@ -48,7 +48,9 @@ import org.typroject.tyboot.core.rdbms.service.BaseService; ...@@ -48,7 +48,9 @@ import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.io.IOException; import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
...@@ -467,6 +469,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind ...@@ -467,6 +469,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
@Override @Override
public void synUnitCylinderFillingData() { public void synUnitCylinderFillingData() {
DecimalFormat df = new DecimalFormat("#0.00");
cylinderFillingDataUnitServiceImpl.remove(new LambdaQueryWrapper<>()); cylinderFillingDataUnitServiceImpl.remove(new LambdaQueryWrapper<>());
countByUnit(cylinderUnit -> { countByUnit(cylinderUnit -> {
// 按照月份 获取数据 取一年数据 // 按照月份 获取数据 取一年数据
...@@ -485,7 +488,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind ...@@ -485,7 +488,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
// 本月 // 本月
Double thisMonth = cylinderFillingRecordServiceImpl.getFillingSumByMonth(cylinderUnit.getAppId(), Double thisMonth = cylinderFillingRecordServiceImpl.getFillingSumByMonth(cylinderUnit.getAppId(),
calendar.getTime()); calendar.getTime());
temp.setTotalSum(thisMonth); temp.setTotalSum(Double.valueOf(df.format(thisMonth)));
calendar.add(Calendar.MONTH, -1); calendar.add(Calendar.MONTH, -1);
// 上月 // 上月
Double lastMonth = cylinderFillingRecordServiceImpl.getFillingSumByMonth(cylinderUnit.getAppId(), Double lastMonth = cylinderFillingRecordServiceImpl.getFillingSumByMonth(cylinderUnit.getAppId(),
...@@ -499,6 +502,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind ...@@ -499,6 +502,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
temp.setChangePercent((int) (percent * 100) + ""); temp.setChangePercent((int) (percent * 100) + "");
temp.setAppId(cylinderUnit.getAppId()); temp.setAppId(cylinderUnit.getAppId());
temp.setChangeSum(thisMonth - lastMonth); temp.setChangeSum(thisMonth - lastMonth);
temp.setChangeSum(Double.valueOf(df.format(temp.getChangeSum())));
cylinderFillingDataUnitServiceImpl.createWithModel(temp); cylinderFillingDataUnitServiceImpl.createWithModel(temp);
} }
}); });
...@@ -667,6 +671,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind ...@@ -667,6 +671,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
* @param cylinderFillingCheckDataUnitDto * @param cylinderFillingCheckDataUnitDto
*/ */
public void calcCylinderFillingCheckDataUnitData(CylinderUnit cylinderUnit, Calendar calender, CylinderFillingCheckDataUnitDto cylinderFillingCheckDataUnitDto) { public void calcCylinderFillingCheckDataUnitData(CylinderUnit cylinderUnit, Calendar calender, CylinderFillingCheckDataUnitDto cylinderFillingCheckDataUnitDto) {
DecimalFormat df = new DecimalFormat("#0.00");
String year = calender.get(Calendar.YEAR) + ""; String year = calender.get(Calendar.YEAR) + "";
int month = calender.get(Calendar.MONTH) + 1; int month = calender.get(Calendar.MONTH) + 1;
String monthStr = month < 10 ? "0" + month : month + ""; String monthStr = month < 10 ? "0" + month : month + "";
...@@ -687,14 +692,14 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind ...@@ -687,14 +692,14 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
before = (double) (fillingCount) / (double) countThisMonth; before = (double) (fillingCount) / (double) countThisMonth;
} }
cylinderFillingCheckDataUnitDto.setFillingCount((long) fillingCount); cylinderFillingCheckDataUnitDto.setFillingCount((long) fillingCount);
cylinderFillingCheckDataUnitDto.setFillingPercent(before * 100); cylinderFillingCheckDataUnitDto.setFillingPercent(Double.valueOf(df.format(before * 100)));
// 充装后检查率:充装后检查次数/充装次数 // 充装后检查率:充装后检查次数/充装次数
double after = 0d; double after = 0d;
if (countThisMonth != 0) { if (countThisMonth != 0) {
after = (double) (fillingCheckCount) / (double) countThisMonth; after = (double) (fillingCheckCount) / (double) countThisMonth;
} }
cylinderFillingCheckDataUnitDto.setFillingCheckCount((long) fillingCheckCount); cylinderFillingCheckDataUnitDto.setFillingCheckCount((long) fillingCheckCount);
cylinderFillingCheckDataUnitDto.setFillingCheckPercent(after * 100); cylinderFillingCheckDataUnitDto.setFillingCheckPercent(Double.valueOf(df.format(after * 100)));
// 充装合格率:充装前检查合格次数+充装后检查合格次数/2*充装次数 // 充装合格率:充装前检查合格次数+充装后检查合格次数/2*充装次数
double passed = 0d; double passed = 0d;
// 充装前检查合格次数 // 充装前检查合格次数
...@@ -709,7 +714,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind ...@@ -709,7 +714,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
} }
cylinderFillingCheckDataUnitDto.setFillingPassedCount((long) (fillingPassedCount + fillingCheckPassedCount)); cylinderFillingCheckDataUnitDto.setFillingPassedCount((long) (fillingPassedCount + fillingCheckPassedCount));
cylinderFillingCheckDataUnitDto.setTotalSumDouble((long) 2 * countThisMonth); cylinderFillingCheckDataUnitDto.setTotalSumDouble((long) 2 * countThisMonth);
cylinderFillingCheckDataUnitDto.setFillingPassedPercent(passed * 100); cylinderFillingCheckDataUnitDto.setFillingPassedPercent(Double.valueOf(df.format(passed * 100)));
cylinderFillingCheckDataUnitDto.setAppId(cylinderUnit.getAppId()); cylinderFillingCheckDataUnitDto.setAppId(cylinderUnit.getAppId());
} }
......
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