|
@@ -0,0 +1,219 @@
|
|
|
+package com.tofly.fees.meterreadingmgt.controller;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.tofly.common.core.entity.ResultRespone;
|
|
|
+import com.tofly.fees.codemgt.mapper.BmMrAreaMapper;
|
|
|
+import com.tofly.fees.codemgt.service.BmMrAreaService;
|
|
|
+import com.tofly.fees.common.dbhelper.DbHelper;
|
|
|
+import com.tofly.fees.common.dbhelper.PageSortHelper;
|
|
|
+import com.tofly.fees.meterreadingmgt.mapper.BwMeterReadPlanMapper;
|
|
|
+import com.tofly.fees.meterreadingmgt.service.IBwMeterReadPlanService;
|
|
|
+import com.tofly.fees.userprofilemgt.mapper.DaCustomerMapper;
|
|
|
+import com.tofly.fees.userprofilemgt.service.DaCustomerService;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import java.text.MessageFormat;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+
|
|
|
+ * 抄表管理-用户表册设置
|
|
|
+ *
|
|
|
+ * @author shudong
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@AllArgsConstructor
|
|
|
+@RequestMapping("/api/userMrBookSet")
|
|
|
+@Api(tags = "抄表管理-用户表册设置")
|
|
|
+public class UserMrBookSetController {
|
|
|
+ private final BwMeterReadPlanMapper bwMeterReadPlanMapper;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ * 用户表册设置:未分配抄表册的用户
|
|
|
+ */
|
|
|
+ @PostMapping("/unAllotList")
|
|
|
+ @ApiOperation(value = "未分配抄表册用户列表")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "companyBranch", value = "公司", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "mrArea", value = "片区", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "searchText", value = "模糊查询(用户编号、姓名)", dataType = "String")
|
|
|
+ })
|
|
|
+ public ResultRespone getUnAllotList(Page page, String companyBranch, String mrArea
|
|
|
+ , String searchText) {
|
|
|
+ PageSortHelper.setPageSort(page, null);
|
|
|
+ IPage<Map<String, Object>> pageList = bwMeterReadPlanMapper.getMrBookUserList(page, companyBranch, mrArea
|
|
|
+ , null, searchText, null);
|
|
|
+ return ResultRespone.success(pageList);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 用户表册设置:已分配抄表册的用户
|
|
|
+ */
|
|
|
+ @PostMapping("/allotList")
|
|
|
+ @ApiOperation(value = "已分配抄表册用户列表")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "companyBranch", value = "公司", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "mrArea", value = "片区", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "mrBook", value = "抄表本", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "searchText", value = "模糊查询(用户编号、姓名)", dataType = "String")
|
|
|
+ })
|
|
|
+ public ResultRespone getAllotList(Page page, String companyBranch, String mrArea
|
|
|
+ , String mrBook, String searchText) {
|
|
|
+ PageSortHelper.setPageSort(page, null);
|
|
|
+ IPage<Map<String, Object>> pageList = bwMeterReadPlanMapper.getMrBookUserList(page, companyBranch, mrArea
|
|
|
+ , mrBook, searchText, "not");
|
|
|
+ return ResultRespone.success(pageList);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ * 用户表册设置:选择分配
|
|
|
+ */
|
|
|
+ @PostMapping("/selectAllotment")
|
|
|
+ @ApiOperation(value = "用户表册设置:选择分配")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "mrBook", value = "抄表本", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "customerNos", value = "用户编号集", dataType = "String")
|
|
|
+ })
|
|
|
+ public ResultRespone selectAllotment(String mrBook, String customerNos) throws Exception {
|
|
|
+ if (StringUtils.isBlank(mrBook)) {
|
|
|
+ return ResultRespone.failed("抄表本编码不能为空!");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(customerNos)) {
|
|
|
+ return ResultRespone.failed("用户编号集不能为空!");
|
|
|
+ }
|
|
|
+ String strWhere = MessageFormat.format("and customer_no in ({0})", customerNos);
|
|
|
+ return getAllotmentResult(mrBook, strWhere, false);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 用户表册设置:全部分配
|
|
|
+ */
|
|
|
+ @PostMapping("/allAllotment")
|
|
|
+ @ApiOperation(value = "用户表册设置:全部分配")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "mrArea", value = "抄表片区", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "mrBook", value = "抄表本", dataType = "String")
|
|
|
+ })
|
|
|
+ public ResultRespone allAllotment(String mrArea, String mrBook) throws Exception {
|
|
|
+ if (StringUtils.isBlank(mrBook)) {
|
|
|
+ return ResultRespone.failed("抄表本编码不能为空!");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(mrArea)) {
|
|
|
+ mrArea = "";
|
|
|
+ } else {
|
|
|
+ mrArea = MessageFormat.format("and mr_area='{0}'", mrArea);
|
|
|
+ }
|
|
|
+ return getAllotmentResult(mrBook, mrArea, true);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 获取分配的处理过程返回
|
|
|
+ *
|
|
|
+ * @param mrBook 抄表本值
|
|
|
+ * @param strWhere 条件语句
|
|
|
+ * @param isAll 是否全部操作
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ private ResultRespone<Boolean> getAllotmentResult(String mrBook, String strWhere, Boolean isAll) throws Exception {
|
|
|
+ DbHelper dbHelper = DbHelper.getDbHelper();
|
|
|
+ String strMrArea = dbHelper.getValue("select mr_area from tf_ywys_bm_mr_book where code='" + mrBook + "'");
|
|
|
+ List<HashMap<String, Object>> listUser = dbHelper.getList("select customer_no from tf_ywys_da_customer where mr_book is null " + strWhere + " order by customer_no");
|
|
|
+
|
|
|
+
|
|
|
+ int intMaxSort = Integer.parseInt(dbHelper.getValue("select NVL(Max(a.mr_order_no),0) mxh from tf_ywys_da_meter a left join tf_ywys_da_customer b on a.customer_no=b.customer_no where b.mr_book='" + mrBook + "'"));
|
|
|
+ for (int i = 0, len = listUser.size(); i < len; i++) {
|
|
|
+ intMaxSort += 1;
|
|
|
+ String strCusNo = listUser.get(i).get("customer_no").toString();
|
|
|
+ dbHelper.addTransactionSql(MessageFormat.format("update tf_ywys_da_meter set mr_order_no={0} where customer_no='{1}'", intMaxSort, strCusNo));
|
|
|
+ dbHelper.addTransactionSql(MessageFormat.format("update tf_ywys_bw_meter_read_plan set mr_order_no={0} where customer_no='{1}'", intMaxSort, strCusNo));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ String strSql = MessageFormat.format("update #table set mr_area='{0}', mr_book='{1}' where mr_book is null {2}", strMrArea, mrBook, strWhere);
|
|
|
+ dbHelper.addTransactionSql(strSql.replace("#table", "tf_ywys_da_customer"));
|
|
|
+ dbHelper.addTransactionSql(strSql.replace("#table", "tf_ywys_bw_meter_read_plan"));
|
|
|
+
|
|
|
+ String strTopMsg = isAll ? "全部" : "";
|
|
|
+ if (dbHelper.executeTransaction()) {
|
|
|
+ return ResultRespone.success(true, strTopMsg + "分配成功!");
|
|
|
+ } else {
|
|
|
+ return ResultRespone.failed(false, strTopMsg + "分配失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ * 用户表册设置:选择撤销
|
|
|
+ */
|
|
|
+ @PostMapping("/selectCancel")
|
|
|
+ @ApiOperation(value = "用户表册设置:选择撤销")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "mrArea", value = "抄表片区", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "customerNos", value = "用户编号集", dataType = "String")
|
|
|
+ })
|
|
|
+ public ResultRespone selectCancel(String mrArea, String customerNos) throws Exception {
|
|
|
+ if (StringUtils.isBlank(customerNos)) {
|
|
|
+ return ResultRespone.failed("用户编号集不能为空!");
|
|
|
+ }
|
|
|
+ mrArea = StringUtils.isBlank(mrArea) ? "null" : "'" + mrArea + "'";
|
|
|
+ DbHelper dbHelper = DbHelper.getDbHelper();
|
|
|
+ dbHelper.addTransactionSql("update tf_ywys_da_meter set mr_order_no=0 where customer_no in(" + customerNos + ")");
|
|
|
+ dbHelper.addTransactionSql("update tf_ywys_da_customer set mr_area=" + mrArea + ", mr_book=null where customer_no in(" + customerNos + ")");
|
|
|
+ dbHelper.addTransactionSql("update tf_ywys_bw_meter_read_plan set mr_area=" + mrArea + ",mr_book=null,mr_order_no=0 where customer_no in(" + customerNos + ")");
|
|
|
+
|
|
|
+ if (dbHelper.executeTransaction()) {
|
|
|
+ return ResultRespone.success(true, "撤销成功!");
|
|
|
+ } else {
|
|
|
+ return ResultRespone.failed(false, "撤销失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 用户表册设置:全部撤销
|
|
|
+ */
|
|
|
+ @PostMapping("/AllCancel")
|
|
|
+ @ApiOperation(value = "用户表册设置:全部撤销")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "mrArea", value = "抄表片区", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "mrBook", value = "抄表本", dataType = "String")
|
|
|
+ })
|
|
|
+ public ResultRespone allCancel(String mrArea, String mrBook) throws Exception {
|
|
|
+ if (StringUtils.isBlank(mrBook)) {
|
|
|
+ return ResultRespone.failed("抄表本不能为空!");
|
|
|
+ }
|
|
|
+ mrArea = StringUtils.isBlank(mrArea) ? "null" : "'" + mrArea + "'";
|
|
|
+
|
|
|
+ DbHelper dbHelper = DbHelper.getDbHelper();
|
|
|
+ dbHelper.addTransactionSql("update tf_ywys_da_meter set mr_order_no=0 where customer_no in(select customer_no from tf_ywys_da_customer where mr_book='" + mrBook + "')");
|
|
|
+ dbHelper.addTransactionSql("update tf_ywys_da_customer set mr_area=" + mrArea + ", mr_book=null where mr_book='" + mrBook + "'");
|
|
|
+ dbHelper.addTransactionSql("update tf_ywys_bw_meter_read_plan set mr_area=" + mrArea + ",mr_book=null,mr_order_no=0 where mr_book='" + mrBook + "'");
|
|
|
+
|
|
|
+ if (dbHelper.executeTransaction()) {
|
|
|
+ return ResultRespone.success(true, "全部撤销成功!");
|
|
|
+ } else {
|
|
|
+ return ResultRespone.failed(false, "全部撤销失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|