Sfoglia il codice sorgente

文件柜手机端接口,列表展示,详情等功能

yanliming 10 mesi fa
parent
commit
7e6b866bc9

+ 1 - 0
common/src/main/java/com/jpsoft/railroad/modules/base/dao/OaFileInfoDAO.java

@@ -15,4 +15,5 @@ public interface OaFileInfoDAO {
 	int delete(String id);
 	List<OaFileInfo> list();
 	List<OaFileInfo> search(Map<String, Object> searchParams, List<Sort> sortList);
+	List<OaFileInfo> searchByMobile(Map<String, Object> searchParams, List<Sort> sortList);
 }

+ 1 - 0
common/src/main/java/com/jpsoft/railroad/modules/base/service/OaFileInfoService.java

@@ -13,4 +13,5 @@ public interface OaFileInfoService {
 	int delete(String id);
 	List<OaFileInfo> list();
 	Page<OaFileInfo> pageSearch(Map<String, Object> searchParams, int pageNum, int pageSize, boolean count, List<Sort> sortList);
+	Page<OaFileInfo> pageSearchByMobile(Map<String, Object> searchParams, int pageNum, int pageSize, boolean count, List<Sort> sortList);
 }

+ 9 - 0
common/src/main/java/com/jpsoft/railroad/modules/base/service/impl/OaFileInfoServiceImpl.java

@@ -67,4 +67,13 @@ public class OaFileInfoServiceImpl implements OaFileInfoService {
         
         return page;
 	}
+
+	@Override
+	public Page<OaFileInfo> pageSearchByMobile(Map<String, Object> searchParams, int pageNumber, int pageSize, boolean count, List<Sort> sortList) {
+		Page<OaFileInfo> page = PageHelper.startPage(pageNumber, pageSize, count).doSelectPage(() -> {
+			oaFileInfoDAO.searchByMobile(searchParams, sortList);
+		});
+
+		return page;
+	}
 }

+ 1 - 1
common/src/main/java/com/jpsoft/railroad/modules/common/utils/SMSUtil.java

