武漢大學正門,資訊學部旁教職工公寓主臥出租(可短租)
阿新 • • 發佈:2020-07-12
http://bbs.whu.edu.cn/bbstcon.php?board=House&gid=89519
package com.tansuo365.test1.controller.kucunstuff; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.reflect.TypeToken; import com.tansuo365.test1.bean.kucunbean.PosunDetails; import com.tansuo365.test1.bean.kucunbean.PosunZong; import com.tansuo365.test1.service.kucunservice.PosunDetailsService; import com.tansuo365.test1.service.kucunservice.PosunZongService; import com.tansuo365.test1.service.kucunservice.WuliaoKucunRiZhiService; import com.tansuo365.test1.util.DateUtil; import com.tansuo365.test1.util.StringUtil; import io.swagger.annotations.Api; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.PropertySource; import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.AsyncResult; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.concurrent.ListenableFuture; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpSession; import java.util.HashMap; import java.util.List; import java.util.Map; @PropertySource(value = "classpath:danhao.properties") @Api(value = "破損單相關控制層", tags = "", description = "") @RestController @RequestMapping("/admin/posundan") public class PosunDanController { @Autowired private PosunZongService posunZongService; @Autowired private PosunDetailsService posunDetailsService; @Autowired private WuliaoKucunRiZhiService wuliaoKucunRiZhiService; @Value("${danhao.posundan.prefix}") private String posundanPrefix; /** * 獲取破損單號 * * @param type * @return * @throws Exception */ @Async @RequestMapping("/getPosunNumber") public ListenableFuture<String> getBillCode(String type) throws Exception { StringBuffer billCodeStr = new StringBuffer(); billCodeStr.append(posundanPrefix); billCodeStr.append(DateUtil.getCurrentDateStr()); String todayMaxShengouDanNumber = posunZongService.getTodayMaxPosunDanNumber(); if (todayMaxShengouDanNumber != null) { billCodeStr.append(StringUtil.formatCode(todayMaxShengouDanNumber)); } else { billCodeStr.append("0001"); } return new AsyncResult<>(billCodeStr.toString()); } @RequestMapping("/getSelective") public Map<String, Object> getPosunDan(PosunZong posunZong, @RequestParam(value = "page", required = true) Integer page, @RequestParam(value = "rows", required = true) Integer rows) { if (posunZong == null) { return null; } System.out.println("專案名稱:" + posunZong.getXiangmumingcheng()); Map<String, Object> resultMap = new HashMap<>(); PageHelper.startPage(page, rows); List<PosunZong> posunZongsList = posunZongService.listPosunZong(posunZong); PageInfo<PosunZong> pageInfo = new PageInfo<PosunZong>(posunZongsList); resultMap.put("rows", pageInfo.getList()); resultMap.put("total", pageInfo.getTotal()); return resultMap; } /** * 根據zongzhang總表的id查詢對應的子表資料 分頁 * * @param page * @param rows * @return 根據總表id遍歷查詢詳細的物料集合 */ @RequestMapping("/listDetailsByZId") public Map<String, Object> listDetailsByZongId(PosunDetails posunDetails, @RequestParam(value = "page", required = true) Integer page, @RequestParam(value = "rows", required = true) Integer rows) { if (posunDetails == null) { return null; } Map<String, Object> resultMap = new HashMap<>(); PageHelper.startPage(page, rows); List<PosunDetails> posunDetailsList = posunDetailsService.listPosunDetailsSelective(posunDetails); PageInfo<PosunDetails> pageInfo = new PageInfo<PosunDetails>(posunDetailsList); resultMap.put("rows", pageInfo.getList()); resultMap.put("total", pageInfo.getTotal()); return resultMap; } @RequestMapping("/save") public Map<String, Object> save(HttpSession session, PosunZong posunZong, @RequestParam("wuliaoPosunDetailsJson") String wuliaoPosunDetailsJson) { if (posunZong == null || wuliaoPosunDetailsJson == null) { return null; } Map<String, Object> resultMap = new HashMap<>(); Gson gson = new GsonBuilder() .setDateFormat("yyyy-MM-dd HH:mm:ss") .create(); List<PosunDetails> posunDetailsList = gson.fromJson(wuliaoPosunDetailsJson, new TypeToken<List<PosunDetails>>() { }.getType()); posunZong.setChuangjianren((String) session.getAttribute("truename")); //save時,先儲存大表,大表返回id後再儲存附表 int insertCode = posunZongService.saveZongAndDetails(posunZong, posunDetailsList); if(insertCode>0){ resultMap.put("success", true); resultMap.put("msg", "儲存成功."); return resultMap; }else if(insertCode==0){ resultMap.put("success", false); resultMap.put("errorInfo", "儲存失敗"); return resultMap; }else if (insertCode < -99) { PosunDetails posunDetails = posunDetailsList.get((-insertCode) - 100); resultMap.put("success", false); resultMap.put("errorInfo", "儲存失敗,儲存破損物料[" + posunDetails.getMingchengguige() + "]超過現有庫存數量,請核對庫存數量再進行出庫操作."); return resultMap; }else{ PosunDetails posunDetails = posunDetailsList.get((-(insertCode) - 1)); resultMap.put("success",false); resultMap.put("errorInfo","儲存失敗,儲存物料["+posunDetails.getMingchengguige()+"]不存在庫存中."); return resultMap; } } @RequestMapping("/update") public Map<String, Object> update(PosunZong posunZong) { if (posunZong == null) { return null; } Map<String, Object> resultMap = new HashMap<>(); int updateCode = posunZongService.updateByPrimaryKeySelective(posunZong); if (updateCode > 0) { resultMap.put("success", true); return resultMap; } else { resultMap.put("success", false); return resultMap; } } @RequestMapping("/delete") @Transactional public Map<String,Object> deleteBatch(@RequestParam("ids[]") Integer[] ids){ Map<String, Object> resultMap = new HashMap<>(); if (ids == null) { resultMap.put("success", false); resultMap.put("errorInfo", "請選中條目進行刪除"); return resultMap; } int posundan = wuliaoKucunRiZhiService.insertAndDeletePosunOrWeixiuShu(ids, "posundan"); int ziDelCode = 0; int code = posunZongService.deleteBatchByPKArr(ids); // if(code>0){ ziDelCode = posunDetailsService.deleteByZongIdArr(ids); //批量刪除到貨詳細根據ids條目 } if (code > 0 && ziDelCode > 0 && posundan>0) { resultMap.put("success", true); } else { resultMap.put("success", false); } return resultMap; } }
package com.tansuo365.test1.service.kucunservice; import com.tansuo365.test1.bean.kucunbean.PosunDetails; import com.tansuo365.test1.bean.kucunbean.PosunZong; import java.util.List; public interface PosunZongService { String getTodayMaxPosunDanNumber(); int deleteByPrimaryKey(Integer id); //動態查詢破損單總表 List<PosunZong> listPosunZong(PosunZong posunZong); int deleteBatchByPKArr(Integer[] ids); int insertSelective(PosunZong posunZong); //新增破損單 以及所有破損單物料 int saveZongAndDetails(PosunZong posunZong, List<PosunDetails> posunDetailsList); PosunZong selectByPrimaryKey(Integer id); int updateByPrimaryKeySelective(PosunZong posunZong); }
package com.tansuo365.test1.service.kucunservice; import com.tansuo365.test1.bean.kucunbean.ChukuDetails; import com.tansuo365.test1.bean.kucunbean.PosunDetails; import java.util.List; public interface PosunDetailsService { List<PosunDetails> listPosunDetailsByZongId(Integer zongzhangid); List<PosunDetails> listPosunDetailsSelective(PosunDetails posunDetails); int deleteByPrimaryKey(Integer id); int deleteByZongId(Integer zongzhangid); int deleteByZongIdArr(Integer[] ids); int insertSelective(PosunDetails posunDetails); PosunDetails selectByPrimaryKey(Integer id); int updateByPrimaryKeySelective(PosunDetails posunDetails); }
package com.tansuo365.test1.mapper.kucunmapper;
import com.tansuo365.test1.bean.kucunbean.PosunZong;
import java.util.List;
public interface PosunZongMapper {
String getTodayMaxPosunDanNumber();
int deleteByPrimaryKey(Integer id);
//動態查詢破損單總表
List<PosunZong> listPosunZong(PosunZong posunZong);
int deleteBatchByPKArr(Integer[] ids);
int insertSelective(PosunZong posunZong);
PosunZong selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(PosunZong posunZong);
}
package com.tansuo365.test1.mapper.kucunmapper;
import com.tansuo365.test1.bean.kucunbean.PosunDetails;
import java.util.List;
public interface PosunDetailsMapper {
List<PosunDetails> listPosunDetailsByZongId(Integer zongzhangid);
List<PosunDetails> listPosunDetailsSelective(PosunDetails posunDetails);
int deleteByPrimaryKey(Integer id);
int deleteByZongId(Integer zongzhangid);
int deleteByZongIdArr(Integer[] ids);
int insertSelective(PosunDetails posunDetails);
PosunDetails selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(PosunDetails posunDetails);
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tansuo365.test1.mapper.kucunmapper.PosunZongMapper">
<resultMap id="BaseResultMap" type="com.tansuo365.test1.bean.kucunbean.PosunZong">
<result column="id" jdbcType="INTEGER" property="id" />
<result column="pusundanhao" jdbcType="VARCHAR" property="pusundanhao" />
<result column="xiangmumingcheng" jdbcType="VARCHAR" property="xiangmumingcheng" />
<result column="morenkufang" jdbcType="VARCHAR" property="morenkufang" />
<result column="chuangjianren" jdbcType="VARCHAR" property="chuangjianren" />
<result column="createtime" jdbcType="TIMESTAMP" property="createtime" />
<result column="updatetime" jdbcType="TIMESTAMP" property="updatetime" />
</resultMap>
<sql id="Base_Column_List">
id, pusundanhao, xiangmumingcheng, morenkufang, chuangjianren, createtime, updatetime
</sql>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.tansuo365.test1.bean.kucunbean.PosunZong" useGeneratedKeys="true">
insert into wuliaoposundan
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="pusundanhao != null">
pusundanhao,
</if>
<if test="xiangmumingcheng != null">
xiangmumingcheng,
</if>
<if test="morenkufang != null">
morenkufang,
</if>
<if test="chuangjianren != null">
chuangjianren,
</if>
<if test="createtime != null">
createtime,
</if>
<if test="updatetime != null">
updatetime,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="pusundanhao != null">
#{pusundanhao,jdbcType=INTEGER},
</if>
<if test="xiangmumingcheng != null">
#{xiangmumingcheng,jdbcType=VARCHAR},
</if>
<if test="morenkufang != null">
#{morenkufang,jdbcType=VARCHAR},
</if>
<if test="chuangjianren != null">
#{chuangjianren,jdbcType=VARCHAR},
</if>
<if test="createtime != null">
#{createtime,jdbcType=TIMESTAMP},
</if>
<if test="updatetime != null">
#{updatetime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.tansuo365.test1.bean.kucunbean.PosunZong">
update wuliaoposundan
<set>
<if test="pusundanhao != null">
pusundanhao = #{pusundanhao,jdbcType=VARCHAR},
</if>
<if test="xiangmumingcheng != null">
xiangmumingcheng = #{xiangmumingcheng,jdbcType=VARCHAR},
</if>
<if test="morenkufang != null">
morenkufang = #{morenkufang,jdbcType=VARCHAR},
</if>
<if test="chuangjianren != null">
chuangjianren = #{chuangjianren,jdbcType=VARCHAR},
</if>
<if test="createtime != null">
createtime = #{createtime,jdbcType=TIMESTAMP},
</if>
<if test="updatetime != null">
updatetime = #{updatetime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from wuliaoposundan
where id = #{id,jdbcType=INTEGER}
</delete>
<!--批量刪除-->
<delete id="deleteBatchByPKArr">
delete from wuliaoposundan
where id in
<foreach item="ids" index="index" collection="array" open="(" separator="," close=")">
#{ids}
</foreach>
</delete>
<select id="getTodayMaxPosunDanNumber" resultType="java.lang.String">
select max(pusundanhao)
from wuliaoposundan
where TO_DAYS(createtime) = TO_DAYS(NOW());
</select>
<select id="listPosunZong" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from wuliaoposundan
<where>
<if test="id != null and id != ''">
and id= #{id}
</if>
<if test="pusundanhao != null and pusundanhao != '' ">
<bind name="danhaoPattern" value="'%'+pusundanhao+'%'"/>
and pusundanhao like #{danhaoPattern}
</if>
<if test="xiangmumingcheng != null and xiangmumingcheng != ''">
<bind name="xiangmmPattern" value="'%'+xiangmumingcheng+'%'"/>
and xiangmumingcheng like #{xiangmmPattern}
</if>
<if test="morenkufang != null and morenkufang != ''">
<bind name="mkPattern" value="'%'+morenkufang+'%'"/>
and morenkufang like #{mkPattern}
</if>
<if test="chuangjianren != null and chuangjianren != ''">
<bind name="chuangjianrenPattern" value="'%'+chuangjianren+'%'"/>
and chuangjianren like #{chuangjianrenPattern}
</if>
<if test="createtime != null">
and createtime = #{createtime}
</if>
<if test="updatetime != null ">
and updatetime = #{updatetime}
</if>
<if test="s_btime != null">
and createtime >= #{s_btime}
</if>
<if test="s_etime != null">
and createtime <= date_add(#{s_etime}, interval 1 day)
</if>
</where>
<if test="sort != null and sort != ''">
order by ${sort} ${order}
</if>
<if test="sort == null">
order by createtime desc
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultType="com.tansuo365.test1.bean.kucunbean.PosunZong">
select
<include refid="Base_Column_List" />
from wuliaoposundan
where id = #{id,jdbcType=INTEGER}
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tansuo365.test1.mapper.kucunmapper.PosunDetailsMapper">
<resultMap id="BaseResultMap" type="com.tansuo365.test1.bean.kucunbean.PosunDetails">
<result column="id" jdbcType="INTEGER" property="id" />
<result column="dalei" jdbcType="VARCHAR" property="dalei" />
<result column="wuliaobianma" jdbcType="VARCHAR" property="wuliaobianma" />
<result column="mingchengguige" jdbcType="VARCHAR" property="mingchengguige" />
<result column="danwei" jdbcType="VARCHAR" property="danwei" />
<result column="chukushuliang" jdbcType="DOUBLE" property="chukushuliang" />
<result column="chukukufang" jdbcType="VARCHAR" property="chukukufang" />
<result column="beizhu" jdbcType="VARCHAR" property="beizhu" />
<result column="createtime" jdbcType="TIMESTAMP" property="createtime" />
<result column="updatetime" jdbcType="TIMESTAMP" property="updatetime" />
<result column="zongzhangid" jdbcType="INTEGER" property="zongzhangid" />
</resultMap>
<sql id="Base_Column_List">
id, dalei, wuliaobianma, mingchengguige, danwei, chukushuliang, chukukufang, beizhu,
createtime, updatetime, zongzhangid
</sql>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.tansuo365.test1.bean.kucunbean.PosunDetails" useGeneratedKeys="true">
insert into wuliaopusundanmingxi
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="dalei != null">
dalei,
</if>
<if test="wuliaobianma != null">
wuliaobianma,
</if>
<if test="mingchengguige != null">
mingchengguige,
</if>
<if test="danwei != null">
danwei,
</if>
<if test="chukushuliang != null">
chukushuliang,
</if>
<if test="chukukufang != null">
chukukufang,
</if>
<if test="beizhu != null">
beizhu,
</if>
<if test="createtime != null">
createtime,
</if>
<if test="updatetime != null">
updatetime,
</if>
<if test="zongzhangid != null">
zongzhangid,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="dalei != null">
#{dalei,jdbcType=VARCHAR},
</if>
<if test="wuliaobianma != null">
#{wuliaobianma,jdbcType=VARCHAR},
</if>
<if test="mingchengguige != null">
#{mingchengguige,jdbcType=VARCHAR},
</if>
<if test="danwei != null">
#{danwei,jdbcType=VARCHAR},
</if>
<if test="chukushuliang != null">
#{chukushuliang,jdbcType=DOUBLE},
</if>
<if test="chukukufang != null">
#{chukukufang,jdbcType=VARCHAR},
</if>
<if test="beizhu != null">
#{beizhu,jdbcType=VARCHAR},
</if>
<if test="createtime != null">
#{createtime,jdbcType=TIMESTAMP},
</if>
<if test="updatetime != null">
#{updatetime,jdbcType=TIMESTAMP},
</if>
<if test="zongzhangid != null">
#{zongzhangid,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.tansuo365.test1.bean.kucunbean.PosunDetails">
update wuliaopusundanmingxi
<set>
<if test="dalei != null">
dalei = #{dalei},
</if>
<if test="wuliaobianma != null">
wuliaobianma = #{wuliaobianma},
</if>
<if test="mingchengguige != null">
mingchengguige = #{mingchengguige},
</if>
<if test="danwei != null">
danwei = #{danwei},
</if>
<if test="chukushuliang != null">
chukushuliang = #{chukushuliang},
</if>
<if test="chukukufang != null">
chukukufang = #{chukukufang},
</if>
<if test="beizhu != null">
beizhu = #{beizhu},
</if>
<if test="createtime != null">
createtime = #{createtime},
</if>
<if test="updatetime != null">
updatetime = #{updatetime},
</if>
<if test="zongzhangid != null">
zongzhangid = #{zongzhangid},
</if>
</set>
where id = #{id}
</update>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from wuliaopusundanmingxi
where id = #{id}
</delete>
<delete id="deleteByZongId">
delete from wuliaopusundanmingxi
where zongzhangid = #{zongzhangid}
</delete>
<!--批量刪除根據總表id的集合陣列-->
<delete id="deleteByZongIdArr" parameterType="java.lang.String">
delete from wuliaopusundanmingxi
where zongzhangid in
<foreach item="ids" index="index" collection="array" open="(" separator="," close=")">
#{ids}
</foreach>
</delete>
<select id="listPosunDetailsByZongId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from wuliaopusundanmingxi
where zongzhangid = #{zongzhangid}
order by createtime desc
</select>
<select id="listPosunDetailsSelective" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from wuliaopusundanmingxi
<where>
<if test="id != null and id != ''">
and id = #{id}
</if>
<if test="dalei != null and dalei != ''">
and dalei = #{dalei}
</if>
<if test="wuliaobianma != null and wuliaobianma != ''">
and wuliaobianma = #{wuliaobianma}
</if>
<if test="mingchengguige != null and mingchengguige != ''">
and mingchengguige = #{mingchengguige}
</if>
<if test="danwei != null and danwei != ''">
and danwei = #{danwei}
</if>
<if test="chukushuliang != null and chukushuliang != ''">
and chukushuliang = #{chukushuliang}
</if>
<if test="chukukufang != null and chukukufang != ''">
and chukukufang = #{chukukufang}
</if>
<if test="beizhu != null and beizhu != ''">
and beizhu = #{beizhu}
</if>
<if test="createtime != null and createtime != ''">
and createtime = #{createtime}
</if>
<if test="updatetime != null and updatetime != ''">
and updatetime = #{updatetime}
</if>
<if test="zongzhangid != null and zongzhangid != ''">
and zongzhangid= #{zongzhangid}
</if>
</where>
<if test="sort != null and sort != ''">
order by ${sort} ${order}
</if>
<if test="sort == null">
order by createtime desc
</if>
</select>
<select id="selectByPrimaryKey" resultType="com.tansuo365.test1.bean.kucunbean.PosunDetails">
select
<include refid="Base_Column_List"/>
from wuliaopusundanmingxi
where id = #{id}
</select>
</mapper>