@@ -145,7 +145,7 @@ public class SMSUtil {
 
 
 	public static String generateNumberString(int length) {
-		StringBuffer sb = new StringBuffer();
+		StringBuffer  sb = new StringBuffer();
 		Random random = new Random();
 		for (int i = 0; i < length; i++) {
 			sb.append(NUMBERCHAR.charAt(random.nextInt(NUMBERCHAR.length())));

+ 1 - 0
common/src/main/java/com/jpsoft/railroad/modules/form/dao/WaybillInfoDAO.java

@@ -23,4 +23,5 @@ public interface WaybillInfoDAO {
 	int countInvalidBillByDateRange(@Param("billType") String billType,@Param("stationId") String stationId,@Param("startDate") String startDate,@Param("endDate") String endDate);
 	List<WaybillInfo> findInvalidBillByDateRange(@Param("billType") String billType,@Param("stationId") String stationId,@Param("startDate") String startDate,@Param("endDate") String endDate);
 	List<WaybillInfo> search(Map<String,Object> searchParams,List<Sort> sortList);
+	WaybillInfo isRepeated(@Param("billNumber")String billNumber,@Param("stationId")String stationId,@Param("billType")String billType);
 }

+ 16 - 0
common/src/main/java/com/jpsoft/railroad/modules/form/service/impl/WaybillInfoServiceImpl.java

@@ -48,6 +48,22 @@ public class WaybillInfoServiceImpl implements WaybillInfoService {
 
     @Override
     public int insertAll(WaybillInfo model) {
+
+        //判断数据库是否已有单号记录,防止生成重复流水号
+        WaybillInfo isRepeatModel = waybillInfoDAO.isRepeated(model.getBillNumber(),model.getStationId(),model.getBillType());
+        while(isRepeatModel!=null){
+            long newBillNumber;
+
+            String num = isRepeatModel.getBillNumber().substring(1);
+            newBillNumber = Long.parseLong(num) + 1;
+
+            String billNumber = String.format("%07d", newBillNumber);
+
+            model.setBillNumber(billNumber);
+
+            isRepeatModel = waybillInfoDAO.isRepeated(billNumber,isRepeatModel.getStationId(),isRepeatModel.getBillType());
+        }
+
         int count = waybillInfoDAO.insert(model);
 
         if (count > 0) {

+ 25 - 0
common/src/main/resources/mapper/base/OaFileInfo.xml

@@ -117,4 +117,29 @@
 	        ${sort.name} ${sort.order}
 	 	</foreach>
 	</select>
+	<select id="searchByMobile" parameterType="hashmap" resultMap="OaFileInfoMap">
+		<![CDATA[
+			select * from base_oa_file_info a
+		]]>
+		<where>
+			a.del_flag = 0
+			<if test="searchParams.createTime != null">
+				and DATE_FORMAT( a.create_time, '%Y-%m-%d' ) = DATE_FORMAT( #{createTime}, '%Y-%m-%d' )
+			</if>
+			<if test="searchParams.name != null">
+				and a.name_ like #{searchParams.name}
+			</if>
+			<if test="searchParams.businessIds != null">
+				and a.id_ in (select file_id from base_oa_file_reg_user_info
+				where del_flag = 0
+				<foreach item="businessId" collection="searchParams.businessIds"  open="and business_id in (" separator="," close=")">
+					#{businessId}
+				</foreach>
+				)
+			</if>
+		</where>
+		<foreach item="sort" collection="sortList"  open="order by" separator=",">
+			${sort.name} ${sort.order}
+		</foreach>
+	</select>
 </mapper>

+ 7 - 0
common/src/main/resources/mapper/form/WaybillInfo.xml

@@ -229,6 +229,13 @@
 		where bill_number is not null and station_id = #{stationId} and bill_type = #{billType}
 		order by create_time desc limit 1
 	</select>
+	<select id="isRepeated" resultMap="WaybillInfoMap">
+		select * from form_waybill_info
+		where bill_number = #{billNumber}
+		and station_id = #{stationId}
+		and bill_type = #{billType}
+		order by create_time desc limit 1
+	</select>
 	<select id="findAllByDateRange" resultMap="WaybillInfoMap">
 		select * from form_waybill_info
 		<where>

+ 126 - 0
web/src/main/java/com/jpsoft/railroad/modules/mobile/controller/OaFileInfoApi.java

@@ -0,0 +1,126 @@
+package com.jpsoft.railroad.modules.mobile.controller;
+
+
+import com.github.pagehelper.Page;
+import com.jpsoft.railroad.modules.base.entity.OaFileInfo;
+import com.jpsoft.railroad.modules.base.entity.RegUser;
+import com.jpsoft.railroad.modules.base.service.OaFileInfoService;
+import com.jpsoft.railroad.modules.base.service.OaFileRegUserInfoService;
+import com.jpsoft.railroad.modules.base.service.OrganizationService;
+import com.jpsoft.railroad.modules.base.service.RegUserService;
+import com.jpsoft.railroad.modules.common.dto.MessageResult;
+import com.jpsoft.railroad.modules.common.dto.Sort;
+import com.jpsoft.railroad.modules.common.utils.PojoUtils;
+import com.jpsoft.railroad.modules.sys.service.DataDictionaryService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.format.annotation.DateTimeFormat;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.*;
+
+@RestController
+@RequestMapping("/mobile/oaFileInfo")
+@Api(description = "文件柜")
+public class OaFileInfoApi {
+
+    private Logger logger = LoggerFactory.getLogger(getClass());
+
+    @Value("${jwt.secret}")
+    private String jwtSecret;
+
+    @Autowired
+    private RegUserService regUserService;
+
+    @Autowired
+    private OaFileInfoService oaFileInfoService;
+
+
+    @ApiOperation(value="公告列表")
+    @RequestMapping(value = "oaFileInfoList",method = RequestMethod.POST)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "name", value = "name", required = false,paramType = "form"),
+            @ApiImplicitParam(name = "queryDate", value = "queryDate", required = false,paramType = "form"),
+    })
+    public MessageResult<Map> oaFileInfoList(
+            @DateTimeFormat(pattern = "yyyy-MM-dd") Date queryDate,
+            @RequestParam(value = "name", defaultValue = "") String name,
+            @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
+            @RequestParam(value="pageSize",defaultValue="20") int pageSize,
+            @RequestAttribute String subject){
+        MessageResult<Map> msgResult = new MessageResult<>();
+        Map<String, Object> map = new HashMap<>();
+
+        try {
+            Map<String,Object> searchParams = new HashMap<>();
+
+            RegUser regUser = regUserService.get(subject);
+            if(regUser == null){
+                throw new Exception("未登录");
+            }
+
+            List<Sort> sortList = new ArrayList<>();
+            sortList.add(new Sort("create_time","desc"));
+
+            if(queryDate != null){
+                searchParams.put("createTime",queryDate);
+            }
+
+            if(queryDate != null){
+                searchParams.put("name","%" + name + "%");
+            }
+
+            searchParams.put("businessIds",Arrays.asList(regUser.getId(),regUser.getOrgId()));
+
+            Page<OaFileInfo> page = oaFileInfoService.pageSearchByMobile(searchParams,pageIndex,pageSize,true,sortList);
+
+            msgResult.setResult(true);
+            msgResult.setData(PojoUtils.pageWrapper(page));
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="公告详细")
+    @RequestMapping(value = "oaFileInfoDetails",method = RequestMethod.POST)
+    public MessageResult<Map> oaFileInfoDetails(
+            String id,
+            @RequestAttribute String subject){
+        MessageResult<Map> msgResult = new MessageResult<>();
+
+        try {
+            Map<String,Object> returnMap = new HashMap<>();
+
+            RegUser regUser = regUserService.get(subject);
+            if(regUser == null){
+                throw new Exception("未登录");
+            }
+
+            OaFileInfo oaFileInfo = oaFileInfoService.get(id);
+            returnMap.put("oaFileInfo",oaFileInfo);
+
+            msgResult.setResult(true);
+            msgResult.setData(returnMap);
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+}